Unified string handling.
[collectd.git] / src / collectd.c
index d2ca568..2044b49 100644 (file)
@@ -86,8 +86,7 @@ static int init_hostname (void)
        str = global_option_get ("Hostname");
        if (str != NULL)
        {
-               strncpy (hostname_g, str, sizeof (hostname_g));
-               hostname_g[sizeof (hostname_g) - 1] = '\0';
+               sstrncpy (hostname_g, str, sizeof (hostname_g));
                return (0);
        }
 
@@ -123,8 +122,7 @@ static int init_hostname (void)
                if (ai_ptr->ai_canonname == NULL)
                        continue;
 
-               strncpy (hostname_g, ai_ptr->ai_canonname, sizeof (hostname_g));
-               hostname_g[sizeof (hostname_g) - 1] = '\0';
+               sstrncpy (hostname_g, ai_ptr->ai_canonname, sizeof (hostname_g));
                break;
        }