[hackers] [slstatus] uptime: Improve typing and sort headers || Aaron Marcher
commit 16e15217c6cb56bd4125c54e645b932a50655b9d
Author: Aaron Marcher <me_AT_drkhsh.at>
AuthorDate: Fri Jul 6 23:47:52 2018 +0200
Commit: Aaron Marcher <me_AT_drkhsh.at>
CommitDate: Fri Jul 6 23:47:52 2018 +0200
uptime: Improve typing and sort headers
diff --git a/components/uptime.c b/components/uptime.c
index 274b41b..f957f17 100644
--- a/components/uptime.c
+++ b/components/uptime.c
_AT_@ -1,19 +1,23 @@
/* See LICENSE file for copyright and license details. */
-#include <time.h>
+#include <inttypes.h>
#include <stdio.h>
+#include <time.h>
#include "../util.h"
const char *
uptime(void)
{
- int h, m;
+ uint64_t h, m;
struct timespec uptime;
+
if (clock_gettime(CLOCK_BOOTTIME, &uptime) < 0) {
warn("clock_gettime 'CLOCK_BOOTTIME'");
return NULL;
}
+
h = uptime.tv_sec / 3600;
m = uptime.tv_sec % 3600 / 60;
- return bprintf("%dh %dm", h, m);
+
+ return bprintf("%" PRIu64 "h %" PRIu64 "m", h, m);
}
Received on Fri Jul 06 2018 - 23:48:16 CEST
This archive was generated by hypermail 2.3.0
: Fri Jul 06 2018 - 23:48:28 CEST