X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=src%2Fmodbus.c;h=2605ec239182bf17315aa1563f38284d680fb13e;hb=0bd857dd5aec94cd6b6fb18b58953bc2663122d1;hp=d2b0a535ff9a0dd135f05fe2b217145ccc9c0315;hpb=74b894a8315a22379e4c0e43f7f3096616879a57;p=collectd.git diff --git a/src/modbus.c b/src/modbus.c index d2b0a535..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,10 +938,9 @@ 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));