summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2e80174)
raw | patch | inline | side by side (parent: 2e80174)
author | Florian Forster <octo@collectd.org> | |
Sun, 14 Aug 2016 19:02:31 +0000 (21:02 +0200) | ||
committer | Florian Forster <octo@collectd.org> | |
Sun, 14 Aug 2016 19:02:34 +0000 (21:02 +0200) |
The variable is used as size for variable length arrays (VLAs), which
cannot have negative size.
Issue: #1835
cannot have negative size.
Issue: #1835
src/ceph.c | patch | blob | history |
diff --git a/src/ceph.c b/src/ceph.c
index b186a276335d1b7e8867a1b170ff864845f4a83e..55cd64c6937c9a10eaf6dfdbed9e59d8e8989f27 100644 (file)
--- a/src/ceph.c
+++ b/src/ceph.c
static struct ceph_daemon **g_daemons = NULL;
/** Number of elements in g_daemons */
-static int g_num_daemons = 0;
+static size_t g_num_daemons = 0;
/**
* A set of data that we build up in memory while parsing the JSON.
static void ceph_daemons_print(void)
{
- for(int i = 0; i < g_num_daemons; ++i)
+ for(size_t i = 0; i < g_num_daemons; ++i)
{
ceph_daemon_print(g_daemons[i]);
}
return ENOMEM;
}
memcpy(nd, &cd, sizeof(*nd));
- g_daemons[g_num_daemons++] = nd;
+ g_daemons[g_num_daemons] = nd;
+ g_num_daemons++;
return 0;
}
/* create cconn array */
memset(io_array, 0, sizeof(io_array));
- for(int 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;
struct pollfd fds[g_num_daemons];
memset(fds, 0, sizeof(fds));
nfds = 0;
- for(int i = 0; i < g_num_daemons; ++i)
+ for(size_t i = 0; i < g_num_daemons; ++i)
{
struct cconn *io = io_array + i;
ret = cconn_prepare(io, fds + nfds);
if(ret < 0)
{
- WARNING("ceph plugin: cconn_prepare(name=%s,i=%d,st=%d)=%d",
+ WARNING("ceph plugin: cconn_prepare(name=%s,i=%zu,st=%d)=%d",
io->d->name, i, io->state, ret);
cconn_close(io);
io->request_type = ASOK_REQ_NONE;
}
}
}
- done: for(int i = 0; i < g_num_daemons; ++i)
+ done: for(size_t i = 0; i < g_num_daemons; ++i)
{
cconn_close(io_array + i);
}
static int ceph_shutdown(void)
{
- for(int i = 0; i < g_num_daemons; ++i)
+ for(size_t i = 0; i < g_num_daemons; ++i)
{
ceph_daemon_free(g_daemons[i]);
}