X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fserial.c;h=dc868fc2da3489558eb59ddcbcde29f07d6cdd47;hb=41288c6a9ed050b41ad47184aa1b53668c3588cc;hp=0878d3c93b1dac2b4d4bc331e4d13e56a358ede9;hpb=b66d5b90a0e59e943a61acb4b68ce55e88f08ade;p=collectd.git diff --git a/src/serial.c b/src/serial.c index 0878d3c9..dc868fc2 100644 --- a/src/serial.c +++ b/src/serial.c @@ -22,6 +22,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -32,15 +33,14 @@ static void serial_submit (const char *type_instance, derive_t rx, derive_t tx) { - value_t values[2]; value_list_t vl = VALUE_LIST_INIT; - - values[0].derive = rx; - values[1].derive = tx; + value_t values[] = { + { .derive = rx }, + { .derive = tx }, + }; vl.values = values; - vl.values_len = 2; - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); + vl.values_len = STATIC_ARRAY_SIZE (values); sstrncpy (vl.plugin, "serial", sizeof (vl.plugin)); sstrncpy (vl.type, "serial_octets", sizeof (vl.type)); sstrncpy (vl.type_instance, type_instance, @@ -73,7 +73,6 @@ static int serial_read (void) char *fields[16]; int numfields; - int i; numfields = strsplit (buffer, fields, STATIC_ARRAY_SIZE (fields)); if (numfields < 6) @@ -90,7 +89,7 @@ static int serial_read (void) continue; fields[0][len - 1] = 0; - for (i = 1; i < numfields; i++) + for (int i = 1; i < numfields; i++) { len = strlen (fields[i]); if (len < 4)