summaryrefslogtreecommitdiff
path: root/components/swap.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-03-28 18:26:56 +0200
committerAaron Marcher <me@drkhsh.at>2018-03-28 18:26:56 +0200
commit96f3a8a54eeb3b2294ed953dad8b15349f3e2703 (patch)
tree26446375bc7c3e64769c1da43b37671da77e80ed /components/swap.c
parentaced8326228ea3cf1673828a6e488b8f75108f45 (diff)
Get rid of err.h as it is not portable
Replace warn() and warnx() with fprintf() and add <stdio.h> where necessary.
Diffstat (limited to 'components/swap.c')
-rw-r--r--components/swap.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/components/swap.c b/components/swap.c
index 0aad074..b82ff46 100644
--- a/components/swap.c
+++ b/components/swap.c
@@ -1,6 +1,5 @@
/* See LICENSE file for copyright and license details. */
#if defined(__linux__)
-#include <err.h>
#include <stdio.h>
#include <string.h>
@@ -16,12 +15,12 @@ swap_free(void)
fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- warn("Failed to open file /proc/meminfo");
+ fprintf(stderr, "Failed to open file /proc/meminfo");
return NULL;
}
if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) {
- warn("swap_free: read error");
+ fprintf(stderr, "swap_free: read error");
fclose(fp);
return NULL;
}
@@ -48,12 +47,12 @@ swap_perc(void)
fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- warn("Failed to open file /proc/meminfo");
+ fprintf(stderr, "Failed to open file /proc/meminfo");
return NULL;
}
if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) {
- warn("swap_perc: read error");
+ fprintf(stderr, "swap_perc: read error");
fclose(fp);
return NULL;
}
@@ -84,11 +83,11 @@ swap_total(void)
fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- warn("Failed to open file /proc/meminfo");
+ fprintf(stderr, "Failed to open file /proc/meminfo");
return NULL;
}
if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) {
- warn("swap_total: read error");
+ fprintf(stderr, "swap_total: read error");
fclose(fp);
return NULL;
}
@@ -111,11 +110,11 @@ swap_used(void)
fp = fopen("/proc/meminfo", "r");
if (fp == NULL) {
- warn("Failed to open file /proc/meminfo");
+ fprintf(stderr, "Failed to open file /proc/meminfo");
return NULL;
}
if ((bytes_read = fread(buf, sizeof(char), sizeof(buf) - 1, fp)) == 0) {
- warn("swap_used: read error");
+ fprintf(stderr, "swap_used: read error");
fclose(fp);
return NULL;
}