summaryrefslogtreecommitdiff
path: root/components/ram.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-07-06 23:37:05 +0200
committerAaron Marcher <me@drkhsh.at>2018-07-06 23:37:05 +0200
commitfa7c266e2b7adbc2a87bd44057b9e561d9ed61e3 (patch)
tree6618bcbc13118b83d1acea2e17e956b04eaa1cdc /components/ram.c
parentb65c058598afe7319c1a634cd8423ec25d0d7215 (diff)
ram: Use POSIX types
Diffstat (limited to 'components/ram.c')
-rw-r--r--components/ram.c34
1 files changed, 18 insertions, 16 deletions
diff --git a/components/ram.c b/components/ram.c
index 0333b3b..74bf337 100644
--- a/components/ram.c
+++ b/components/ram.c
@@ -4,15 +4,17 @@
#include "../util.h"
#if defined(__linux__)
+ #include <inttypes.h>
+
const char *
ram_free(void)
{
- long free;
+ uint64_t free;
if (pscanf("/proc/meminfo",
- "MemTotal: %ld kB\n"
- "MemFree: %ld kB\n"
- "MemAvailable: %ld kB\n",
+ "MemTotal: %" PRIu64 " kB\n"
+ "MemFree: %" PRIu64 " kB\n"
+ "MemAvailable: %" PRIu64 " kB\n",
&free, &free, &free) != 3) {
return NULL;
}
@@ -23,13 +25,13 @@
const char *
ram_perc(void)
{
- long total, free, buffers, cached;
+ uint64_t total, free, buffers, cached;
if (pscanf("/proc/meminfo",
- "MemTotal: %ld kB\n"
- "MemFree: %ld kB\n"
- "MemAvailable: %ld kB\nBuffers: %ld kB\n"
- "Cached: %ld kB\n",
+ "MemTotal: %" PRIu64 " kB\n"
+ "MemFree: %" PRIu64 " kB\n"
+ "MemAvailable: %" PRIu64 " kB\nBuffers: %ld kB\n"
+ "Cached: %" PRIu64 " kB\n",
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}
@@ -41,9 +43,9 @@
const char *
ram_total(void)
{
- long total;
+ uint64_t total;
- if (pscanf("/proc/meminfo", "MemTotal: %ld kB\n",
+ if (pscanf("/proc/meminfo", "MemTotal: %" PRIu64 " kB\n",
&total) != 1) {
return NULL;
}
@@ -54,13 +56,13 @@
const char *
ram_used(void)
{
- long total, free, buffers, cached;
+ uint64_t total, free, buffers, cached;
if (pscanf("/proc/meminfo",
- "MemTotal: %ld kB\n"
- "MemFree: %ld kB\n"
- "MemAvailable: %ld kB\nBuffers: %ld kB\n"
- "Cached: %ld kB\n",
+ "MemTotal: %" PRIu64 " kB\n"
+ "MemFree: %" PRIu64 " kB\n"
+ "MemAvailable: %" PRIu64 " kB\nBuffers: %" PRIu64 " kB\n"
+ "Cached: %" PRIu64 " kB\n",
&total, &free, &buffers, &buffers, &cached) != 5) {
return NULL;
}