From: Florian Forster Date: Tue, 16 Aug 2016 04:57:24 +0000 (+0200) Subject: ceph plugin: Guard against g_num_daemons being zero. X-Git-Tag: collectd-5.6.0~14 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f674a62840d14f4559a5bf828cf18e767ab77512;p=collectd.git ceph plugin: Guard against g_num_daemons being zero. clang scan-build flags this, because this variable is used to declare VLAs. --- diff --git a/src/ceph.c b/src/ceph.c index 5b792391..458112ae 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -1579,8 +1579,6 @@ static int ceph_read(void) /******* lifecycle *******/ static int ceph_init(void) { - int ret; - #if defined(HAVE_SYS_CAPABILITY_H) && defined(CAP_DAC_OVERRIDE) if (check_capability (CAP_DAC_OVERRIDE) != 0) { @@ -1598,9 +1596,13 @@ static int ceph_init(void) ceph_daemons_print(); - ret = cconn_main_loop(ASOK_REQ_VERSION); + if (g_num_daemons < 1) + { + ERROR ("ceph plugin: No daemons configured. See the \"Daemon\" config option."); + return ENOENT; + } - return (ret) ? ret : 0; + return cconn_main_loop(ASOK_REQ_VERSION); } static int ceph_shutdown(void)