X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fmbmon.c;h=87e54fa18406dd44a4d07a2822b00a90c79083fe;hb=5917eb3d38171296d021351aba4e2601c8819bb7;hp=5f398d0c8301fd1701a98c0d1a68695323290487;hpb=cd5c60931ef73c6c34be6dcf58538b069be17c58;p=collectd.git diff --git a/src/mbmon.c b/src/mbmon.c index 5f398d0c..87e54fa1 100644 --- a/src/mbmon.c +++ b/src/mbmon.c @@ -24,9 +24,9 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" -#include "configfile.h" #include #include @@ -84,7 +84,7 @@ static int mbmon_query_daemon (char *buffer, int buffer_size) const char *host; const char *port; - struct addrinfo *ai_list, *ai_ptr; + struct addrinfo *ai_list; int ai_return; host = mbmon_host; @@ -114,7 +114,7 @@ static int mbmon_query_daemon (char *buffer, int buffer_size) } fd = -1; - for (ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) + for (struct addrinfo *ai_ptr = ai_list; ai_ptr != NULL; ai_ptr = ai_ptr->ai_next) { /* create our socket descriptor */ if ((fd = socket (ai_ptr->ai_family, ai_ptr->ai_socktype, ai_ptr->ai_protocol)) < 0) @@ -218,14 +218,10 @@ static int mbmon_config (const char *key, const char *value) static void mbmon_submit (const char *type, const char *type_instance, double value) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; - values[0].gauge = value; - - vl.values = values; + vl.values = &(value_t) { .gauge = value }; vl.values_len = 1; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "mbmon", sizeof (vl.plugin)); sstrncpy (vl.type, type, sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, sizeof (vl.type_instance)); @@ -236,9 +232,7 @@ static void mbmon_submit (const char *type, const char *type_instance, /* Trim trailing whitespace from a string. */ static void trim_spaces (char *s) { - size_t l; - - for (l = strlen (s) - 1; (l > 0) && isspace ((int) s[l]); l--) + for (size_t l = strlen (s) - 1; (l > 0) && isspace ((int) s[l]); l--) s[l] = '\0'; }