projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.4' into collectd-5.5
[collectd.git]
/
src
/
modbus.c
diff --git
a/src/modbus.c
b/src/modbus.c
index
e24f2ec
..
c04b308
100644
(file)
--- a/
src/modbus.c
+++ b/
src/modbus.c
@@
-27,7
+27,7
@@
#include <netdb.h>
#include <netdb.h>
-#include <modbus
/modbus
.h>
+#include <modbus.h>
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
#ifndef LIBMODBUS_VERSION_CHECK
/* Assume version 2.0.3 */
@@
-310,7
+310,9
@@
static int mb_init_connection (mb_host_t *host) /* {{{ */
if (host == NULL)
return (EINVAL);
if (host == NULL)
return (EINVAL);
+#if COLLECT_DEBUG
modbus_set_debug (&host->connection, 1);
modbus_set_debug (&host->connection, 1);
+#endif
/* We'll do the error handling ourselves. */
modbus_set_error_handling (&host->connection, NOP_ON_ERROR);
/* 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);
modbus_set_debug (host->connection, 1);
+#endif
/* We'll do the error handling ourselves. */
modbus_set_error_recovery (host->connection, 0);
/* We'll do the error handling ourselves. */
modbus_set_error_recovery (host->connection, 0);
@@
-426,7
+430,7
@@
static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */
uint16_t values[2];
int values_num;
const data_set_t *ds;
uint16_t values[2];
int values_num;
const data_set_t *ds;
- int status;
+ int status
= 0
;
if ((host == NULL) || (slave == NULL) || (data == NULL))
return (EINVAL);
if ((host == NULL) || (slave == NULL) || (data == NULL))
return (EINVAL);
@@
-463,7
+467,6
@@
static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */
else
values_num = 1;
else
values_num = 1;
- status = 0;
if (host->connection == NULL)
{
status = EBADF;
if (host->connection == NULL)
{
status = EBADF;
@@
-733,7
+736,6
@@
static int mb_config_add_data (oconfig_item_t *ci) /* {{{ */
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
- status = 0;
if (strcasecmp ("Type", child->key) == 0)
status = cf_util_get_string_buffer (child,
if (strcasecmp ("Type", child->key) == 0)
status = cf_util_get_string_buffer (child,
@@
-894,7
+896,6
@@
static int mb_config_add_slave (mb_host_t *host, oconfig_item_t *ci) /* {{{ */
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
for (i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
- status = 0;
if (strcasecmp ("Instance", child->key) == 0)
status = cf_util_get_string_buffer (child,
if (strcasecmp ("Instance", child->key) == 0)
status = cf_util_get_string_buffer (child,
@@
-945,9
+946,15
@@
static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */
status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host));
if (status != 0)
status = cf_util_get_string_buffer (ci, host->host, sizeof (host->host));
if (status != 0)
+ {
+ sfree (host);
return (status);
return (status);
+ }
if (host->host[0] == 0)
if (host->host[0] == 0)
+ {
+ sfree (host);
return (EINVAL);
return (EINVAL);
+ }
for (i = 0; i < ci->children_num; i++)
{
for (i = 0; i < ci->children_num; i++)
{