This is an automated email from the git hooks/post-receive script.

git pushed a commit to branch master
in repository enlightenment.

View the commit online.

commit d9560ef485fb62363b5ebcc1e7a7bf3632f27034
Author: Alastair Poole <m...@alastairpoole.com>
AuthorDate: Sat Feb 8 20:30:38 2025 +0000

    battery: clamp health at 100%.
    
    You shouldn't have > 100.0% health.
    
    @fix
---
 src/modules/battery/e_mod_main.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/modules/battery/e_mod_main.c b/src/modules/battery/e_mod_main.c
index 9649986a7..88b34ec94 100644
--- a/src/modules/battery/e_mod_main.c
+++ b/src/modules/battery/e_mod_main.c
@@ -324,11 +324,14 @@ _battery_popup_usage_content_update_cb(void *data)
         snprintf(buf, sizeof(buf), "%i:%02i", hrs, mins);
         elm_object_text_set(w->remaining, buf);
 
-        if ((bat->last_full_charge > 0) && (bat->design_charge > 0))
-          snprintf(buf, sizeof(buf), "%1.1f%%",
-                   100.0 * ((double)bat->last_full_charge / bat->design_charge));
-        else
+        if ((bat->last_full_charge <= 0) || (bat->design_charge <= 0))
           snprintf(buf, sizeof(buf), "???%%");
+        else
+          {
+             double health = 100.0 * (double)bat->last_full_charge / bat->design_charge;
+             if (health > 100.0) health = 100.0;
+             snprintf(buf, sizeof(buf), "%1.1f%%", health);
+          }
         elm_object_text_set(w->health, buf);
 
         if (bat->technology)

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.

Reply via email to