From: Florian Forster Date: Tue, 19 Sep 2017 06:16:42 +0000 (+0200) Subject: uptime plugin: Coding style update. X-Git-Tag: collectd-5.8.0~97^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9a187189a13a58081da76bf46457f9ffcd6808c3;p=collectd.git uptime plugin: Coding style update. This is only touching the Linux code, though. --- diff --git a/src/uptime.c b/src/uptime.c index ed0dfd10..8b83cf9b 100644 --- a/src/uptime.c +++ b/src/uptime.c @@ -86,14 +86,7 @@ static int uptime_init(void) /* {{{ */ */ #if KERNEL_LINUX - double uptime_seconds; - int ret; - FILE *fh; - - ret = 0; - - fh = fopen(UPTIME_FILE, "r"); - + FILE *fh = fopen(UPTIME_FILE, "r"); if (fh == NULL) { char errbuf[1024]; ERROR("uptime plugin: Cannot open " UPTIME_FILE ": %s", @@ -101,16 +94,15 @@ static int uptime_init(void) /* {{{ */ return -1; } - ret = fscanf(fh, "%lf", &uptime_seconds); - - fclose(fh); - - /* loop done, check if no value has been found/read */ - if (ret != 1) { + double uptime_seconds = 0.0; + if (fscanf(fh, "%lf", &uptime_seconds) != 1) { ERROR("uptime plugin: No value read from " UPTIME_FILE ""); + fclose(fh); return -1; } + fclose(fh); + if (uptime_seconds == 0.0) { ERROR("uptime plugin: uptime read from " UPTIME_FILE ", " "but it is zero!");