projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge pull request #1455 from rubenk/configure-ac-remove-dead-code
[collectd.git]
/
src
/
modbus.c
diff --git
a/src/modbus.c
b/src/modbus.c
index
e24f2ec
..
d2b0a53
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 */
@@
-426,7
+426,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);
@@
-440,7
+440,7
@@
static int mb_read_data (mb_host_t *host, mb_slave_t *slave, /* {{{ */
if (ds->ds_num != 1)
{
if (ds->ds_num != 1)
{
- ERROR ("Modbus plugin: The type \"%s\" has %
i
data sources. "
+ ERROR ("Modbus plugin: The type \"%s\" has %
zu
data sources. "
"I can only handle data sets with only one data source.",
data->type, ds->ds_num);
return (-1);
"I can only handle data sets with only one data source.",
data->type, ds->ds_num);
return (-1);
@@
-463,7
+463,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
+732,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
+892,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
+942,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++)
{
@@
-1017,18
+1020,15
@@
static int mb_config_add_host (oconfig_item_t *ci) /* {{{ */
{
user_data_t ud;
char name[1024];
{
user_data_t ud;
char name[1024];
- struct timespec interval = { 0, 0 };
ud.data = host;
ud.free_func = host_free;
ssnprintf (name, sizeof (name), "modbus-%s", host->host);
ud.data = host;
ud.free_func = host_free;
ssnprintf (name, sizeof (name), "modbus-%s", host->host);
- CDTIME_T_TO_TIMESPEC (host->interval, &interval);
-
plugin_register_complex_read (/* group = */ NULL, name,
/* callback = */ mb_read,
plugin_register_complex_read (/* group = */ NULL, name,
/* callback = */ mb_read,
- /* interval = */
(host->interval > 0) ? &interval : NULL
,
+ /* interval = */
host->interval
,
&ud);
}
else
&ud);
}
else