[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 02/02: Renamed variables in implementation according to header file; indicate unsued pointers, assertions on arguments (might be replaced by g_return_if_fail?)

noreply at xfce.org noreply at xfce.org
Wed Apr 19 00:45:50 CEST 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 7df8b3259140909d48d5add303a2e6a190b028a8
Author: Fabian <timystery at arcor.de>
Date:   Wed Apr 19 00:24:10 2017 +0200

    Renamed variables in implementation according to header file; indicate unsued pointers, assertions on arguments (might be replaced by g_return_if_fail?)
---
 include/middlelayer.h |   8 +--
 lib/middlelayer.c     | 178 ++++++++++++++++++++++++++------------------------
 2 files changed, 95 insertions(+), 91 deletions(-)

diff --git a/include/middlelayer.h b/include/middlelayer.h
index 4df03b2..6b3cd3c 100644
--- a/include/middlelayer.h
+++ b/include/middlelayer.h
@@ -69,17 +69,17 @@ int sensor_get_value (t_chip *ptr_chip, int idx_chipfeature, double *outptr_valu
 /**
  * Free data in chipfeatures
  * @param ptr_chipfeature: pointer to chipfeature to free
- * @param ptr_data: currently unused
+ * @param ptr_unused: currently unused
  */
-void free_chipfeature (gpointer ptr_chipfeature, gpointer ptr_data);
+void free_chipfeature (gpointer ptr_chipfeature, gpointer ptr_unused);
 
 
 /**
  * Free remaining structures in chips and associated chipfeatures
  * @param ptr_chip: pointer to chip to free
- * @param ptr_data: currently unused
+ * @param ptr_unused: currently unused
  */
-void free_chip (gpointer ptr_chip, gpointer ptr_data);
+void free_chip (gpointer ptr_chip, gpointer ptr_unused);
 
 
 /**
diff --git a/lib/middlelayer.c b/lib/middlelayer.c
index cde5c0e..91ed7c2 100644
--- a/lib/middlelayer.c
+++ b/lib/middlelayer.c
@@ -28,10 +28,6 @@
 
 /* Gtk/Glib includes */
 #include <glib.h>
-/* #include <glib/gerror.h>
-#include <glib/gmem.h>
-#include <glib/gmessages.h>
-#include <glib/gprintf.h> */
 
 /* Global includes */
 #include <string.h>
@@ -56,67 +52,70 @@
 
 /* -------------------------------------------------------------------------- */
 int
-initialize_all (GPtrArray **chips, gboolean *suppressmessage)
+initialize_all (GPtrArray **outptr_arr_ptr_chips, gboolean *outptr_suppressmessage)
 {
-    int res = 0;
+    int result = 0;
 
     TRACE ("enters initialize_all");
 
-    *chips = g_ptr_array_new(); //_with_free_func(free_chip);
+    g_assert (outptr_arr_ptr_chips != NULL);
+
+    *outptr_arr_ptr_chips = g_ptr_array_new(); //_with_free_func(free_chip);
 
      #ifdef HAVE_LIBSENSORS
-    res += initialize_libsensors (*chips);
+    result += initialize_libsensors (*outptr_arr_ptr_chips);
     #endif
 
     #ifdef HAVE_HDDTEMP
-    res += initialize_hddtemp (*chips, suppressmessage);
+    result += initialize_hddtemp (*outptr_arr_ptr_chips, outptr_suppressmessage);
     #endif
 
     #ifdef HAVE_ACPI
-    res += initialize_ACPI (*chips);
+    result += initialize_ACPI (*outptr_arr_ptr_chips);
     #endif
 
     #ifdef HAVE_NVIDIA
-    res += initialize_nvidia (*chips);
+    result += initialize_nvidia (*outptr_arr_ptr_chips);
     #endif
 
-    TRACE ("leaves initialize_all, chips->len=%d", (*chips)->len);
+    TRACE ("leaves initialize_all, chips->len=%d", (*outptr_arr_ptr_chips)->len);
 
-    return res;
+    return result;
 }
 
 
 /* -------------------------------------------------------------------------- */
 void
-refresh_chip (gpointer chip, gpointer data)
+refresh_chip (gpointer ptr_chip, gpointer ptr_data)
 {
     t_chip *ptr_chip_structure;
 
-    g_assert (chip!=NULL);
+    g_assert (ptr_chip != NULL);
 
     TRACE ("enters refresh_chip");
 
-    ptr_chip_structure = (t_chip*) chip;
+    ptr_chip_structure = (t_chip*) ptr_chip;
 
     switch (ptr_chip_structure->type)
     {
     #ifdef HAVE_ACPI
         case ACPI: {
-            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_acpi, NULL );
+            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_acpi, NULL);
             break;
         }
     #endif
 
     #ifdef HAVE_LIBSENSORS
         case LMSENSOR: {
-            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_lmsensors, NULL );
+            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_lmsensors, NULL);
             break;
         }
     #endif
 
     #ifdef HAVE_HDDTEMP
         case HDD: {
-            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_hddtemp, data ); /* note that data is of *t_sensors! */
+            g_assert (ptr_data != NULL);
+            g_ptr_array_foreach (ptr_chip_structure->chip_features, refresh_hddtemp, ptr_data); /* note that data is of *t_sensors! */
             break;
         }
     #endif
@@ -139,11 +138,14 @@ refresh_chip (gpointer chip, gpointer data)
 
 /* -------------------------------------------------------------------------- */
 void
-refresh_all_chips (GPtrArray *chips, t_sensors *sensors )
+refresh_all_chips (GPtrArray *arr_ptr_chips, t_sensors *ptr_sensors )
 {
     TRACE ("enters refresh_all_chips");
 
-    g_ptr_array_foreach (chips, refresh_chip, sensors);
+    g_assert (arr_ptr_chips != NULL);
+    g_assert (ptr_sensors != NULL);
+
+    g_ptr_array_foreach (arr_ptr_chips, refresh_chip, ptr_sensors);
 
     TRACE ("leaves refresh_all_chips");
 }
@@ -151,36 +153,37 @@ refresh_all_chips (GPtrArray *chips, t_sensors *sensors )
 
 /* -------------------------------------------------------------------------- */
 void
-categorize_sensor_type (t_chipfeature* chipfeature)
+categorize_sensor_type (t_chipfeature* ptr_chipfeature)
 {
     TRACE ("enters categorize_sensor_type");
-
-    if ( strstr(chipfeature->name, "Temp")!=NULL
-    || strstr(chipfeature->name, "temp")!=NULL ) {
-        chipfeature->class = TEMPERATURE;
-        chipfeature->min_value = 0.0;
-        chipfeature->max_value = 80.0;
-    } else if ( strstr(chipfeature->name, "VCore")!=NULL
-    || strstr(chipfeature->name, "3V")!=NULL
-    || strstr(chipfeature->name, "5V")!=NULL
-    || strstr(chipfeature->name, "12V")!=NULL ) {
-        chipfeature->class = VOLTAGE;
-        chipfeature->min_value = 1.0;
-        chipfeature->max_value = 12.2;
-    } else if ( strstr(chipfeature->name, "Fan")!=NULL
-    || strstr(chipfeature->name, "fan")!=NULL ) {
-        chipfeature->class = SPEED;
-        chipfeature->min_value = 1000.0;
-        chipfeature->max_value = 3500.0;
-    } else if ( strstr(chipfeature->name, "alarm")!=NULL
-    || strstr(chipfeature->name, "Alarm")!=NULL ) {
-        chipfeature->class = STATE;
-        chipfeature->min_value = 0.0;
-        chipfeature->max_value = 1.0;
+    g_assert (ptr_chipfeature != NULL);
+
+    if ( strstr(ptr_chipfeature->name, "Temp")!=NULL
+    || strstr(ptr_chipfeature->name, "temp")!=NULL ) {
+        ptr_chipfeature->class = TEMPERATURE;
+        ptr_chipfeature->min_value = 0.0;
+        ptr_chipfeature->max_value = 80.0;
+    } else if ( strstr(ptr_chipfeature->name, "VCore")!=NULL
+    || strstr(ptr_chipfeature->name, "3V")!=NULL
+    || strstr(ptr_chipfeature->name, "5V")!=NULL
+    || strstr(ptr_chipfeature->name, "12V")!=NULL ) {
+        ptr_chipfeature->class = VOLTAGE;
+        ptr_chipfeature->min_value = 1.0;
+        ptr_chipfeature->max_value = 12.2;
+    } else if ( strstr(ptr_chipfeature->name, "Fan")!=NULL
+    || strstr(ptr_chipfeature->name, "fan")!=NULL ) {
+        ptr_chipfeature->class = SPEED;
+        ptr_chipfeature->min_value = 1000.0;
+        ptr_chipfeature->max_value = 3500.0;
+    } else if ( strstr(ptr_chipfeature->name, "alarm")!=NULL
+    || strstr(ptr_chipfeature->name, "Alarm")!=NULL ) {
+        ptr_chipfeature->class = STATE;
+        ptr_chipfeature->min_value = 0.0;
+        ptr_chipfeature->max_value = 1.0;
     } else {
-        chipfeature->class = OTHER;
-        chipfeature->min_value = 0.0;
-        chipfeature->max_value = 7000.0;
+        ptr_chipfeature->class = OTHER;
+        ptr_chipfeature->min_value = 0.0;
+        ptr_chipfeature->max_value = 7000.0;
     }
 
     TRACE ("leaves categorize_sensor_type");
@@ -189,20 +192,21 @@ categorize_sensor_type (t_chipfeature* chipfeature)
 
 /* -------------------------------------------------------------------------- */
 int
-sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmessage)
+sensor_get_value (t_chip *ptr_chip, int idx_chipfeature, double *outptr_value, gboolean *outptr_suppressmessage)
 {
-    t_chipfeature *feature;
-        #ifdef HAVE_HDDTEMP
-    gboolean *suppress = suppressmessage;
-        #endif
-    /* TRACE ("enters sensor_get_value %d", number); */
+    t_chipfeature *ptr_feature;
+    #ifdef HAVE_HDDTEMP
+        gboolean *ptr_suppress = outptr_suppressmessage;
+        g_assert (ptr_suppress != NULL);
+    #endif
 
-    g_assert (chip!=NULL);
+    g_assert (ptr_chip != NULL);
+    g_assert (outptr_value != NULL);
 
-    switch (chip->type) {
+    switch (ptr_chip->type) {
         case LMSENSOR: {
             #ifdef HAVE_LIBSENSORS
-                return sensors_get_feature_wrapper (chip->chip_name, number, value);
+                return sensors_get_feature_wrapper (ptr_chip->chip_name, idx_chipfeature, outptr_value);
             #else
                 return -1;
             #endif
@@ -210,11 +214,11 @@ sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmes
         }
         case HDD: {
             #ifdef HAVE_HDDTEMP
-                g_assert (number<chip->num_features);
-                feature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, number);
-                g_assert (feature!=NULL);
-                *value = get_hddtemp_value (feature->devicename, suppress);
-                if (*value==NO_VALID_HDDTEMP_PROGRAM) {
+                g_assert (idx_chipfeature < ptr_chip->num_features);
+                ptr_feature = (t_chipfeature *) g_ptr_array_index (ptr_chip->chip_features, idx_chipfeature);
+                g_assert (ptr_feature != NULL);
+                *outptr_value = get_hddtemp_value (ptr_feature->devicename, ptr_suppress);
+                if (*outptr_value==NO_VALID_HDDTEMP_PROGRAM) {
                     return NO_VALID_HDDTEMP_PROGRAM;
                 }
                 return 0;
@@ -225,12 +229,12 @@ sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmes
         }
         case ACPI: {
             #ifdef HAVE_ACPI
-                g_assert (number<chip->num_features);
-                feature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, number);
-                g_assert (feature!=NULL);
+                g_assert (idx_chipfeature < ptr_chip->num_features);
+                ptr_feature = (t_chipfeature *) g_ptr_array_index (ptr_chip->chip_features, idx_chipfeature);
+                g_assert (ptr_feature != NULL);
                 /* TODO: seperate refresh from get operation! */
-                refresh_acpi ((gpointer) feature, NULL);
-                *value = feature->raw_value;
+                refresh_acpi ((gpointer) ptr_feature, NULL);
+                *outptr_value = ptr_feature->raw_value;
                 return 0;
             #else
                 return -1;
@@ -239,12 +243,12 @@ sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmes
         }
         case GPU: {
             #ifdef HAVE_NVIDIA
-                g_assert (number<chip->num_features);
-                feature = (t_chipfeature *) g_ptr_array_index (chip->chip_features, number);
-                g_assert (feature!=NULL);
+                g_assert (idx_chipfeature < ptr_chip->num_features);
+                ptr_feature = (t_chipfeature *) g_ptr_array_index (ptr_chip->chip_features, idx_chipfeature);
+                g_assert (ptr_feature != NULL);
                 /* TODO: seperate refresh from get operation! */
-                refresh_nvidia ((gpointer) feature, NULL);
-                *value = feature->raw_value;
+                refresh_nvidia ((gpointer) ptr_feature, NULL);
+                *outptr_value = ptr_feature->raw_value;
                 return 0;
             #else
                 return -1;
@@ -252,7 +256,7 @@ sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmes
             break;
         }
         default: {
-            feature = NULL;
+            ptr_feature = NULL;
             return -1;
             break;
         }
@@ -264,25 +268,25 @@ sensor_get_value (t_chip *chip, int number, double *value, gboolean *suppressmes
 
 /* -------------------------------------------------------------------------- */
 void
-free_chipfeature (gpointer chipfeature, gpointer data)
+free_chipfeature (gpointer ptr_chipfeature, gpointer ptr_unused)
 {
-    t_chipfeature *ptr_chipfeature;
-    ptr_chipfeature = (t_chipfeature *) chipfeature;
-
-    g_free (ptr_chipfeature->name);
-    g_free (ptr_chipfeature->devicename);
-    g_free (ptr_chipfeature->formatted_value);
-    g_free (ptr_chipfeature->color);
-    g_free (ptr_chipfeature);
+    t_chipfeature *ptr_localchipfeature = (t_chipfeature *) ptr_chipfeature;
+    g_assert (ptr_localchipfeature!=NULL);
+
+    g_free (ptr_localchipfeature->name);
+    g_free (ptr_localchipfeature->devicename);
+    g_free (ptr_localchipfeature->formatted_value);
+    g_free (ptr_localchipfeature->color);
+    g_free (ptr_localchipfeature);
 }
 
 
 /* -------------------------------------------------------------------------- */
 void
-free_chip (gpointer chip, gpointer data)
+free_chip (gpointer ptr_chip, gpointer ptr_unused)
 {
-    t_chip *ptr_chip_structure;
-    ptr_chip_structure = (t_chip *) chip;
+    t_chip *ptr_chip_structure = (t_chip *) ptr_chip;
+    g_assert (ptr_chip_structure != NULL);
 
     g_free (ptr_chip_structure->description);
     g_free (ptr_chip_structure->name);
@@ -290,12 +294,12 @@ free_chip (gpointer chip, gpointer data)
 
 #ifdef HAVE_LIBSENSORS
     if (ptr_chip_structure->type==LMSENSOR) {
-        free_lmsensors_chip (chip);
+        free_lmsensors_chip (ptr_chip);
     }
 #endif
 #ifdef HAVE_ACPI
     if (ptr_chip_structure->type==ACPI) {
-        free_acpi_chip (chip);
+        free_acpi_chip (ptr_chip);
     }
 #endif
 //#ifdef HAVE_HDDTEMP

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


More information about the Xfce4-commits mailing list