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)
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;
"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))
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;
{
struct addrinfo *ai_list;
struct addrinfo *ai_ptr;
- struct addrinfo ai_hints;
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
- /* XXX: libmodbus can only handle IPv4 addresses. */
- ai_hints.ai_family = AF_INET;
- ai_hints.ai_addr = NULL;
- ai_hints.ai_canonname = NULL;
- ai_hints.ai_next = NULL;
+ struct addrinfo ai_hints = {
+ /* XXX: libmodbus can only handle IPv4 addresses. */
+ .ai_family = AF_INET,
+ .ai_flags = AI_ADDRCONFIG
+ };
- ai_list = NULL;
status = getaddrinfo (address, /* service = */ NULL,
&ai_hints, &ai_list);
if (status != 0)