summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenny Baumann <BenBE@geshi.org>2020-10-31 21:11:39 +0100
committerBenny Baumann <BenBE@geshi.org>2020-11-02 22:15:01 +0100
commit9a16b1079ec1e831a449eb23ff23bf13b1b2a935 (patch)
treebe8ed62e7ef4b3696645c06999c4f9f9e942f801
parent493217e8145079e552d9da8d69f2767bb1b9e8c7 (diff)
Make scope of match macro symmetric
-rw-r--r--linux/Battery.c10
1 files 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);
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy