Merge pull request #1887 from rubenk/make-xfs-optional
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 13 Aug 2016 17:21:21 +0000 (19:21 +0200)
committerGitHub <noreply@github.com>
Sat, 13 Aug 2016 17:21:21 +0000 (19:21 +0200)
Add an option to disable building with XFS support

33 files changed:
configure.ac
src/Makefile.am
src/barometer.c
src/ceph.c
src/collectdctl.c
src/collectdmon.c
src/curl_json.c
src/curl_xml.c
src/daemon/configfile.h
src/dbi.c
src/java.c
src/liboconfig/oconfig.c
src/liboconfig/oconfig.h
src/memcached.c
src/mqtt.c
src/mysql.c
src/netapp.c
src/openldap.c
src/postgresql.c
src/python.c
src/snmp.c
src/tail.c
src/tail_csv.c
src/varnish.c
src/write_graphite.c
src/write_http.c
src/write_kafka.c
src/write_log.c
src/write_mongodb.c
src/write_redis.c
src/write_riemann.c
src/write_sensu.c
src/write_tsdb.c

index e432975..b3e4e7c 100644 (file)
@@ -3348,9 +3348,6 @@ AM_CONDITIONAL(BUILD_WITH_LIBNETAPP, test "x$with_libnetapp" = "xyes")
 # }}}
 
 # --with-libnetsnmp {{{
-with_snmp_config="net-snmp-config"
-with_snmp_cflags=""
-with_snmp_libs=""
 AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Path to the Net-SNMPD library.])],
 [
        if test "x$withval" = "xno"
@@ -3360,57 +3357,42 @@ AC_ARG_WITH(libnetsnmp, [AS_HELP_STRING([--with-libnetsnmp@<:@=PREFIX@:>@], [Pat
        then
                with_libnetsnmp="yes"
        else
-               if test -x "$withval"
-               then
-                       with_snmp_config="$withval"
-                       with_libnetsnmp="yes"
-               else
-                       with_snmp_config="$withval/bin/net-snmp-config"
-                       with_libnetsnmp="yes"
-               fi
+               with_libnetsnmp_cppflags="-I$withval/include"
+               with_libnetsnmp_ldflags="-I$withval/lib"
+               with_libnetsnmp="yes"
        fi; fi
 ],
 [with_libnetsnmp="yes"])
 if test "x$with_libnetsnmp" = "xyes"
 then
-       with_snmp_cflags=`$with_snmp_config --cflags 2>/dev/null`
-       snmp_config_status=$?
-
-       if test $snmp_config_status -ne 0
-       then
-               with_libnetsnmp="no ($with_snmp_config failed)"
-       else
-               SAVE_CPPFLAGS="$CPPFLAGS"
-               CPPFLAGS="$CPPFLAGS $with_snmp_cflags"
+       SAVE_CPPFLAGS="$CPPFLAGS"
+       CPPFLAGS="$CPPFLAGS $with_libnetsnmp_cppflags"
 
-               AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
+       AC_CHECK_HEADERS(net-snmp/net-snmp-config.h, [], [with_libnetsnmp="no (net-snmp/net-snmp-config.h not found)"])
 
-               CPPFLAGS="$SAVE_CPPFLAGS"
-       fi
+       CPPFLAGS="$SAVE_CPPFLAGS"
 fi
 if test "x$with_libnetsnmp" = "xyes"
 then
-       with_snmp_libs=`$with_snmp_config --libs 2>/dev/null`
-       snmp_config_status=$?
+       SAVE_LDFLAGS="$LDFLAGS"
+       LDFLAGS="$LDFLAGS $with_libnetsnmp_ldflags"
 
-       if test $snmp_config_status -ne 0
-       then
-               with_libnetsnmp="no ($with_snmp_config failed)"
-       else
-               AC_CHECK_LIB(netsnmp, init_snmp,
+       AC_CHECK_LIB(netsnmp, init_snmp,
                [with_libnetsnmp="yes"],
                [with_libnetsnmp="no (libnetsnmp not found)"],
                [$with_snmp_libs])
-       fi
+
+       LDFLAGS="$SAVE_LDFLAGS"
 fi
 if test "x$with_libnetsnmp" = "xyes"
 then
-       BUILD_WITH_LIBSNMP_CFLAGS="$with_snmp_cflags"
-       BUILD_WITH_LIBSNMP_LIBS="$with_snmp_libs"
-       AC_SUBST(BUILD_WITH_LIBSNMP_CFLAGS)
-       AC_SUBST(BUILD_WITH_LIBSNMP_LIBS)
+       BUILD_WITH_LIBNETSNMP_CPPFLAGS="$with_libnetsnmp_cppflags"
+       BUILD_WITH_LIBNETSNMP_LDFLAGS="$with_libnetsnmp_ldflags"
+       BUILD_WITH_LIBNETSNMP_LIBS="-lnetsnmp"
 fi
-AM_CONDITIONAL(BUILD_WITH_LIBNETSNMP, test "x$with_libnetsnmp" = "xyes")
+AC_SUBST(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
+AC_SUBST(BUILD_WITH_LIBNETSNMP_LDFLAGS)
+AC_SUBST(BUILD_WITH_LIBNETSNMP_LIBS)
 # }}}
 
 # --with-liboconfig {{{
@@ -3443,7 +3425,7 @@ save_LDFLAGS="$LDFLAGS"
 save_CPPFLAGS="$CPPFLAGS"
 LDFLAGS="$liboconfig_LDFLAGS"
 CPPFLAGS="$liboconfig_CPPFLAGS"
-AC_CHECK_LIB(oconfig, oconfig_parse_fh,
+AC_CHECK_LIB(oconfig, oconfig_parse_file,
 [
        with_liboconfig="yes"
        with_own_liboconfig="no"
index 12c7730..25d7bd4 100644 (file)
@@ -1005,13 +1005,9 @@ endif
 if BUILD_PLUGIN_SNMP
 pkglib_LTLIBRARIES += snmp.la
 snmp_la_SOURCES = snmp.c
-snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS)
-snmp_la_CFLAGS = $(AM_CFLAGS)
-snmp_la_LIBADD =
-if BUILD_WITH_LIBNETSNMP
-snmp_la_CFLAGS += $(BUILD_WITH_LIBSNMP_CFLAGS)
-snmp_la_LIBADD += $(BUILD_WITH_LIBSNMP_LIBS)
-endif
+snmp_la_CPPFLAGS = $(AM_CPPFLAGS) $(BUILD_WITH_LIBNETSNMP_CPPFLAGS)
+snmp_la_LDFLAGS = $(PLUGIN_LDFLAGS) $(BUILD_WITH_LIBNETSNMP_LDFLAGS)
+snmp_la_LIBADD = $(BUILD_WITH_LIBNETSNMP_LIBS)
 endif
 
 if BUILD_PLUGIN_STATSD
index fba3450..998932d 100644 (file)
@@ -30,6 +30,7 @@
 #include <unistd.h>
 #include <linux/i2c-dev.h>
 #include <math.h>
+#include <sys/ioctl.h>
 
 /* ------------ MPL115 defines ------------ */
 /* I2C address of the MPL115 sensor */
index 5248a1a..b186a27 100644 (file)
@@ -1528,6 +1528,7 @@ static int cconn_main_loop(uint32_t request_type)
             if(revents == 0)
             {
                 /* do nothing */
+                continue;
             }
             else if(cconn_validate_revents(io, revents))
             {
index 31183b1..8c88479 100644 (file)
 
 #include "libcollectdclient/collectd/client.h"
 
+#ifndef PREFIX
+# define PREFIX "/opt/" PACKAGE_NAME
+#endif
+
+#ifndef LOCALSTATEDIR
+# define LOCALSTATEDIR PREFIX "/var"
+#endif
+
 #define DEFAULT_SOCK LOCALSTATEDIR"/run/"PACKAGE_NAME"-unixsock"
 
 extern char *optarg;
index 13304f2..61daa58 100644 (file)
 
 #include <unistd.h>
 
+#ifndef PREFIX
+# define PREFIX "/opt/" PACKAGE_NAME
+#endif
+
+#ifndef LOCALSTATEDIR
+# define LOCALSTATEDIR PREFIX "/var"
+#endif
+
 #ifndef COLLECTDMON_PIDFILE
 # define COLLECTDMON_PIDFILE LOCALSTATEDIR"/run/collectdmon.pid"
 #endif /* ! COLLECTDMON_PIDFILE */
index 0c10899..ab0237e 100644 (file)
@@ -758,7 +758,6 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */
   /* If all went well, register this database for reading */
   if (status == 0)
   {
-    user_data_t ud = { 0 };
     char *cb_name;
 
     if (db->instance == NULL)
@@ -767,12 +766,14 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */
     DEBUG ("curl_json plugin: Registering new read callback: %s",
            db->instance);
 
-    ud.data = (void *) db;
-    ud.free_func = cj_free;
-
     cb_name = ssnprintf_alloc ("curl_json-%s-%s",
                db->instance, db->url ? db->url : db->sock);
 
+    user_data_t ud = {
+      .data = db,
+      .free_func = cj_free
+    };
+
     plugin_register_complex_read (/* group = */ NULL, cb_name, cj_read,
                                   /* interval = */ db->interval,
                                   &ud);
index 1d9ecc0..c8a1313 100644 (file)
@@ -1016,7 +1016,6 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
   /* If all went well, register this database for reading */
   if (status == 0)
   {
-    user_data_t ud = { 0 };
     char *cb_name;
 
     if (db->instance == NULL)
@@ -1025,10 +1024,13 @@ static int cx_config_add_url (oconfig_item_t *ci) /* {{{ */
     DEBUG ("curl_xml plugin: Registering new read callback: %s",
            db->instance);
 
-    ud.data = (void *) db;
-    ud.free_func = cx_free;
-
     cb_name = ssnprintf_alloc ("curl_xml-%s-%s", db->instance, db->url);
+
+    user_data_t ud = {
+      .data = db,
+      .free_func = cx_free
+    };
+
     plugin_register_complex_read (/* group = */ "curl_xml", cb_name, cx_read,
                                   /* interval = */ 0, &ud);
     sfree (cb_name);
index ae2c6c0..a13bc09 100644 (file)
@@ -93,7 +93,6 @@ int cf_read (const char *filename);
 int global_option_set (const char *option, const char *value, _Bool from_cli);
 const char *global_option_get (const char *option);
 long global_option_get_long (const char *option, long default_value);
-long global_option_get_long_in_range (const char *option, long default_value, long min, long max);
 
 cdtime_t global_option_get_time (char const *option, cdtime_t default_value);
 
index 783ea2b..068bf4d 100644 (file)
--- a/src/dbi.c
+++ b/src/dbi.c
@@ -390,17 +390,18 @@ static int cdbi_config_add_database (oconfig_item_t *ci) /* {{{ */
     }
     else
     {
-      user_data_t ud = { 0 };
       char *name = NULL;
 
       databases = temp;
       databases[databases_num] = db;
       databases_num++;
 
-      ud.data = (void *) db;
-      ud.free_func = NULL;
       name = ssnprintf_alloc("dbi:%s", db->name);
 
+      user_data_t ud = {
+        .data = db
+      };
+
       plugin_register_complex_read (/* group = */ NULL,
           /* name = */ name ? name : db->name,
           /* callback = */ cdbi_read_database,
index 47f4cd3..67740ac 100644 (file)
@@ -1417,7 +1417,6 @@ static jint JNICALL cjni_api_register_init (JNIEnv *jvm_env, /* {{{ */
 static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject o_name, jobject o_read)
 {
-  user_data_t ud = { 0 };
   cjni_callback_info_t *cbi;
 
   cbi = cjni_callback_info_create (jvm_env, o_name, o_read, CB_TYPE_READ);
@@ -1426,8 +1425,10 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
 
   DEBUG ("java plugin: Registering new read callback: %s", cbi->name);
 
-  ud.data = (void *) cbi;
-  ud.free_func = cjni_callback_info_destroy;
+  user_data_t ud = {
+    .data = cbi,
+    .free_func = cjni_callback_info_destroy
+  };
 
   plugin_register_complex_read (/* group = */ NULL, cbi->name, cjni_read,
       /* interval = */ 0, &ud);
@@ -1440,7 +1441,6 @@ static jint JNICALL cjni_api_register_read (JNIEnv *jvm_env, /* {{{ */
 static jint JNICALL cjni_api_register_write (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject o_name, jobject o_write)
 {
-  user_data_t ud = { 0 };
   cjni_callback_info_t *cbi;
 
   cbi = cjni_callback_info_create (jvm_env, o_name, o_write, CB_TYPE_WRITE);
@@ -1449,8 +1449,10 @@ static jint JNICALL cjni_api_register_write (JNIEnv *jvm_env, /* {{{ */
 
   DEBUG ("java plugin: Registering new write callback: %s", cbi->name);
 
-  ud.data = (void *) cbi;
-  ud.free_func = cjni_callback_info_destroy;
+  user_data_t ud = {
+    .data = cbi,
+    .free_func = cjni_callback_info_destroy
+  };
 
   plugin_register_write (cbi->name, cjni_write, &ud);
 
@@ -1462,7 +1464,6 @@ static jint JNICALL cjni_api_register_write (JNIEnv *jvm_env, /* {{{ */
 static jint JNICALL cjni_api_register_flush (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject o_name, jobject o_flush)
 {
-  user_data_t ud = { 0 };
   cjni_callback_info_t *cbi;
 
   cbi = cjni_callback_info_create (jvm_env, o_name, o_flush, CB_TYPE_FLUSH);
@@ -1471,8 +1472,10 @@ static jint JNICALL cjni_api_register_flush (JNIEnv *jvm_env, /* {{{ */
 
   DEBUG ("java plugin: Registering new flush callback: %s", cbi->name);
 
-  ud.data = (void *) cbi;
-  ud.free_func = cjni_callback_info_destroy;
+  user_data_t ud = {
+    .data = cbi,
+    .free_func = cjni_callback_info_destroy
+  };
 
   plugin_register_flush (cbi->name, cjni_flush, &ud);
 
@@ -1491,7 +1494,6 @@ static jint JNICALL cjni_api_register_shutdown (JNIEnv *jvm_env, /* {{{ */
 static jint JNICALL cjni_api_register_log (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject o_name, jobject o_log)
 {
-  user_data_t ud = { 0 };
   cjni_callback_info_t *cbi;
 
   cbi = cjni_callback_info_create (jvm_env, o_name, o_log, CB_TYPE_LOG);
@@ -1500,8 +1502,10 @@ static jint JNICALL cjni_api_register_log (JNIEnv *jvm_env, /* {{{ */
 
   DEBUG ("java plugin: Registering new log callback: %s", cbi->name);
 
-  ud.data = (void *) cbi;
-  ud.free_func = cjni_callback_info_destroy;
+  user_data_t ud = {
+    .data = cbi,
+    .free_func = cjni_callback_info_destroy
+  };
 
   plugin_register_log (cbi->name, cjni_log, &ud);
 
@@ -1513,7 +1517,6 @@ static jint JNICALL cjni_api_register_log (JNIEnv *jvm_env, /* {{{ */
 static jint JNICALL cjni_api_register_notification (JNIEnv *jvm_env, /* {{{ */
     jobject this, jobject o_name, jobject o_notification)
 {
-  user_data_t ud = { 0 };
   cjni_callback_info_t *cbi;
 
   cbi = cjni_callback_info_create (jvm_env, o_name, o_notification,
@@ -1523,8 +1526,10 @@ static jint JNICALL cjni_api_register_notification (JNIEnv *jvm_env, /* {{{ */
 
   DEBUG ("java plugin: Registering new notification callback: %s", cbi->name);
 
-  ud.data = (void *) cbi;
-  ud.free_func = cjni_callback_info_destroy;
+  user_data_t ud = {
+    .data = cbi,
+    .free_func = cjni_callback_info_destroy
+  };
 
   plugin_register_notification (cbi->name, cjni_notification, &ud);
 
index 319aae8..d6f0744 100644 (file)
@@ -43,7 +43,7 @@ static void yyset_in  (FILE *fd)
   yyin = fd;
 } /* void yyset_in */
 
-oconfig_item_t *oconfig_parse_fh (FILE *fh)
+static oconfig_item_t *oconfig_parse_fh (FILE *fh)
 {
   int status;
   oconfig_item_t *ret;
index 840137c..24045de 100644 (file)
@@ -64,7 +64,6 @@ struct oconfig_item_s
 /*
  * Functions
  */
-oconfig_item_t *oconfig_parse_fh (FILE *fh);
 oconfig_item_t *oconfig_parse_file (const char *file);
 
 oconfig_item_t *oconfig_clone (const oconfig_item_t *ci);
index c552360..9e6e725 100644 (file)
@@ -548,16 +548,17 @@ static int memcached_read (user_data_t *user_data)
 
 static int memcached_add_read_callback (memcached_t *st)
 {
-  user_data_t ud = { 0 };
   char callback_name[3*DATA_MAX_NAME_LEN];
   int status;
 
-  ud.data = st;
-  ud.free_func = memcached_free;
-
   assert (st->name != NULL);
   ssnprintf (callback_name, sizeof (callback_name), "memcached/%s", st->name);
 
+  user_data_t ud = {
+    .data = st,
+    .free_func = memcached_free
+  };
+
   status = plugin_register_complex_read (/* group = */ "memcached",
       /* name      = */ callback_name,
       /* callback  = */ memcached_read,
index a7a0b86..ad88995 100644 (file)
@@ -548,7 +548,6 @@ static int mqtt_config_publisher (oconfig_item_t *ci)
 {
     mqtt_client_conf_t *conf;
     char cb_name[1024];
-    user_data_t user_data = { 0 };
     int status;
 
     conf = calloc (1, sizeof (*conf));
@@ -632,7 +631,9 @@ static int mqtt_config_publisher (oconfig_item_t *ci)
     }
 
     ssnprintf (cb_name, sizeof (cb_name), "mqtt/%s", conf->name);
-    user_data.data = conf;
+    user_data_t user_data = {
+        .data = conf
+    };
 
     plugin_register_write (cb_name, mqtt_write, &user_data);
     return (0);
index eea3df8..32b72e2 100644 (file)
@@ -222,21 +222,22 @@ static int mysql_config_database (oconfig_item_t *ci) /* {{{ */
        /* If all went well, register this database for reading */
        if (status == 0)
        {
-               user_data_t ud = { 0 };
                char cb_name[DATA_MAX_NAME_LEN];
 
                DEBUG ("mysql plugin: Registering new read callback: %s",
                                (db->database != NULL) ? db->database : "<default>");
 
-               ud.data = (void *) db;
-               ud.free_func = mysql_database_free;
-
                if (db->instance != NULL)
                        ssnprintf (cb_name, sizeof (cb_name), "mysql-%s",
                                        db->instance);
                else
                        sstrncpy (cb_name, "mysql", sizeof (cb_name));
 
+               user_data_t ud = {
+                       .data = db,
+                       .free_func = mysql_database_free
+               };
+
                plugin_register_complex_read (/* group = */ NULL, cb_name,
                                              mysql_read,
                                              /* interval = */ 0, &ud);
index 26577da..d739696 100644 (file)
@@ -2872,7 +2872,6 @@ static int cna_read (user_data_t *ud);
 static int cna_register_host (host_config_t *host) /* {{{ */
 {
        char cb_name[256];
-       user_data_t ud = { 0 };
 
        if (host->vfiler)
                ssnprintf (cb_name, sizeof (cb_name), "netapp-%s-%s",
@@ -2880,8 +2879,10 @@ static int cna_register_host (host_config_t *host) /* {{{ */
        else
                ssnprintf (cb_name, sizeof (cb_name), "netapp-%s", host->name);
 
-       ud.data = host;
-       ud.free_func = (void (*) (void *)) free_host_config;
+       user_data_t ud = {
+               .data = host,
+               .free_func = (void (*) (void *)) free_host_config
+       };
 
        plugin_register_complex_read (/* group = */ NULL, cb_name,
                        /* callback  = */ cna_read,
index 1353536..d424cb4 100644 (file)
@@ -652,19 +652,20 @@ static int cldap_config_add (oconfig_item_t *ci) /* {{{ */
                }
                else
                {
-                       user_data_t ud = { 0 };
                        char callback_name[3*DATA_MAX_NAME_LEN] = { 0 };
 
                        databases = temp;
                        databases[databases_num] = st;
                        databases_num++;
 
-                       ud.data = st;
-
                        ssnprintf (callback_name, sizeof (callback_name),
                                        "openldap/%s/%s",
                                        (st->host != NULL) ? st->host : hostname_g,
-                                       (st->name != NULL) ? st->name : "default"),
+                                       (st->name != NULL) ? st->name : "default");
+
+                       user_data_t ud = {
+                               .data = st
+                       };
 
                        status = plugin_register_complex_read (/* group = */ NULL,
                                        /* name      = */ callback_name,
index c4e19db..084eae4 100644 (file)
@@ -1176,8 +1176,6 @@ static int c_psql_config_database (oconfig_item_t *ci)
        c_psql_database_t *db;
 
        char cb_name[DATA_MAX_NAME_LEN];
-       user_data_t ud = { 0 };
-
        static _Bool have_flush = 0;
 
        if ((1 != ci->values_num)
@@ -1260,11 +1258,13 @@ static int c_psql_config_database (oconfig_item_t *ci)
                }
        }
 
-       ud.data = db;
-       ud.free_func = c_psql_database_delete;
-
        ssnprintf (cb_name, sizeof (cb_name), "postgresql-%s", db->instance);
 
+       user_data_t ud = {
+               .data = db,
+               .free_func = c_psql_database_delete
+       };
+
        if (db->queries_num > 0) {
                ++db->ref_cnt;
                plugin_register_complex_read ("postgresql", cb_name, c_psql_read,
index 24046de..884bb05 100644 (file)
@@ -624,7 +624,6 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
        char buf[512];
        reg_function_t *register_function = (reg_function_t *) reg;
        cpy_callback_t *c = NULL;
-       user_data_t user_data = { 0 };
        char *name = NULL;
        PyObject *callback = NULL, *data = NULL;
        static char *kwlist[] = {"callback", "data", "name", NULL};
@@ -650,8 +649,10 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
        c->data = data;
        c->next = NULL;
 
-       user_data.free_func = cpy_destroy_user_data;
-       user_data.data = c;
+       user_data_t user_data = {
+               .data = c,
+               .free_func = cpy_destroy_user_data
+       };
 
        register_function(buf, handler, &user_data);
        return cpy_string_to_unicode_or_bytes(buf);
@@ -660,7 +661,6 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler, PyObjec
 static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwds) {
        char buf[512];
        cpy_callback_t *c = NULL;
-       user_data_t user_data = { 0 };
        double interval = 0;
        char *name = NULL;
        PyObject *callback = NULL, *data = NULL;
@@ -687,8 +687,10 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args, PyObject *kwd
        c->data = data;
        c->next = NULL;
 
-       user_data.free_func = cpy_destroy_user_data;
-       user_data.data = c;
+       user_data_t user_data = {
+               .data = c,
+               .free_func = cpy_destroy_user_data
+       };
 
        plugin_register_complex_read(/* group = */ "python", buf,
                        cpy_read_callback, DOUBLE_TO_CDTIME_T (interval), &user_data);
index e0e1973..abeda43 100644 (file)
@@ -634,7 +634,6 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
 
   /* Registration stuff. */
   char cb_name[DATA_MAX_NAME_LEN];
-  user_data_t cb_data = { 0 };
 
   hd = calloc (1, sizeof (*hd));
   if (hd == NULL)
@@ -765,11 +764,13 @@ static int csnmp_config_add_host (oconfig_item_t *ci)
 
   ssnprintf (cb_name, sizeof (cb_name), "snmp-%s", hd->name);
 
-  cb_data.data = hd;
-  cb_data.free_func = csnmp_host_definition_destroy;
+  user_data_t ud = {
+    .data = hd,
+    .free_func = csnmp_host_definition_destroy
+  };
 
   status = plugin_register_complex_read (/* group = */ NULL, cb_name,
-      csnmp_read_host, hd->interval, /* user_data = */ &cb_data);
+      csnmp_read_host, hd->interval, /* user_data = */ &ud);
   if (status != 0)
   {
     ERROR ("snmp plugin: Registering complex read function failed.");
index b8922ec..e8cde1e 100644 (file)
@@ -328,7 +328,6 @@ static int ctail_read (user_data_t *ud)
 static int ctail_init (void)
 {
   char str[255];
-  user_data_t ud = { 0 };
 
   if (tail_match_list_num == 0)
   {
@@ -338,8 +337,12 @@ static int ctail_init (void)
 
   for (size_t i = 0; i < tail_match_list_num; i++)
   {
-    ud.data = (void *)tail_match_list[i];
     ssnprintf(str, sizeof(str), "tail-%zu", i);
+
+    user_data_t ud = {
+     .data = tail_match_list[i]
+    };
+
     plugin_register_complex_read (NULL, str, ctail_read, tail_match_list_intervals[i], &ud);
   }
 
index 79ea466..1bdf8b2 100644 (file)
@@ -421,7 +421,6 @@ static int tcsv_config_add_file(oconfig_item_t *ci)
 
     /* Registration variables */
     char cb_name[DATA_MAX_NAME_LEN];
-    user_data_t cb_data = { 0 };
 
     id = calloc(1, sizeof(*id));
     if (id == NULL)
@@ -482,9 +481,13 @@ static int tcsv_config_add_file(oconfig_item_t *ci)
     }
 
     ssnprintf (cb_name, sizeof (cb_name), "tail_csv/%s", id->path);
-    cb_data.data = id;
-    cb_data.free_func = tcsv_instance_definition_destroy;
-    status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &cb_data);
+
+    user_data_t ud = {
+        .data = id,
+        .free_func = tcsv_instance_definition_destroy
+    };
+
+    status = plugin_register_complex_read(NULL, cb_name, tcsv_read, id->interval, &ud);
 
     if (status != 0){
         ERROR("tail_csv plugin: Registering complex read function failed.");
index e65b2a3..6cc092c 100644 (file)
@@ -938,7 +938,6 @@ static int varnish_config_apply_default (user_config_t *conf) /* {{{ */
 static int varnish_init (void) /* {{{ */
 {
        user_config_t *conf;
-       user_data_t ud;
 
        if (have_instance)
                return (0);
@@ -952,8 +951,10 @@ static int varnish_init (void) /* {{{ */
 
        varnish_config_apply_default (conf);
 
-       ud.data = conf;
-       ud.free_func = varnish_config_free;
+       user_data_t ud = {
+               .data = conf,
+               .free_func = varnish_config_free
+       };
 
        plugin_register_complex_read (/* group = */ "varnish",
                        /* name      = */ "varnish/localhost",
index 8f38e06..fe2376a 100644 (file)
@@ -474,7 +474,6 @@ static int config_set_char (char *dest,
 static int wg_config_node (oconfig_item_t *ci)
 {
     struct wg_callback *cb;
-    user_data_t user_data = { 0 };
     char callback_name[DATA_MAX_NAME_LEN];
     int status = 0;
 
@@ -576,12 +575,15 @@ static int wg_config_node (oconfig_item_t *ci)
         ssnprintf (callback_name, sizeof (callback_name), "write_graphite/%s",
                 cb->name);
 
-    user_data.data = cb;
-    user_data.free_func = wg_callback_free;
-    plugin_register_write (callback_name, wg_write, &user_data);
+    user_data_t ud = {
+        .data = cb,
+        .free_func = wg_callback_free
+    };
+
+    plugin_register_write (callback_name, wg_write, &ud);
 
-    user_data.free_func = NULL;
-    plugin_register_flush (callback_name, wg_flush, &user_data);
+    ud.free_func = NULL;
+    plugin_register_flush (callback_name, wg_flush, &ud);
 
     return (0);
 }
index d8d8c34..95132cf 100644 (file)
@@ -649,7 +649,6 @@ static int wh_config_node (oconfig_item_t *ci) /* {{{ */
 {
         wh_callback_t *cb;
         int buffer_size = 0;
-        user_data_t user_data = { 0 };
         char callback_name[DATA_MAX_NAME_LEN];
         int status = 0;
 
@@ -813,7 +812,10 @@ static int wh_config_node (oconfig_item_t *ci) /* {{{ */
         DEBUG ("write_http: Registering write callback '%s' with URL '%s'",
                         callback_name, cb->location);
 
-        user_data.data = cb;
+        user_data_t user_data = {
+                .data = cb
+        };
+
         plugin_register_flush (callback_name, wh_flush, &user_data);
 
         user_data.free_func = wh_callback_free;
index 81ca128..9fda2df 100644 (file)
@@ -245,7 +245,6 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{
     char                        *val;
     char                         callback_name[DATA_MAX_NAME_LEN];
     char                         errbuf[1024];
-    user_data_t                  ud;
     oconfig_item_t              *child;
     rd_kafka_conf_res_t          ret;
 
@@ -384,8 +383,10 @@ static void kafka_config_topic(rd_kafka_conf_t *conf, oconfig_item_t *ci) /* {{{
     ssnprintf(callback_name, sizeof(callback_name),
               "write_kafka/%s", tctx->topic_name);
 
-    ud.data = tctx;
-    ud.free_func = kafka_topic_context_free;
+    user_data_t ud = {
+        .data = tctx,
+        .free_func = kafka_topic_context_free
+    };
 
     status = plugin_register_write (callback_name, kafka_write, &ud);
     if (status != 0) {
index 7260615..b0dc6f1 100644 (file)
@@ -59,7 +59,7 @@ static int wl_write_messages (const data_set_t *ds, const value_list_t *vl)
 } /* int wl_write_messages */
 
 static int wl_write (const data_set_t *ds, const value_list_t *vl,
-        user_data_t *user_data)
+        __attribute__ ((unused)) user_data_t *user_data)
 {
     int status;
 
index 01ce64a..6d5f379 100644 (file)
@@ -336,12 +336,13 @@ static int wm_config_node (oconfig_item_t *ci) /* {{{ */
   if (status == 0)
   {
     char cb_name[DATA_MAX_NAME_LEN];
-    user_data_t ud;
 
     ssnprintf (cb_name, sizeof (cb_name), "write_mongodb/%s", node->name);
 
-    ud.data = node;
-    ud.free_func = wm_config_free;
+    user_data_t ud = {
+      .data = node,
+      .free_func = wm_config_free
+    };
 
     status = plugin_register_write (cb_name, wm_write, &ud);
     INFO ("write_mongodb plugin: registered write plugin %s %d",cb_name,status);
index 973b180..4722416 100644 (file)
@@ -231,12 +231,13 @@ static int wr_config_node (oconfig_item_t *ci) /* {{{ */
   if (status == 0)
   {
     char cb_name[DATA_MAX_NAME_LEN];
-    user_data_t ud;
 
     ssnprintf (cb_name, sizeof (cb_name), "write_redis/%s", node->name);
 
-    ud.data = node;
-    ud.free_func = wr_config_free;
+    user_data_t ud = {
+      .data = node,
+      .free_func = wr_config_free
+    };
 
     status = plugin_register_write (cb_name, wr_write, &ud);
   }
index 0ed0260..043a06b 100644 (file)
@@ -611,7 +611,6 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */
   int i;
   oconfig_item_t *child;
   char callback_name[DATA_MAX_NAME_LEN];
-  user_data_t ud;
 
   if ((host = calloc(1, sizeof(*host))) == NULL) {
     ERROR("write_riemann plugin: calloc failed.");
@@ -789,8 +788,11 @@ static int wrr_config_node(oconfig_item_t *ci) /* {{{ */
 
   ssnprintf(callback_name, sizeof(callback_name), "write_riemann/%s",
             host->name);
-  ud.data = host;
-  ud.free_func = wrr_free;
+
+  user_data_t ud = {
+    .data = host,
+    .free_func = wrr_free
+  };
 
   pthread_mutex_lock(&host->lock);
 
index 2f1f35a..d764d26 100644 (file)
@@ -978,7 +978,6 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */
        int                                     status = 0;
        oconfig_item_t          *child;
        char                            callback_name[DATA_MAX_NAME_LEN];
-       user_data_t                     ud;
 
        if ((host = calloc(1, sizeof(*host))) == NULL) {
                ERROR("write_sensu plugin: calloc failed.");
@@ -1108,8 +1107,11 @@ static int sensu_config_node(oconfig_item_t *ci) /* {{{ */
        }
 
        ssnprintf(callback_name, sizeof(callback_name), "write_sensu/%s", host->name);
-       ud.data = host;
-       ud.free_func = sensu_free;
+
+       user_data_t ud = {
+               .data = host,
+               .free_func = sensu_free
+       };
 
        pthread_mutex_lock(&host->lock);
 
index c183d27..b670f3a 100644 (file)
@@ -570,7 +570,6 @@ static int wt_write(const data_set_t *ds, const value_list_t *vl,
 static int wt_config_tsd(oconfig_item_t *ci)
 {
     struct wt_callback *cb;
-    user_data_t user_data = { 0 };
     char callback_name[DATA_MAX_NAME_LEN];
 
     cb = calloc(1, sizeof(*cb));
@@ -612,8 +611,11 @@ static int wt_config_tsd(oconfig_item_t *ci)
               cb->node != NULL ? cb->node : WT_DEFAULT_NODE,
               cb->service != NULL ? cb->service : WT_DEFAULT_SERVICE);
 
-    user_data.data = cb;
-    user_data.free_func = wt_callback_free;
+    user_data_t user_data = {
+        .data = cb,
+        .free_func = wt_callback_free
+    };
+
     plugin_register_write(callback_name, wt_write, &user_data);
 
     user_data.free_func = NULL;