X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fserial.c;h=482232024123a5f7172588716fe2b5884fe51c92;hb=1aa4295ba6875ceb02a7383237bc2485ffab9c1e;hp=0878d3c93b1dac2b4d4bc331e4d13e56a358ede9;hpb=43ef00c0eb99991902d3c9a5fbe582cde049b055;p=collectd.git diff --git a/src/serial.c b/src/serial.c index 0878d3c9..48223202 100644 --- a/src/serial.c +++ b/src/serial.c @@ -22,6 +22,7 @@ **/ #include "collectd.h" + #include "common.h" #include "plugin.h" @@ -32,14 +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; + vl.values_len = STATIC_ARRAY_SIZE (values); sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "serial", sizeof (vl.plugin)); sstrncpy (vl.type, "serial_octets", sizeof (vl.type)); @@ -73,7 +74,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 +90,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)