sensors: Fallback fix

This commit is contained in:
Alastair Poole 2021-04-06 17:58:50 +01:00
parent 93afb7f45d
commit 2ee73c7fad
1 changed files with 16 additions and 17 deletions

View File

@ -453,22 +453,23 @@ _battery_state_get(power_t *power)
} }
closedir(dir); closedir(dir);
if (!naming) if (naming)
continue;
snprintf(path, sizeof(path), "%s/%s_full", link, naming);
buf = file_contents(path);
if (buf)
{ {
power->batteries[i]->charge_full = atol(buf); snprintf(path, sizeof(path), "%s/%s_full", link, naming);
free(buf); buf = file_contents(path);
} if (buf)
snprintf(path, sizeof(path), "%s/%s_now", link, naming); {
buf = file_contents(path); power->batteries[i]->charge_full = atol(buf);
if (buf) free(buf);
{ }
power->batteries[i]->charge_current = atol(buf); snprintf(path, sizeof(path), "%s/%s_now", link, naming);
free(buf); buf = file_contents(path);
if (buf)
{
power->batteries[i]->charge_current = atol(buf);
free(buf);
}
free(naming);
} }
else else
{ {
@ -488,11 +489,9 @@ _battery_state_get(power_t *power)
power->batteries[i]->charge_current = 25; power->batteries[i]->charge_current = 25;
else if (buf[0] == 'C') else if (buf[0] == 'C')
power->batteries[i]->charge_current = 5; power->batteries[i]->charge_current = 5;
free(buf); free(buf);
} }
} }
free(naming);
} }
done: done:
if (link) free(link); if (link) free(link);