More robust preprocessor switches
authorAaron Marcher <me@drkhsh.at>
Wed, 21 Mar 2018 11:21:37 +0000 (12:21 +0100)
committerAaron Marcher <me@drkhsh.at>
Wed, 21 Mar 2018 11:21:37 +0000 (12:21 +0100)
Replace #ifdef with #if defined() and #elif with #elif defined() as it
should only test if it is defined or not.

components/battery.c
components/cpu.c
components/entropy.c
components/ip.c
components/ram.c
components/swap.c
components/temperature.c
components/uptime.c
components/volume.c
components/wifi.c

index 4314e81c71b7614a84c88e9ffa922f7999e87714..aef5b5f3b2131ba4f5d34f35f1f8098e0a8121bb 100644 (file)
@@ -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>
 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)
 {
index ef27ec5a3d4702c7f6581b3b18e295f691cb1d9b..a001d146b5bf6cc4a9a3ad72b8f1e2b77b1a8092 100644 (file)
@@ -1,5 +1,5 @@
 /* See LICENSE file for copyright and license details. */
-#ifdef __linux__
+#if defined(__linux__)
 #include <stdio.h>
 #include <string.h>
 
index f1441b370001d4e849ddde173a7d7671a31e1cc9..65c65a1b3209453db5afd4216a602b0b08e5b84c 100644 (file)
@@ -1,5 +1,5 @@
 /* See LICENSE file for copyright and license details. */
-#ifdef __linux__
+#if defined(__linux__)
 #include <stdio.h>
 
 #include "../util.h"
index 8a40cfe577eb8343554fb87ad1944ff86319680d..25071e46f2f93c4cdc63dfd2168aa27648e1fc52 100644 (file)
@@ -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>
index 334a203347befd45d58bf705dc6749bf4176c589..a1fc3fe913b755bb7efbec971294466b75b14591 100644 (file)
@@ -1,5 +1,5 @@
 /* See LICENSE file for copyright and license details. */
-#ifdef __linux__
+#if defined(__linux__)
 #include <stdio.h>
 
 #include "../util.h"
index a030f5f35657e0b93c8622a28bbf68fd56432a93..0aad07491993d499b98d37c7bdb3c1cc115f509b 100644 (file)
@@ -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>
index 6376e30f79942964355accc6a2f7cd6bfcc5560d..4a447e5f1c06fd7aa7eca5aa1fbdc08094243ffb 100644 (file)
@@ -1,5 +1,5 @@
 /* See LICENSE file for copyright and license details. */
-#ifdef __linux__
+#if defined(__linux__)
 #include <stdio.h>
 
 #include "../util.h"
index c5e28ee0892093fa31e587201ad91621282a3378..8a04b92a22f17783eed5f2232e227549166b0a7f 100644 (file)
@@ -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;
index a4b49bb2c9a282497726b6a0e6865ca12b197aa9..22fa02fde4f03eaaafb9df98960c899b515f2290 100644 (file)
@@ -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>
index 084ab99178baeb5686fccb329c52a6deb54b901f..a02c277fe6eddf2070e209c69ca29964881b1286 100644 (file)
@@ -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>