From 9a16b1079ec1e831a449eb23ff23bf13b1b2a935 Mon Sep 17 00:00:00 2001 From: Benny Baumann Date: Sat, 31 Oct 2020 21:11:39 +0100 Subject: [PATCH] Make scope of match macro symmetric --- linux/Battery.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/linux/Battery.c b/linux/Battery.c index 3554d799..c185258a 100644 --- a/linux/Battery.c +++ b/linux/Battery.c @@ -232,9 +232,11 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { bool now = false; int fullSize = 0; double capacityLevel = NAN; + + #define match(str,prefix) \ + (String_startsWith(str,prefix) ? (str) + strlen(prefix) : NULL) + while ((line = strsep(&buf, "\n")) != NULL) { - #define match(str,prefix) \ - (String_startsWith(str,prefix) ? (str) + strlen(prefix) : NULL) const char* ps = match(line, "POWER_SUPPLY_"); if (!ps) { continue; @@ -266,7 +268,9 @@ static void Battery_getSysData(double* level, ACPresence* isOnAC) { continue; } } - #undef match + + #undef match + if (!now && full && !isnan(capacityLevel)) { totalRemain += (capacityLevel * fullSize); }