X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fmodbus.c;h=2605ec239182bf17315aa1563f38284d680fb13e;hb=0bd857dd5aec94cd6b6fb18b58953bc2663122d1;hp=cfc6331e293218b4fdfaca1d99eadabae02754fa;hpb=1978dba8e613eb01581b3376a42137e6fe11ca1a;p=collectd.git diff --git a/src/modbus.c b/src/modbus.c index cfc6331e..2605ec23 100644 --- a/src/modbus.c +++ b/src/modbus.c @@ -310,7 +310,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ if (host == NULL) return (EINVAL); +#if COLLECT_DEBUG modbus_set_debug (&host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_handling (&host->connection, NOP_ON_ERROR); @@ -390,7 +392,9 @@ static int mb_init_connection (mb_host_t *host) /* {{{ */ } } +#if COLLECT_DEBUG modbus_set_debug (host->connection, 1); +#endif /* We'll do the error handling ourselves. */ modbus_set_error_recovery (host->connection, 0); @@ -934,17 +938,22 @@ static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */ int status; int i; - host = malloc (sizeof (*host)); + host = calloc (1, sizeof (*host)); if (host == NULL) return (ENOMEM); - memset (host, 0, sizeof (*host)); host->slaves = NULL; status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host)); if (status != 0) + { + sfree (host); return (status); + } if (host->host[0] == 0) + { + sfree (host); return (EINVAL); + } for (i = 0; i < ci->children_num; i++) {