summaryrefslogtreecommitdiff
path: root/components/battery.c
diff options
context:
space:
mode:
authorAaron Marcher <me@drkhsh.at>2018-03-21 12:21:37 +0100
committerAaron Marcher <me@drkhsh.at>2018-03-21 12:21:37 +0100
commite79d4932ea413c277425ff92c456741e0730c3d6 (patch)
tree7f49fbc24b6594ecd22655f47a4523242e326cee /components/battery.c
parentfc5d23212fdaec8c242db9b25770f290dd287212 (diff)
More robust preprocessor switches
Replace #ifdef with #if defined() and #elif with #elif defined() as it should only test if it is defined or not.
Diffstat (limited to 'components/battery.c')
-rw-r--r--components/battery.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/components/battery.c b/components/battery.c
index 4314e81..aef5b5f 100644
--- a/components/battery.c
+++ b/components/battery.c
@@ -1,10 +1,10 @@
/* See LICENSE file for copyright and license details. */
#include <err.h>
#include <stdio.h>
-#ifdef __linux__
+#if defined(__linux__)
#include <limits.h>
#include <string.h>
-#elif __OpenBSD__
+#elif defined(__OpenBSD__)
#include <sys/ioctl.h>
#include <fcntl.h>
#include <unistd.h>
@@ -16,14 +16,14 @@
const char *
battery_perc(const char *bat)
{
-#ifdef __linux__
+#if defined(__linux__)
int perc;
char path[PATH_MAX];
snprintf(path, sizeof(path), "%s%s%s", "/sys/class/power_supply/", bat, "/capacity");
return (pscanf(path, "%i", &perc) == 1) ?
bprintf("%d", perc) : NULL;
-#elif __OpenBSD__
+#elif defined(__OpenBSD__)
struct apm_power_info apm_info;
int fd;
@@ -44,7 +44,7 @@ battery_perc(const char *bat)
#endif
}
-#ifdef __linux__
+#if defined(__linux__)
const char *
battery_power(const char *bat)
{