Unified string handling.
[collectd.git] / src / apcups.c
index 7f8afd4..fb48109 100644 (file)
@@ -124,8 +124,7 @@ static int net_open (char *host, int port)
        assert ((port > 0x00000000) && (port <= 0x0000FFFF));
 
        /* Convert the port to a string */
-       snprintf (port_str, 8, "%i", port);
-       port_str[7] = '\0';
+       ssnprintf (port_str, sizeof (port_str), "%i", port);
 
        /* Resolve name */
        memset ((void *) &ai_hints, '\0', sizeof (ai_hints));
@@ -376,8 +375,8 @@ static void apc_submit_generic (char *type, char *type_inst, double value)
        strcpy (vl.host, hostname_g);
        strcpy (vl.plugin, "apcups");
        strcpy (vl.plugin_instance, "");
-       strncpy (vl.type, type, sizeof (vl.type));
-       strncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
+       sstrncpy (vl.type, type, sizeof (vl.type));
+       sstrncpy (vl.type_instance, type_inst, sizeof (vl.type_instance));
 
        plugin_dispatch_values (&vl);
 }