From: Florian Forster Date: Tue, 16 Aug 2016 05:09:45 +0000 (+0200) Subject: ceph plugin: Assert that the strings on the stack are non-NULL. X-Git-Tag: collectd-5.6.0~13 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=c9d019339f9ecc99c698bf186e53d5b72b951c27 ceph plugin: Assert that the strings on the stack are non-NULL. The static analyzer is whining about passing NULLs to strcmp(). --- diff --git a/src/ceph.c b/src/ceph.c index 458112ae..e6d3767b 100644 --- a/src/ceph.c +++ b/src/ceph.c @@ -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