From 9e2c04a0c5b1b0f4bd2269c29c27fe1f3b1115de Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Fri, 2 Sep 2016 10:41:06 +0200 Subject: [PATCH] ceph plugin: Use compound literals to initialize a VLA. This also moves the DEBUG() statement before the sanity check in an attempt to make scan-build happy: scan-build is under the impression that the DEBUG() macro would write to the g_num_daemons global variable. While we're at it, use PRIu32 to print the uint32_t. Issue: #1835 --- src/ceph.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/ceph.c b/src/ceph.c index ad0688cc..64d87855 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -1468,21 +1468,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 = %"PRIu32")", request_type); + 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 */ - memset(io_array, 0, sizeof(io_array)); - for(size_t i = 0; i < g_num_daemons; ++i) + 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; + 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 */ -- 2.30.2