From 9a187189a13a58081da76bf46457f9ffcd6808c3 Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Tue, 19 Sep 2017 08:16:42 +0200 Subject: [PATCH] uptime plugin: Coding style update. This is only touching the Linux code, though. --- src/uptime.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) 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!"); -- 2.11.0