diff options
author | Aaron Marcher <me@drkhsh.at> | 2018-03-21 12:21:37 +0100 |
---|---|---|
committer | Aaron Marcher <me@drkhsh.at> | 2018-03-21 12:21:37 +0100 |
commit | e79d4932ea413c277425ff92c456741e0730c3d6 (patch) | |
tree | 7f49fbc24b6594ecd22655f47a4523242e326cee | |
parent | fc5d23212fdaec8c242db9b25770f290dd287212 (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.
-rw-r--r-- | components/battery.c | 10 | ||||
-rw-r--r-- | components/cpu.c | 2 | ||||
-rw-r--r-- | components/entropy.c | 2 | ||||
-rw-r--r-- | components/ip.c | 2 | ||||
-rw-r--r-- | components/ram.c | 2 | ||||
-rw-r--r-- | components/swap.c | 2 | ||||
-rw-r--r-- | components/temperature.c | 2 | ||||
-rw-r--r-- | components/uptime.c | 8 | ||||
-rw-r--r-- | components/volume.c | 2 | ||||
-rw-r--r-- | components/wifi.c | 2 |
10 files changed, 17 insertions, 17 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) { diff --git a/components/cpu.c b/components/cpu.c index ef27ec5..a001d14 100644 --- a/components/cpu.c +++ b/components/cpu.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include <string.h> diff --git a/components/entropy.c b/components/entropy.c index f1441b3..65c65a1 100644 --- a/components/entropy.c +++ b/components/entropy.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h" diff --git a/components/ip.c b/components/ip.c index 8a40cfe..25071e4 100644 --- a/components/ip.c +++ b/components/ip.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <ifaddrs.h> #include <netdb.h> diff --git a/components/ram.c b/components/ram.c index 334a203..a1fc3fe 100644 --- a/components/ram.c +++ b/components/ram.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h" diff --git a/components/swap.c b/components/swap.c index a030f5f..0aad074 100644 --- a/components/swap.c +++ b/components/swap.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <stdio.h> #include <string.h> diff --git a/components/temperature.c b/components/temperature.c index 6376e30..4a447e5 100644 --- a/components/temperature.c +++ b/components/temperature.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <stdio.h> #include "../util.h" diff --git a/components/uptime.c b/components/uptime.c index c5e28ee..8a04b92 100644 --- a/components/uptime.c +++ b/components/uptime.c @@ -1,8 +1,8 @@ /* See LICENSE file for copyright and license details. */ #include <stdio.h> -#ifdef __linux__ +#if defined(__linux__) #include <sys/sysinfo.h> -#elif __OpenBSD__ +#elif defined(__OpenBSD__) #include <sys/sysctl.h> #include <sys/time.h> #endif @@ -15,12 +15,12 @@ uptime(void) int h; int m; int uptime = 0; -#ifdef __linux__ +#if defined(__linux__) struct sysinfo info; sysinfo(&info); uptime = info.uptime; -#elif __OpenBSD__ +#elif defined(__OpenBSD__) int mib[2]; size_t size; time_t now; diff --git a/components/volume.c b/components/volume.c index a4b49bb..22fa02f 100644 --- a/components/volume.c +++ b/components/volume.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <fcntl.h> #include <sys/soundcard.h> diff --git a/components/wifi.c b/components/wifi.c index 084ab99..a02c277 100644 --- a/components/wifi.c +++ b/components/wifi.c @@ -1,5 +1,5 @@ /* See LICENSE file for copyright and license details. */ -#ifdef __linux__ +#if defined(__linux__) #include <err.h> #include <ifaddrs.h> #include <linux/wireless.h> |