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 #1856 from rubenk/snmp-dont-dispatch-values-with-empty-type-instance
[collectd.git]
/
src
/
mqtt.c
diff --git
a/src/mqtt.c
b/src/mqtt.c
index
0b00bab
..
a7a0b86
100644
(file)
--- a/
src/mqtt.c
+++ b/
src/mqtt.c
@@
-31,13
+31,11
@@
#include "collectd.h"
#include "collectd.h"
+
#include "common.h"
#include "plugin.h"
#include "common.h"
#include "plugin.h"
-#include "utils_cache.h"
#include "utils_complain.h"
#include "utils_complain.h"
-#include <pthread.h>
-
#include <mosquitto.h>
#define MQTT_MAX_TOPIC_SIZE 1024
#include <mosquitto.h>
#define MQTT_MAX_TOPIC_SIZE 1024
@@
-147,11
+145,9
@@
static void mqtt_free (mqtt_client_conf_t *conf)
static char *strip_prefix (char *topic)
{
static char *strip_prefix (char *topic)
{
- size_t num;
- size_t i;
+ size_t num = 0;
- num = 0;
- for (i = 0; topic[i] != 0; i++)
+ for (size_t i = 0; topic[i] != 0; i++)
if (topic[i] == '/')
num++;
if (topic[i] == '/')
num++;
@@
-552,9
+548,8
@@
static int mqtt_config_publisher (oconfig_item_t *ci)
{
mqtt_client_conf_t *conf;
char cb_name[1024];
{
mqtt_client_conf_t *conf;
char cb_name[1024];
- user_data_t user_data;
+ user_data_t user_data
= { 0 }
;
int status;
int status;
- int i;
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
@@
-588,7
+583,7
@@
static int mqtt_config_publisher (oconfig_item_t *ci)
C_COMPLAIN_INIT (&conf->complaint_cantpublish);
C_COMPLAIN_INIT (&conf->complaint_cantpublish);
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Host", child->key) == 0)
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Host", child->key) == 0)
@@
-637,7
+632,6
@@
static int mqtt_config_publisher (oconfig_item_t *ci)
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
}
ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
- memset (&user_data, 0, sizeof (user_data));
user_data.data = conf;
plugin_register_write (cb_name, mqtt_write, &user_data);
user_data.data = conf;
plugin_register_write (cb_name, mqtt_write, &user_data);
@@
-659,7
+653,6
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
mqtt_client_conf_t **tmp;
mqtt_client_conf_t *conf;
int status;
mqtt_client_conf_t **tmp;
mqtt_client_conf_t *conf;
int status;
- int i;
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
conf = calloc (1, sizeof (*conf));
if (conf == NULL)
@@
-693,7
+686,7
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
C_COMPLAIN_INIT (&conf->complaint_cantpublish);
C_COMPLAIN_INIT (&conf->complaint_cantpublish);
- for (i = 0; i < ci->children_num; i++)
+ for (i
nt i
= 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Host", child->key) == 0)
{
oconfig_item_t *child = ci->children + i;
if (strcasecmp ("Host", child->key) == 0)
@@
-755,9
+748,7
@@
static int mqtt_config_subscriber (oconfig_item_t *ci)
*/
static int mqtt_config (oconfig_item_t *ci)
{
*/
static int mqtt_config (oconfig_item_t *ci)
{
- int i;
-
- for (i = 0; i < ci->children_num; i++)
+ for (int i = 0; i < ci->children_num; i++)
{
oconfig_item_t *child = ci->children + i;
{
oconfig_item_t *child = ci->children + i;
@@
-774,11
+765,9
@@
static int mqtt_config (oconfig_item_t *ci)
static int mqtt_init (void)
{
static int mqtt_init (void)
{
- size_t i;
-
mosquitto_lib_init ();
mosquitto_lib_init ();
- for (i = 0; i < subscribers_num; i++)
+ for (
size_t
i = 0; i < subscribers_num; i++)
{
int status;
{
int status;