Skip to content

Commit

Permalink
Make scope of match macro symmetric
Browse files Browse the repository at this point in the history
  • Loading branch information
BenBE committed Nov 2, 2020
1 parent 493217e commit 9a16b10
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions linux/Battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
Expand Down

0 comments on commit 9a16b10

Please sign in to comment.