Merge remote-tracking branch 'github/pr/2190'
[collectd.git] / src / python.c
index 9c25823..b106e45 100644 (file)
@@ -718,9 +718,11 @@ static PyObject *cpy_register_generic_userdata(void *reg, void *handler,
   c->data = data;
   c->next = NULL;
 
-  user_data_t user_data = {.data = c, .free_func = cpy_destroy_user_data};
+  register_function(buf, handler,
+                    &(user_data_t){
+                        .data = c, .free_func = cpy_destroy_user_data,
+                    });
 
-  register_function(buf, handler, &user_data);
   ++cpy_num_callbacks;
   return cpy_string_to_unicode_or_bytes(buf);
 }
@@ -757,10 +759,12 @@ static PyObject *cpy_register_read(PyObject *self, PyObject *args,
   c->data = data;
   c->next = NULL;
 
-  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);
+  plugin_register_complex_read(
+      /* group = */ "python", buf, cpy_read_callback,
+      DOUBLE_TO_CDTIME_T(interval),
+      &(user_data_t){
+          .data = c, .free_func = cpy_destroy_user_data,
+      });
   ++cpy_num_callbacks;
   return cpy_string_to_unicode_or_bytes(buf);
 }
@@ -780,8 +784,8 @@ static PyObject *cpy_register_write(PyObject *self, PyObject *args,
 static PyObject *cpy_register_notification(PyObject *self, PyObject *args,
                                            PyObject *kwds) {
   return cpy_register_generic_userdata((void *)plugin_register_notification,
-                                       (void *)cpy_notification_callback, args,
-                                       kwds);
+                                       (void *)cpy_notification_callback,
+                                       args, kwds);
 }
 
 static PyObject *cpy_register_flush(PyObject *self, PyObject *args,
@@ -940,7 +944,8 @@ static PyObject *cpy_unregister_read(PyObject *self, PyObject *arg) {
 }
 
 static PyObject *cpy_unregister_write(PyObject *self, PyObject *arg) {
-  return cpy_unregister_generic_userdata(plugin_unregister_write, arg, "write");
+  return cpy_unregister_generic_userdata(plugin_unregister_write, arg,
+                                         "write");
 }
 
 static PyObject *cpy_unregister_notification(PyObject *self, PyObject *arg) {
@@ -949,7 +954,8 @@ static PyObject *cpy_unregister_notification(PyObject *self, PyObject *arg) {
 }
 
 static PyObject *cpy_unregister_flush(PyObject *self, PyObject *arg) {
-  return cpy_unregister_generic_userdata(plugin_unregister_flush, arg, "flush");
+  return cpy_unregister_generic_userdata(plugin_unregister_flush, arg,
+                                         "flush");
 }
 
 static PyObject *cpy_unregister_shutdown(PyObject *self, PyObject *arg) {
@@ -1094,7 +1100,8 @@ static int cpy_init(void) {
       ERROR("python: Unable to create pipe.");
       return 1;
     }
-    if (plugin_thread_create(&thread, NULL, cpy_interactive, pipefd + 1)) {
+    if (plugin_thread_create(&thread, NULL, cpy_interactive, pipefd + 1,
+                             "python interpreter")) {
       ERROR("python: Error creating thread for interactive interpreter.");
     }
     if (read(pipefd[0], &buf, 1))
@@ -1392,7 +1399,7 @@ static int cpy_config(oconfig_item_t *ci) {
       status = 1;
     }
   }
-  return (status);
+  return status;
 }
 
 void module_register(void) {