#include "collectd.h"
-#include "common.h"
#include "plugin.h"
+#include "utils/common/common.h"
#include <stdio.h>
#include <stdlib.h>
void *cb_data) {
const struct sr_datafeed_analog *analog;
struct config_device *cfdev;
- value_t value;
value_list_t vl = VALUE_LIST_INIT;
/* Find this device's configuration. */
/* Ignore all but the first sample on the first probe. */
analog = packet->payload;
- value.gauge = analog->data[0];
- vl.values = &value;
+ vl.values = &(value_t){.gauge = analog->data[0]};
vl.values_len = 1;
- sstrncpy(vl.host, hostname_g, sizeof(vl.host));
sstrncpy(vl.plugin, "sigrok", sizeof(vl.plugin));
- ssnprintf(vl.plugin_instance, sizeof(vl.plugin_instance), "%s", cfdev->name);
+ sstrncpy(vl.plugin_instance, cfdev->name, sizeof(vl.plugin_instance));
sstrncpy(vl.type, sigrok_value_type(analog), sizeof(vl.type));
plugin_dispatch_values(&vl);
}
cfdev->sdi = devlist->data;
g_slist_free(devlist);
- ssnprintf(hwident, sizeof(hwident), "%s %s %s",
- cfdev->sdi->vendor ? cfdev->sdi->vendor : "",
- cfdev->sdi->model ? cfdev->sdi->model : "",
- cfdev->sdi->version ? cfdev->sdi->version : "");
+ snprintf(hwident, sizeof(hwident), "%s %s %s",
+ cfdev->sdi->vendor ? cfdev->sdi->vendor : "",
+ cfdev->sdi->model ? cfdev->sdi->model : "",
+ cfdev->sdi->version ? cfdev->sdi->version : "");
INFO("sigrok plugin: Device \"%s\" is a %s", cfdev->name, hwident);
if (sr_dev_open(cfdev->sdi) != SR_OK)
return -1;
}
- status = plugin_thread_create(&sr_thread, NULL, sigrok_read_thread, NULL);
+ status = plugin_thread_create(&sr_thread, NULL, sigrok_read_thread, NULL,
+ "sigrok read");
if (status != 0) {
- char errbuf[1024];
- ERROR("sigrok plugin: Failed to create thread: %s.",
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ ERROR("sigrok plugin: Failed to create thread: %s.", STRERRNO);
return -1;
}
sr_thread_running = TRUE;