Code

write_http plugin: Add assertion for scan-build.
[collectd.git] / src / ceph.c
index 458112ae0eb91c4018e9139c8f104f83ed14e6b4..ad0688ccb22245a6131e135c3f09dddca5a93a74 100644 (file)
@@ -297,6 +297,11 @@ ceph_cb_number(void *ctx, const char *number_val, yajl_len_t number_len)
     {
         latency_type = 1;
 
+        /* depth >= 2  =>  (stack[-1] != NULL && stack[-2] != NULL) */
+        assert ((state->depth < 2)
+                || ((state->stack[state->depth - 1] != NULL)
+                    && (state->stack[state->depth - 2] != NULL)));
+
         /* Super-special case for filestore.journal_wr_bytes.avgcount: For
          * some reason, Ceph schema encodes this as a count/sum pair while all
          * other "Bytes" data (excluding used/capacity bytes for OSD space) uses
@@ -1463,6 +1468,12 @@ static int cconn_main_loop(uint32_t request_type)
     struct timeval end_tv;
     struct cconn io_array[g_num_daemons];
 
+    if (g_num_daemons < 1)
+    {
+        ERROR ("ceph plugin: No daemons configured. See the \"Daemon\" config option.");
+        return ENOENT;
+    }
+
     DEBUG("ceph plugin: entering cconn_main_loop(request_type = %d)", request_type);
 
     /* create cconn array */