From 2e3de288a69e5556f2fe2d095da67c64cf7c9ec3 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Mon, 30 Jan 2017 17:13:52 +0100 Subject: rsmemsiz: Fix warning and add error check to getuptime call. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit rsmemsiz.c: In function ‘main’: rsmemsiz.c:139:11: warning: ‘uptime_secs’ may be used uninitialized in this function [-Wmaybe-uninitialized] updays = (int) uptime_secs / (60*60*24); ^~~~~~~~~~~~~~~~~ Signed-off-by: Ralf Baechle --- rose/rsmemsiz.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'rose') diff --git a/rose/rsmemsiz.c b/rose/rsmemsiz.c index 882912a..9187d3b 100644 --- a/rose/rsmemsiz.c +++ b/rose/rsmemsiz.c @@ -135,7 +135,11 @@ int main(int argc, char **argv) } /* read and calculate the amount of uptime and format it nicely */ - getuptime(&uptime_secs); + if (getuptime(&uptime_secs) < 0) { + fprintf(stdout, "Cannot get system uptime\r"); + uptime_secs = 0; + } + updays = (int) uptime_secs / (60*60*24); upminutes = (int) uptime_secs / 60; uphours = upminutes / 60; -- cgit v1.2.3