summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2017-01-30 17:13:52 +0100
committerRalf Baechle <ralf@linux-mips.org>2017-02-06 23:43:46 +0100
commit2e3de288a69e5556f2fe2d095da67c64cf7c9ec3 (patch)
treec4a86676d13fabd3278434798a66b2a21a5387c4
parent6f3c1ec5b5e202d45bff3a3dd8206dd89c129555 (diff)
rsmemsiz: Fix warning and add error check to getuptime call.
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 <ralf@linux-mips.org>
-rw-r--r--rose/rsmemsiz.c6
1 files changed, 5 insertions, 1 deletions
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;