X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmodbus.c;h=589ce90fd2e2b85d86714f11f0ceb87ab34b573b;hb=6d8031d73b7c1d874d7afa4cad2f248c4073764d;hp=82213d2c6b62ed21c11e035ad7f79a77c935b6e3;hpb=e62ca6291b991412d3d8cbcecd4274b8c66a457d;p=collectd.git diff --git a/src/modbus.c b/src/modbus.c index 82213d2c..589ce90f 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -23,11 +23,12 @@ #include "collectd.h" #include "common.h" +#include "configfile.h" #include "plugin.h" -#include - #include +#include +#include #ifndef LIBMODBUS_VERSION_CHECK /* Assume version 2.0.3 */ @@ -472,10 +473,9 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ { /* getpeername() is used only to determine if the socket is connected, not * because we're really interested in the peer's IP address. */ - status = getpeername (modbus_get_socket (host->connection), - (struct sockaddr *) &(struct sockaddr_storage) { 0 }, - &(socklen_t) { sizeof (struct sockaddr_storage) }); - if (status != 0) + if (getpeername (modbus_get_socket (host->connection), + (void *) &(struct sockaddr_storage) {0}, + &(socklen_t) {sizeof(struct sockaddr_storage)}) != 0) status = errno; } @@ -1003,18 +1003,17 @@ static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ if (status == 0) { - user_data_t ud; char name[1024]; - ud.data = host; - ud.free_func = host_free; - ssnprintf (name, sizeof (name), "modbus-%s", host->host); plugin_register_complex_read (/* group = */ NULL, name, /* callback = */ mb_read, /* interval = */ host->interval, - &ud); + &(user_data_t) { + .data = host, + .free_func = host_free, + }); } else {