X-Git-Url: https://git.octo.it/?p=rrdtool.git;a=blobdiff_plain;f=src%2Frrd_flushcached.c;h=93b0fb57b05f32d356d2afd6145974fd88b8dbdd;hp=fb9345b4ea8ee1382257c9ce567a2fe71840b121;hb=e8dc709cbb05fd0e69ca0607acbc10fa13e5fe4a;hpb=cd6581d4edf9cd9c73f023eb9b1f5529959bf816 diff --git a/src/rrd_flushcached.c b/src/rrd_flushcached.c index fb9345b..93b0fb5 100644 --- a/src/rrd_flushcached.c +++ b/src/rrd_flushcached.c @@ -74,8 +74,7 @@ int rrd_flushcached (int argc, char **argv) /* try to connect to rrdcached */ status = rrdc_connect(opt_daemon); - if (opt_daemon) free(opt_daemon); - if (status != 0) return status; + if (status != 0) goto out; if (! rrdc_is_connected(opt_daemon)) { @@ -83,11 +82,12 @@ int rrd_flushcached (int argc, char **argv) "option to set an address on the command line or set the " "\"%s\" environment variable.", ENV_RRDCACHED_ADDRESS); - return (-1); + status = -1; + goto out; } status = 0; - for (int i = optind; i < argc; i++) + for (i = optind; i < argc; i++) { status = rrdc_flush(argv[i]); if (status) @@ -107,7 +107,10 @@ int rrd_flushcached (int argc, char **argv) } } - return ((status == 0) ? 0 : -1); +out: + if (opt_daemon) free(opt_daemon); + + return status; } /* int rrd_flush */ /*