X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmodbus.c;h=809194b4c51538d39a3f25180d8be5df77ebc843;hb=69b8a9a1af204685dfdfaf1279a0f2928e0bbb32;hp=51447b162e0e2240386a8b01c7d94702d3e83af6;hpb=50345eec33951b964e2829e83c30399b71f2baba;p=collectd.git diff --git a/src/modbus.c b/src/modbus.c index 51447b16..809194b4 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -257,7 +257,7 @@ static int mb_submit (mb_host_t *host, mb_slave_t *slave, /* {{{ */ if ((host == NULL) || (slave == NULL) || (data == NULL)) return (EINVAL); - if (host->interval <= 0) + if (host->interval == 0) host->interval = plugin_get_interval (); if (slave->instance[0] == 0) @@ -427,7 +427,7 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ mb_data_t *data) { - uint16_t values[2]; + uint16_t values[2] = { 0 }; int values_num; const data_set_t *ds; int status = 0; @@ -459,7 +459,6 @@ static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */ "is not UINT32.", data->type, DS_TYPE_TO_STRING (ds->ds[0].type)); } - memset (values, 0, sizeof (values)); if ((data->register_type == REG_TYPE_INT32) || (data->register_type == REG_TYPE_UINT32) || (data->register_type == REG_TYPE_FLOAT)) @@ -720,11 +719,10 @@ static void host_free (void *void_host) /* {{{ */ static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */ { - mb_data_t data; + mb_data_t data = { 0 }; int status; int i; - memset (&data, 0, sizeof (data)); data.name = NULL; data.register_type = REG_TYPE_UINT16; data.next = NULL; @@ -820,13 +818,12 @@ static int mb_config_set_host_address (mb_host_t *host, /* {{{ */ { struct addrinfo *ai_list; struct addrinfo *ai_ptr; - struct addrinfo ai_hints; + struct addrinfo ai_hints = { 0 }; int status; if ((host == NULL) || (address == NULL)) return (EINVAL); - memset (&ai_hints, 0, sizeof (ai_hints)); #if AI_ADDRCONFIG ai_hints.ai_flags |= AI_ADDRCONFIG; #endif