Make scope of match macro symmetric

This commit is contained in:
Benny Baumann 2020-10-31 21:11:39 +01:00
parent 493217e814
commit 9a16b1079e

View File

@ -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);
}