X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fcollectdctl.c;h=8ca0559d0728eebf5dafabb57fb0c47e556e29aa;hb=f3610533206238bf4fcb72c76e9a07517d8bc64b;hp=d019d2742f3db6bef5d98f653ed144cdf4a42895;hpb=213eb227d7737bfbd899474033f94342c61dcb8c;p=collectd.git diff --git a/src/collectdctl.c b/src/collectdctl.c index d019d274..8ca0559d 100644 --- a/src/collectdctl.c +++ b/src/collectdctl.c @@ -72,6 +72,7 @@ extern char *optarg; extern int optind; +__attribute__((noreturn)) static void exit_usage (const char *name, int status) { fprintf ((status == 0) ? stdout : stderr, "Usage: %s [options] [cmd options]\n\n" @@ -120,7 +121,7 @@ static int count_chars (const char *str, char chr) { return count; } /* count_chars */ -static int array_grow (void **array, int *array_len, size_t elem_size) +static int array_grow (void **array, size_t *array_len, size_t elem_size) { void *tmp; @@ -193,7 +194,6 @@ static int getval (lcc_connection_t *c, int argc, char **argv) return (-1); } - memset (&ident, 0, sizeof (ident)); status = parse_identifier (c, argv[1], &ident); if (status != 0) return (status); @@ -229,10 +229,10 @@ static int flush (lcc_connection_t *c, int argc, char **argv) int timeout = -1; lcc_identifier_t *identifiers = NULL; - int identifiers_num = 0; + size_t identifiers_num = 0; char **plugins = NULL; - int plugins_num = 0; + size_t plugins_num = 0; int status; int i; @@ -482,7 +482,7 @@ static int putval (lcc_connection_t *c, int argc, char **argv) values_len = 0; value = tmp; - while (value != 0) { + while (value != NULL) { char *dot, *endptr; tmp = strchr (value, (int)':'); @@ -507,7 +507,7 @@ static int putval (lcc_connection_t *c, int argc, char **argv) values_types[values_len] = LCC_TYPE_GAUGE; } else { /* integer */ - values[values_len].counter = strtol (value, &endptr, 0); + values[values_len].counter = (counter_t) strtoull (value, &endptr, 0); values_types[values_len] = LCC_TYPE_COUNTER; } ++values_len; @@ -551,21 +551,20 @@ int main (int argc, char **argv) { int status; while (42) { - int n; + int opt; - n = getopt (argc, argv, "s:h"); + opt = getopt (argc, argv, "s:h"); - if (n == -1) + if (opt == -1) break; - switch (n) { + switch (opt) { case 's': snprintf (address, sizeof (address), "unix:%s", optarg); address[sizeof (address) - 1] = '\0'; break; case 'h': exit_usage (argv[0], 0); - break; default: exit_usage (argv[0], 1); }