various: Put paths into defines to avoid line wraps

Long, wrapped, multi-line if statements suck to read.
This fixes readability in the worst places by packing format strings for
paths into defines.
This commit is contained in:
drkhsh
2022-10-27 23:44:52 +02:00
parent c46c1487a9
commit 69b2487650
5 changed files with 36 additions and 41 deletions

View File

@ -18,6 +18,8 @@
#include <limits.h>
#include <linux/wireless.h>
#define NET_OPERSTATE "/sys/class/net/%s/operstate"
const char *
wifi_perc(const char *interface)
{
@ -28,10 +30,8 @@
char status[5];
FILE *fp;
if (esnprintf(path, sizeof(path), "/sys/class/net/%s/operstate",
interface) < 0) {
if (esnprintf(path, sizeof(path), NET_OPERSTATE, interface) < 0)
return NULL;
}
if (!(fp = fopen(path, "r"))) {
warn("fopen '%s':", path);
return NULL;