Merge branch 'collectd-5.7'
[collectd.git] / src / ceph.c
index 2be17fb..c2284cb 100644 (file)
@@ -634,7 +634,7 @@ static int cc_add_daemon_config(oconfig_item_t *ci) {
   if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) {
     WARNING("ceph plugin: `Daemon' blocks need exactly one string "
             "argument.");
-    return (-1);
+    return -1;
   }
 
   ret = cc_handle_str(ci, cd.name, DATA_MAX_NAME_LEN);
@@ -1027,7 +1027,6 @@ static int cconn_process_data(struct cconn *io, yajl_struct *yajl,
   }
 
   vtmp->vlist = (value_list_t)VALUE_LIST_INIT;
-  sstrncpy(vtmp->vlist.host, hostname_g, sizeof(vtmp->vlist.host));
   sstrncpy(vtmp->vlist.plugin, "ceph", sizeof(vtmp->vlist.plugin));
   sstrncpy(vtmp->vlist.plugin_instance, io->d->name,
            sizeof(vtmp->vlist.plugin_instance));
@@ -1301,15 +1300,22 @@ static int cconn_main_loop(uint32_t request_type) {
   struct timeval end_tv;
   struct cconn io_array[g_num_daemons];
 
-  DEBUG("ceph plugin: entering cconn_main_loop(request_type = %d)",
+  DEBUG("ceph plugin: entering cconn_main_loop(request_type = %" PRIu32 ")",
         request_type);
 
+  if (g_num_daemons < 1) {
+    ERROR("ceph plugin: No daemons configured. See the \"Daemon\" config "
+          "option.");
+    return ENOENT;
+  }
+
   /* create cconn array */
-  memset(io_array, 0, sizeof(io_array));
-  for (size_t i = 0; i < g_num_daemons; ++i) {
-    io_array[i].d = g_daemons[i];
-    io_array[i].request_type = request_type;
-    io_array[i].state = CSTATE_UNCONNECTED;
+  for (size_t i = 0; i < g_num_daemons; i++) {
+    io_array[i] = (struct cconn){
+        .d = g_daemons[i],
+        .request_type = request_type,
+        .state = CSTATE_UNCONNECTED,
+    };
   }
 
   /** Calculate the time at which we should give up */
@@ -1440,4 +1446,3 @@ void module_register(void) {
   plugin_register_read("ceph", ceph_read);
   plugin_register_shutdown("ceph", ceph_shutdown);
 }
-/* vim: set sw=4 sts=4 et : */