treewide: use designated initializers for user_data
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 13 Aug 2016 13:55:39 +0000 (15:55 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Sat, 13 Aug 2016 13:55:39 +0000 (15:55 +0200)
23 files changed:
src/curl_json.c
src/curl_xml.c
src/dbi.c
src/java.c
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_mongodb.c
src/write_redis.c
src/write_riemann.c
src/write_sensu.c
src/write_tsdb.c

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 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 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 a1fa509..d424cb4 100644 (file)
@@ -652,20 +652,21 @@ 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");
 
+                       user_data_t ud = {
+                               .data = st
+                       };
+
                        status = plugin_register_complex_read (/* group = */ NULL,
                                        /* name      = */ callback_name,
                                        /* callback  = */ cldap_read_host,
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 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;