netstar pushed a commit to branch master.

http://git.enlightenment.org/apps/evisum.git/commit/?id=4792cd07e4001d79deb5604616a2690e8bc21fe6

commit 4792cd07e4001d79deb5604616a2690e8bc21fe6
Author: Alastair Poole <[email protected]>
Date:   Sun Sep 1 14:22:40 2019 +0100

    Fix: Let's ensure we can properly escape this function.
    
    Thanks to Apostolos Bartziokas for his patience and testing.
    His commitment is very valuable.
---
 src/system.c        |  4 +---
 src/tingle/tingle.c | 13 ++++++++-----
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/system.c b/src/system.c
index c79c803..dea2129 100644
--- a/src/system.c
+++ b/src/system.c
@@ -871,7 +871,7 @@ _battery_state_get(power_t *power, int *mib)
    unsigned long charge_full = 0;
    unsigned long charge_current = 0;
 
-   while (i < power->battery_count)
+   for (i = 0; i < power->battery_count; i++)
      {
         naming = NULL;
         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)
           {
-             i++;
              continue;
           }
 
@@ -920,7 +919,6 @@ _battery_state_get(power_t *power, int *mib)
         power->charge_current += charge_current;
 
         free(naming);
-        i++;
 
         if (i == MAX_BATTERIES)
           {
diff --git a/src/tingle/tingle.c b/src/tingle/tingle.c
index ba0c312..7a732ef 100644
--- a/src/tingle/tingle.c
+++ b/src/tingle/tingle.c
@@ -1081,16 +1081,16 @@ _battery_state_get(power_t *power, int *mib)
    struct stat st;
    DIR *dir;
    char *buf, *naming;
-   int i = 0;
+   int i;
    unsigned long charge_full = 0;
    unsigned long charge_current = 0;
 
-   while (i < power->battery_count)
+   for (i = 0; i < power->battery_count; i++)
      {
         naming = NULL;
         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_ISDIR(st.st_mode)) continue;
 
@@ -1108,7 +1108,11 @@ _battery_state_get(power_t *power, int *mib)
           }
         closedir(dir);
 
-        if (!naming) continue;
+        if (!naming)
+         {
+             continue;
+         }
+
         snprintf(path, sizeof(path), "/sys/class/power_supply/%s/%s_full", 
power->battery_names[i], naming);
         buf = Fcontents(path);
         if (buf)
@@ -1127,7 +1131,6 @@ _battery_state_get(power_t *power, int *mib)
         power->batteries[i]->charge_current = charge_current;
 
         free(naming);
-        i++;
      }
 #endif
 }

-- 


Reply via email to