X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fonewire.c;h=c333fead4455b9e84e0d0653c5712c8fc8d2667d;hb=c76419c0cf983f1ecd3d36aa236cc4e3f9cff733;hp=8bb2d8161de5b3c145556da1f2be0575d95f97b8;hpb=03af72c5ef8b98ddfcab87ea44b764f5b0e165aa;p=collectd.git diff --git a/src/onewire.c b/src/onewire.c index 8bb2d816..c333fead 100644 --- a/src/onewire.c +++ b/src/onewire.c @@ -336,7 +336,6 @@ static int cow_load_config (const char *key, const char *value) static int cow_read_values (const char *path, const char *name, const ow_family_features_t *family_info) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; int success = 0; @@ -347,10 +346,6 @@ static int cow_read_values (const char *path, const char *name, return 0; } - vl.values = values; - vl.values_len = 1; - - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, name, sizeof (vl.plugin_instance)); @@ -381,7 +376,7 @@ static int cow_read_values (const char *path, const char *name, DEBUG ("Read onewire device %s as %s", file, buffer); endptr = NULL; - values[0].gauge = strtod (buffer, &endptr); + gauge_t g = strtod (buffer, &endptr); if (endptr == NULL) { ERROR ("onewire plugin: Buffer is not a number: %s", buffer); @@ -392,6 +387,9 @@ static int cow_read_values (const char *path, const char *name, sstrncpy (vl.type_instance, family_info->features[i].type_instance, sizeof (vl.type_instance)); + vl.values = &(value_t) { .gauge = g }; + vl.values_len = 1; + plugin_dispatch_values (&vl); success++; @@ -495,7 +493,6 @@ static int cow_read_bus (const char *path) static int cow_simple_read (void) { - value_t values[1]; value_list_t vl = VALUE_LIST_INIT; char *buffer; size_t buffer_size; @@ -507,10 +504,6 @@ static int cow_simple_read (void) /* traverse list and check entries */ for (traverse = direct_list; traverse != NULL; traverse = traverse->next) { - vl.values = values; - vl.values_len = 1; - - sstrncpy (vl.host, hostname_g, sizeof (vl.host)); sstrncpy (vl.plugin, "onewire", sizeof (vl.plugin)); sstrncpy (vl.plugin_instance, traverse->address, sizeof (vl.plugin_instance)); @@ -524,9 +517,8 @@ static int cow_simple_read (void) } DEBUG ("onewire plugin: Read onewire device %s as %s", traverse->path, buffer); - endptr = NULL; - values[0].gauge = strtod (buffer, &endptr); + gauge_t g = strtod (buffer, &endptr); if (endptr == NULL) { ERROR ("onewire plugin: Buffer is not a number: %s", buffer); @@ -536,6 +528,9 @@ static int cow_simple_read (void) sstrncpy (vl.type, traverse->file, sizeof (vl.type)); sstrncpy (vl.type_instance, "", sizeof ("")); + vl.values = &(value_t) { .gauge = g }; + vl.values_len = 1; + plugin_dispatch_values (&vl); free (buffer); } /* for (traverse) */