forked from enlightenment/evisum
Fix: Let's ensure we can properly escape this function.
Thanks to Apostolos Bartziokas for his patience and testing. His commitment is very valuable.
This commit is contained in:
parent
37cb378cf9
commit
4792cd07e4
|
@ -871,7 +871,7 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
unsigned long charge_full = 0;
|
unsigned long charge_full = 0;
|
||||||
unsigned long charge_current = 0;
|
unsigned long charge_current = 0;
|
||||||
|
|
||||||
while (i < power->battery_count)
|
for (i = 0; i < power->battery_count; i++)
|
||||||
{
|
{
|
||||||
naming = NULL;
|
naming = NULL;
|
||||||
snprintf(path, sizeof(path), "/sys/class/power_supply/%s", power->battery_names[i]);
|
snprintf(path, sizeof(path), "/sys/class/power_supply/%s", power->battery_names[i]);
|
||||||
|
@ -897,7 +897,6 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
|
|
||||||
if (!naming)
|
if (!naming)
|
||||||
{
|
{
|
||||||
i++;
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -920,7 +919,6 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
power->charge_current += charge_current;
|
power->charge_current += charge_current;
|
||||||
|
|
||||||
free(naming);
|
free(naming);
|
||||||
i++;
|
|
||||||
|
|
||||||
if (i == MAX_BATTERIES)
|
if (i == MAX_BATTERIES)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1081,16 +1081,16 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
struct stat st;
|
struct stat st;
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
char *buf, *naming;
|
char *buf, *naming;
|
||||||
int i = 0;
|
int i;
|
||||||
unsigned long charge_full = 0;
|
unsigned long charge_full = 0;
|
||||||
unsigned long charge_current = 0;
|
unsigned long charge_current = 0;
|
||||||
|
|
||||||
while (i < power->battery_count)
|
for (i = 0; i < power->battery_count; i++)
|
||||||
{
|
{
|
||||||
naming = NULL;
|
naming = NULL;
|
||||||
snprintf(path, sizeof(path), "/sys/class/power_supply/%s", power->battery_names[i]);
|
snprintf(path, sizeof(path), "/sys/class/power_supply/%s", power->battery_names[i]);
|
||||||
if (stat(path, &st) < 0) continue;
|
|
||||||
|
|
||||||
|
if (stat(path, &st) < 0) continue;
|
||||||
if (S_ISLNK(st.st_mode)) continue;
|
if (S_ISLNK(st.st_mode)) continue;
|
||||||
if (!S_ISDIR(st.st_mode)) continue;
|
if (!S_ISDIR(st.st_mode)) continue;
|
||||||
|
|
||||||
|
@ -1108,7 +1108,11 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
}
|
}
|
||||||
closedir(dir);
|
closedir(dir);
|
||||||
|
|
||||||
if (!naming) continue;
|
if (!naming)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(path, sizeof(path), "/sys/class/power_supply/%s/%s_full", power->battery_names[i], naming);
|
snprintf(path, sizeof(path), "/sys/class/power_supply/%s/%s_full", power->battery_names[i], naming);
|
||||||
buf = Fcontents(path);
|
buf = Fcontents(path);
|
||||||
if (buf)
|
if (buf)
|
||||||
|
@ -1127,7 +1131,6 @@ _battery_state_get(power_t *power, int *mib)
|
||||||
power->batteries[i]->charge_current = charge_current;
|
power->batteries[i]->charge_current = charge_current;
|
||||||
|
|
||||||
free(naming);
|
free(naming);
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue