[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 05/11: further assertions for more safety

noreply at xfce.org noreply at xfce.org
Tue Mar 7 23:38:29 CET 2017


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

timystery pushed a commit to branch master
in repository panel-plugins/xfce4-sensors-plugin.

commit 89acf574bb7b29656f6f5226fcc870cbae85c787
Author: Fabian <timystery at arcor.de>
Date:   Mon Mar 6 23:49:49 2017 +0100

    further assertions for more safety
---
 lib/acpi.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/lib/acpi.c b/lib/acpi.c
index e5da786..e4a3e69 100644
--- a/lib/acpi.c
+++ b/lib/acpi.c
@@ -217,6 +217,7 @@ get_fan_zone_value (gchar *str_zonename)
             if (strncmp (buffer, "status:", 7)==0)
             {
                 ptr_strippedbuffer = strip_key_colon_spaces(buffer);
+                g_assert(ptr_strippedbuffer!=NULL);
                 DBG ("tmp=%s", ptr_strippedbuffer);
                 if (strncmp (ptr_strippedbuffer, "on", 2)==0)
                     res_value = 1.0;
@@ -273,6 +274,7 @@ get_battery_zone_value (gchar *str_zone)
             if (strncmp (buffer, "remaining capacity:", 19)==0)
             {
                 ptr_strippedbuffer = strip_key_colon_spaces(buffer);
+                g_assert(ptr_strippedbuffer!=NULL);
                 res_value = strtod (ptr_strippedbuffer, NULL);
                 break;
             }
@@ -382,11 +384,13 @@ read_battery_zone (t_chip *ptr_chip)
                         if (strncmp (buffer, "design capacity low:", 20)==0)
                         {
                             ptr_strippedbuffer = strip_key_colon_spaces(buffer);
+                            g_assert(ptr_strippedbuffer!=NULL);
                             ptr_chipfeature->min_value = strtod (ptr_strippedbuffer, NULL);
                         }
                         else if (strncmp (buffer, "remaining capacity:", 19)==0)
                         {
                             ptr_strippedbuffer = strip_key_colon_spaces(buffer);
+                            g_assert(ptr_strippedbuffer!=NULL);
                             ptr_chipfeature->raw_value = strtod (ptr_strippedbuffer, NULL);
                         }
                     }
@@ -468,6 +472,7 @@ get_battery_max_value (gchar *str_filename, t_chipfeature *ptr_chipfeature)
             if (strncmp (buffer, "last full capacity:", 19)==0)
             {
                 ptr_strippedbuffer = strip_key_colon_spaces(buffer);
+                g_assert(ptr_strippedbuffer!=NULL);
                 ptr_chipfeature->max_value = strtod (ptr_strippedbuffer, NULL);
                 break;
             }
@@ -636,6 +641,7 @@ refresh_acpi (gpointer ptr_chipfeature, gpointer ptr_unused)
                 cf->raw_value = strtod(buffer, NULL) / 1000.0;
               }
               fclose (ptr_file);
+              ptr_file = NULL; /* avoid reuse after closing file */
             }
 #else
             str_zone = g_strdup_printf ("%s/%s", ACPI_DIR_THERMAL, cf->devicename);
@@ -776,6 +782,7 @@ get_acpi_value (gchar *str_filename)
         fclose (ptr_file);
 
         ptr_valueinstring = strip_key_colon_spaces (buffer);
+        g_assert(ptr_valueinstring!=NULL); /* points to beginning of buffer at least */
 
         TRACE ("leaves get_acpi_value with %s", ptr_valueinstring);
 

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


More information about the Xfce4-commits mailing list