Merge branch 'collectd-4.10' into collectd-5.0
[collectd.git] / src / common.c
index 7813d5b..6fdb441 100644 (file)
 # include <math.h>
 #endif
 
-/* for ntohl and htonl */
-#if HAVE_ARPA_INET_H
-# include <arpa/inet.h>
-#endif
-
 /* for getaddrinfo */
 #include <sys/types.h>
 #include <sys/socket.h>
 # include <netinet/in.h>
 #endif
 
+/* for ntohl and htonl */
+#if HAVE_ARPA_INET_H
+# include <arpa/inet.h>
+#endif
+
 #ifdef HAVE_LIBKSTAT
 extern kstat_ctl_t *kc;
 #endif
@@ -941,9 +941,13 @@ int parse_identifier_vl (const char *str, value_list_t *vl) /* {{{ */
 
        sstrncpy (vl->host, host, sizeof (host));
        sstrncpy (vl->plugin, plugin, sizeof (plugin));
-       sstrncpy (vl->plugin_instance, plugin_instance, sizeof (plugin_instance));
+       sstrncpy (vl->plugin_instance,
+                       (plugin_instance != NULL) ? plugin_instance : "",
+                       sizeof (plugin_instance));
        sstrncpy (vl->type, type, sizeof (type));
-       sstrncpy (vl->type_instance, type_instance, sizeof (type_instance));
+       sstrncpy (vl->type_instance,
+                       (type_instance != NULL) ? type_instance : "",
+                       sizeof (type_instance));
 
        return (0);
 } /* }}} int parse_identifier_vl */