[Xfce4-commits] [panel-plugins/xfce4-sensors-plugin] 01/01: refactoring and code cleanup in hddtemp and configuration parts

noreply at xfce.org noreply at xfce.org
Mon Feb 13 22:52:16 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 509aadb08f636f2b1d1d2f25f636e810ce26ea25
Author: Fabian <timystery at arcor.de>
Date:   Mon Feb 13 22:46:43 2017 +0100

    refactoring and code cleanup in hddtemp and configuration parts
---
 include/hddtemp.h   |  21 ++--
 lib/configuration.c | 319 +++++++++++++++++++++++++---------------------------
 lib/hddtemp.c       | 215 ++++++++++++++++-------------------
 3 files changed, 267 insertions(+), 288 deletions(-)

diff --git a/include/hddtemp.h b/include/hddtemp.h
index ab1b4b4..48c6ba3 100644
--- a/include/hddtemp.h
+++ b/include/hddtemp.h
@@ -1,5 +1,5 @@
 /* $Id$ */
-/*  Copyright 2004-2010 Fabian Nowak (timystery at arcor.de)
+/*  Copyright 2004-2017 Fabian Nowak (timystery at arcor.de)
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -32,21 +32,28 @@
 
 /**
  * Initialize hddtemp by finding disks to monitor
- * @Param Pointer to array of chips
+ * @Param arr_ptr_chips: Pointer to array of chips
+ * @Param ptr_suppressmessage: returns whether messages shall be suppressed
  * @Return Number of initialized chips
  */
-int initialize_hddtemp (GPtrArray *chips, gboolean *suppressmessage);
+int initialize_hddtemp (GPtrArray *arr_ptr_chips, gboolean *ptr_suppressmessage);
 
 
 /**
  * Refreshs a hddtemp chip's feature in sense of raw and formatted value
  *
- * @Param chip_feature: Pointer to feature
- * @Param data: Pointer to t_sensors or NULL
+ * @Param ptr_chip_feature: Pointer to feature
+ * @Param ptr_data: Pointer to t_sensors or NULL
  */
-void refresh_hddtemp (gpointer chip_feature, gpointer data);
+void refresh_hddtemp (gpointer ptr_chip_feature, gpointer ptr_data);
 
 
-double get_hddtemp_value (char* disk, gboolean *suppressmessage);
+/**
+ * Gets the hddtemp value of a disk
+ * @Param str_disk: disk name
+ * @Param ptr_suppressmessage: returns whether messages shall be suppressed
+ * @Return Temperature of dsk
+ */
+double get_hddtemp_value (char* str_disk, gboolean *ptr_suppressmessage);
 
 #endif /* XFCE4_SENSORS_HDDTEMP_H */
diff --git a/lib/configuration.c b/lib/configuration.c
index 93c9ed6..e5fff75 100644
--- a/lib/configuration.c
+++ b/lib/configuration.c
@@ -40,7 +40,7 @@
 
 
 gint
-get_Id_from_address (gint chipnumber, gint addr_chipfeature, t_sensors *ptr_sensors)
+get_Id_from_address (gint idx_chip, gint addr_chipfeature, t_sensors *ptr_sensors)
 {
     gint idx_feature = -1;
     t_chip *ptr_chip = NULL;
@@ -48,7 +48,7 @@ get_Id_from_address (gint chipnumber, gint addr_chipfeature, t_sensors *ptr_sens
 
     TRACE ("enters get_Id_from_address");
 
-    ptr_chip = (t_chip *) g_ptr_array_index (ptr_sensors->chips, chipnumber);
+    ptr_chip = (t_chip *) g_ptr_array_index (ptr_sensors->chips, idx_chip);
 
     if (ptr_chip)
     {
@@ -72,10 +72,10 @@ void
 sensors_write_config (t_sensors *ptr_sensors)
 {
     XfceRc *ptr_xfcerc;
-    gchar *str_file, *str_tmp, rc_chip[8], feature[20];
-    gint i, j;
-    t_chip *chip;
-    t_chipfeature *chipfeature;
+    gchar *str_file, *str_tmp, str_chip[8], str_feature[20];
+    gint idx_chips, idx_features;
+    t_chip *ptr_chip;
+    t_chipfeature *ptr_chipfeature;
 
     TRACE ("enters sensors_write_config");
 
@@ -134,57 +134,57 @@ sensors_write_config (t_sensors *ptr_sensors)
             xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Width", ptr_sensors->preferred_width);
             xfce_rc_write_int_entry (ptr_xfcerc, "Preferred_Height", ptr_sensors->preferred_height);
 
-            for (i=0; i<ptr_sensors->num_sensorchips; i++) {
+            for (idx_chips=0; idx_chips<ptr_sensors->num_sensorchips; idx_chips++) {
 
-                chip = (t_chip *) g_ptr_array_index(ptr_sensors->chips, i);
-                g_assert (chip!=NULL);
+                ptr_chip = (t_chip *) g_ptr_array_index(ptr_sensors->chips, idx_chips);
+                g_assert (ptr_chip!=NULL);
 
-                g_snprintf (rc_chip, 8, "Chip%d", i);
+                g_snprintf (str_chip, 8, "Chip%d", idx_chips);
 
-                xfce_rc_set_group (ptr_xfcerc, rc_chip);
+                xfce_rc_set_group (ptr_xfcerc, str_chip);
 
-                xfce_rc_write_entry (ptr_xfcerc, "Name", chip->sensorId);
+                xfce_rc_write_entry (ptr_xfcerc, "Name", ptr_chip->sensorId);
 
                 /* number of sensors is still limited */
-                xfce_rc_write_int_entry (ptr_xfcerc, "Number", i);
+                xfce_rc_write_int_entry (ptr_xfcerc, "Number", idx_chips);
 
-                for (j=0; j<chip->num_features; j++) {
-                    chipfeature = g_ptr_array_index(chip->chip_features, j);
-                    g_assert (chipfeature!=NULL);
+                for (idx_features=0; idx_features<ptr_chip->num_features; idx_features++) {
+                    ptr_chipfeature = g_ptr_array_index(ptr_chip->chip_features, idx_features);
+                    g_assert (ptr_chipfeature!=NULL);
 
-                    if (chipfeature->show) {
+                    if (ptr_chipfeature->show) {
 
-                       g_snprintf (feature, 20, "%s_Feature%d", rc_chip, j);
+                       g_snprintf (str_feature, 20, "%s_Feature%d", str_chip, idx_features);
 
-                       xfce_rc_set_group (ptr_xfcerc, feature);
+                       xfce_rc_set_group (ptr_xfcerc, str_feature);
 
-                       xfce_rc_write_int_entry (ptr_xfcerc, "Id", get_Id_from_address(i, j, ptr_sensors));
+                       xfce_rc_write_int_entry (ptr_xfcerc, "Id", get_Id_from_address(idx_chips, idx_features, ptr_sensors));
 
                        /* only use this if no hddtemp sensor */
                        /* or do only use this , if it is an lmsensors device. whatever. */
-                       if ( strcmp(chip->sensorId, _("Hard disks")) != 0 ) /* chip->name? */
-                            xfce_rc_write_int_entry (ptr_xfcerc, "Address", j);
+                       if ( strcmp(ptr_chip->sensorId, _("Hard disks")) != 0 ) /* chip->name? */
+                            xfce_rc_write_int_entry (ptr_xfcerc, "Address", idx_features);
                         else
-                            xfce_rc_write_entry (ptr_xfcerc, "DeviceName", chipfeature->devicename);
+                            xfce_rc_write_entry (ptr_xfcerc, "DeviceName", ptr_chipfeature->devicename);
 
-                       xfce_rc_write_entry (ptr_xfcerc, "Name", chipfeature->name);
+                       xfce_rc_write_entry (ptr_xfcerc, "Name", ptr_chipfeature->name);
 
-                       xfce_rc_write_entry (ptr_xfcerc, "Color", chipfeature->color);
+                       xfce_rc_write_entry (ptr_xfcerc, "Color", ptr_chipfeature->color);
 
-                       xfce_rc_write_bool_entry (ptr_xfcerc, "Show", chipfeature->show);
+                       xfce_rc_write_bool_entry (ptr_xfcerc, "Show", ptr_chipfeature->show);
 
-                       str_tmp = g_strdup_printf("%.2f", chipfeature->min_value);
+                       str_tmp = g_strdup_printf("%.2f", ptr_chipfeature->min_value);
                        xfce_rc_write_entry (ptr_xfcerc, "Min", str_tmp);
                        g_free (str_tmp);
 
-                       str_tmp = g_strdup_printf("%.2f", chipfeature->max_value);
+                       str_tmp = g_strdup_printf("%.2f", ptr_chipfeature->max_value);
                        xfce_rc_write_entry (ptr_xfcerc, "Max", str_tmp);
                        g_free (str_tmp);
                     } /* end if */
 
-                } /* end for j */
+                } /* end for idx_features */
 
-            } /* end for i */
+            } /* end for idx_chips */
 
             xfce_rc_close (ptr_xfcerc);
 
@@ -195,65 +195,65 @@ sensors_write_config (t_sensors *ptr_sensors)
 
 
 void
-sensors_read_general_config (XfceRc *rc, t_sensors *sensors)
+sensors_read_general_config (XfceRc *ptr_xfceresources, t_sensors *ptr_sensors)
 {
-    const gchar *value;
+    const gchar *str_value;
 
     TRACE ("enters sensors_read_general_config");
 
-    if (xfce_rc_has_group (rc, "General") ) {
+    if (xfce_rc_has_group (ptr_xfceresources, "General") ) {
 
-        xfce_rc_set_group (rc, "General");
+        xfce_rc_set_group (ptr_xfceresources, "General");
 
-        sensors->show_title = xfce_rc_read_bool_entry (rc, "Show_Title", TRUE);
+        ptr_sensors->show_title = xfce_rc_read_bool_entry (ptr_xfceresources, "Show_Title", TRUE);
 
-        sensors->show_labels = xfce_rc_read_bool_entry (rc, "Show_Labels", TRUE);
+        ptr_sensors->show_labels = xfce_rc_read_bool_entry (ptr_xfceresources, "Show_Labels", TRUE);
 
-        sensors->display_values_type = xfce_rc_read_int_entry (rc, "Use_Bar_UI", 0);
+        ptr_sensors->display_values_type = xfce_rc_read_int_entry (ptr_xfceresources, "Use_Bar_UI", 0);
 
-        sensors->show_colored_bars = xfce_rc_read_bool_entry (rc, "Show_Colored_Bars", FALSE);
+        ptr_sensors->show_colored_bars = xfce_rc_read_bool_entry (ptr_xfceresources, "Show_Colored_Bars", FALSE);
 
-        sensors->scale = xfce_rc_read_int_entry (rc, "Scale", 0);
+        ptr_sensors->scale = xfce_rc_read_int_entry (ptr_xfceresources, "Scale", 0);
 
-        if ((value = xfce_rc_read_entry (rc, "str_fontsize", NULL)) && *value) {
-            g_free(sensors->str_fontsize);
-            sensors->str_fontsize = g_strdup(value);
+        if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "str_fontsize", NULL)) && *str_value) {
+            g_free(ptr_sensors->str_fontsize);
+            ptr_sensors->str_fontsize = g_strdup(str_value);
         }
 
-        if ((value = xfce_rc_read_entry (rc, "Font", NULL)) && *value) {
-            //g_free(sensors->font); // font is initialized to NULL
-            font = g_strdup(value); // in tacho.h for the tachometers
+        if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "Font", NULL)) && *str_value) {
+            //g_free(ptr_sensors->font); // font is initialized to NULL
+            font = g_strdup(str_value); // in tacho.h for the tachometers
         }
 
-        sensors->val_fontsize = xfce_rc_read_int_entry (rc,
+        ptr_sensors->val_fontsize = xfce_rc_read_int_entry (ptr_xfceresources,
                                                  "val_fontsize", 2);
 
-        sensors->lines_size = xfce_rc_read_int_entry (rc, "Lines_Size", 3);
+        ptr_sensors->lines_size = xfce_rc_read_int_entry (ptr_xfceresources, "Lines_Size", 3);
 
-        sensors->sensors_refresh_time = xfce_rc_read_int_entry (rc, "Update_Interval",
+        ptr_sensors->sensors_refresh_time = xfce_rc_read_int_entry (ptr_xfceresources, "Update_Interval",
                                                   60);
 
-        sensors->exec_command = xfce_rc_read_bool_entry (rc, "Exec_Command", TRUE);
+        ptr_sensors->exec_command = xfce_rc_read_bool_entry (ptr_xfceresources, "Exec_Command", TRUE);
 
-        sensors->show_units= xfce_rc_read_bool_entry (rc, "Show_Units", TRUE);
+        ptr_sensors->show_units= xfce_rc_read_bool_entry (ptr_xfceresources, "Show_Units", TRUE);
 
-        sensors->show_smallspacings= xfce_rc_read_bool_entry (rc, "Small_Spacings", FALSE);
+        ptr_sensors->show_smallspacings= xfce_rc_read_bool_entry (ptr_xfceresources, "Small_Spacings", FALSE);
 
-        if ((value = xfce_rc_read_entry (rc, "Command_Name", NULL)) && *value) {
-            g_free(sensors->command_name);
-            sensors->command_name = g_strdup (value);
+        if ((str_value = xfce_rc_read_entry (ptr_xfceresources, "Command_Name", NULL)) && *str_value) {
+            g_free(ptr_sensors->command_name);
+            ptr_sensors->command_name = g_strdup (str_value);
         }
 
-        if (!sensors->suppressmessage)
-            sensors->suppressmessage = xfce_rc_read_bool_entry (rc, "Suppress_Hddtemp_Message", FALSE);
+        if (!ptr_sensors->suppressmessage)
+            ptr_sensors->suppressmessage = xfce_rc_read_bool_entry (ptr_xfceresources, "Suppress_Hddtemp_Message", FALSE);
 
-        if (!sensors->suppresstooltip)
-            sensors->suppresstooltip = xfce_rc_read_bool_entry (rc, "Suppress_Tooltip", FALSE);
+        if (!ptr_sensors->suppresstooltip)
+            ptr_sensors->suppresstooltip = xfce_rc_read_bool_entry (ptr_xfceresources, "Suppress_Tooltip", FALSE);
 
-        sensors->preferred_width = xfce_rc_read_int_entry (rc, "Preferred_Width", 400);
-        sensors->preferred_height = xfce_rc_read_int_entry (rc, "Preferred_Height", 400);
+        ptr_sensors->preferred_width = xfce_rc_read_int_entry (ptr_xfceresources, "Preferred_Width", 400);
+        ptr_sensors->preferred_height = xfce_rc_read_int_entry (ptr_xfceresources, "Preferred_Height", 400);
 
-        //num_chips = xfce_rc_read_int_entry (rc, "Number_Chips", 0);
+        //num_chips = xfce_rc_read_int_entry (ptr_xfceresources, "Number_Chips", 0);
         /* or could use 1 or the always existent dummy entry */
     }
 
@@ -262,28 +262,25 @@ sensors_read_general_config (XfceRc *rc, t_sensors *sensors)
 
 
 void
-sensors_read_preliminary_config (XfcePanelPlugin *plugin, t_sensors *sensors)
+sensors_read_preliminary_config (XfcePanelPlugin *ptr_panelplugin, t_sensors *ptr_sensors)
 {
-    gchar *file;
-    XfceRc *rc;
+    gchar *str_file;
+    XfceRc *ptr_xfceresource;
 
     TRACE ("enters sensors_read_preliminary_config");
 
-    if (plugin==NULL)
-        return;
-
-    if (!(file = sensors->plugin_config_file))
-        return;
-
-    rc = xfce_rc_simple_open (file, TRUE);
-    g_free (file);
-
-    if (!rc)
-        return;
+    if (ptr_panelplugin)
+    {
+        if ((str_file = ptr_sensors->plugin_config_file))
+        {
+            ptr_xfceresource = xfce_rc_simple_open (str_file, TRUE);
+            g_free (str_file);
 
-    if (xfce_rc_has_group (rc, "General") ) {
-        xfce_rc_set_group (rc, "General");
-        sensors->suppressmessage = xfce_rc_read_bool_entry (rc, "Suppress_Hddtemp_Message", FALSE);
+            if (ptr_xfceresource && xfce_rc_has_group (ptr_xfceresource, "General") ) {
+                xfce_rc_set_group (ptr_xfceresource, "General");
+                ptr_sensors->suppressmessage = xfce_rc_read_bool_entry (ptr_xfceresource, "Suppress_Hddtemp_Message", FALSE);
+            }
+        }
     }
 
     TRACE ("leaves sensors_read_preliminary_config");
@@ -292,151 +289,143 @@ sensors_read_preliminary_config (XfcePanelPlugin *plugin, t_sensors *sensors)
 
 // TODO: modify to store chipname as indicator and access features by acpitz-1_Feature0 etc.
 // this will require differently storing the stuff as well.
-// targeted for 1.1 or 1.2 release
+// targeted for 1.3 or 1.4 release
 void
-sensors_read_config (XfcePanelPlugin *plugin, t_sensors *sensors)
+sensors_read_config (XfcePanelPlugin *ptr_panelplugin, t_sensors *ptr_sensors)
 {
-    const gchar *value;
-    gchar *file;
-    XfceRc *rc;
-    gint i, j, k;
-    gchar rc_chip[8], feature[20];
-    gchar* sensorName=NULL;
+    const gchar *str_value;
+    gchar *str_file;
+    XfceRc *ptr_xfceresource;
+    gint idx_chip, idx_feature, idx_chiptmp;
+    gchar str_rcchip[8], str_feature[20];
+    gchar* str_sensorname=NULL;
     gint num_sensorchip, id, address;
-    t_chip *chip;
-    t_chipfeature *chipfeature;
+    t_chip *ptr_chip;
+    t_chipfeature *ptr_chipfeature;
 
     TRACE ("enters sensors_read_config");
 
-    if (!(file = sensors->plugin_config_file))
+    if (!(str_file = ptr_sensors->plugin_config_file))
         return;
 
-    rc = xfce_rc_simple_open (file, TRUE);
-    g_free (file);
+    ptr_xfceresource = xfce_rc_simple_open (str_file, TRUE);
+    g_free (str_file);
 
-    if (!rc)
+    if (!ptr_xfceresource)
         return;
 
-    sensors_read_general_config (rc, sensors);
+    sensors_read_general_config (ptr_xfceresource, ptr_sensors);
 
-    for (i = 0; i<sensors->num_sensorchips; i++) {
+    for (idx_chip = 0; idx_chip<ptr_sensors->num_sensorchips; idx_chip++) {
 
-        g_snprintf (rc_chip, 8, "Chip%d", i);
+        g_snprintf (str_rcchip, 8, "Chip%d", idx_chip);
 
-        if (xfce_rc_has_group (rc, rc_chip)) {
+        if (xfce_rc_has_group (ptr_xfceresource, str_rcchip)) {
 
-            xfce_rc_set_group (rc, rc_chip);
+            xfce_rc_set_group (ptr_xfceresource, str_rcchip);
 
             num_sensorchip=0;
 
-            if ((value = xfce_rc_read_entry (rc, "Name", NULL)) && *value) {
-                sensorName = g_strdup (value);
+            if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "Name", NULL)) && *str_value) {
+                str_sensorname = g_strdup (str_value);
             }
 
-            num_sensorchip = (gint) xfce_rc_read_int_entry (rc, "Number", 0);
+            num_sensorchip = (gint) xfce_rc_read_int_entry (ptr_xfceresource, "Number", 0);
 
-            /* assert that file does not contain more information
+            /* assert that str_file does not contain more information
               than does exist on system */
               /* ??? At least, it works. */
-              //DBG("number of chip from file: %d, number of expected or known chips: %d.\n", num_sensorchip, sensors->num_sensorchips);
-            g_return_if_fail (num_sensorchip < sensors->num_sensorchips);
-            //DBG ("Success.\n");
+            g_return_if_fail (num_sensorchip < ptr_sensors->num_sensorchips);
 
             /* now featuring enhanced string comparison */
-            //g_assert (chip!=NULL);
-            k = 0;
+            idx_chiptmp = 0;
             do {
-              chip = (t_chip *) g_ptr_array_index (sensors->chips, k++);
-              if (chip==NULL || k==sensors->num_sensorchips)
+              ptr_chip = (t_chip *) g_ptr_array_index (ptr_sensors->chips, idx_chiptmp++);
+              if (ptr_chip==NULL || idx_chiptmp==ptr_sensors->num_sensorchips)
                   break;
-              }
-            while (chip!=NULL && sensorName != NULL && strcmp(chip->sensorId, sensorName) != 0 );
+            }
+            while (ptr_chip!=NULL && str_sensorname != NULL && strcmp(ptr_chip->sensorId, str_sensorname) != 0 );
 
-            if ( chip!=NULL && sensorName != NULL && strcmp(chip->sensorId, sensorName)==0 ) {
+            if ( ptr_chip!=NULL && str_sensorname != NULL && strcmp(ptr_chip->sensorId, str_sensorname)==0 ) {
 
-                for (j=0; j<chip->num_features; j++) {
-                    chipfeature = (t_chipfeature *) g_ptr_array_index (
-                                                        chip->chip_features,
-                                                        j);
-                    g_assert (chipfeature!=NULL);
+                for (idx_feature=0; idx_feature<ptr_chip->num_features; idx_feature++) {
+                    ptr_chipfeature = (t_chipfeature *) g_ptr_array_index (
+                                                        ptr_chip->chip_features,
+                                                        idx_feature);
+                    g_assert (ptr_chipfeature!=NULL);
 
-                    g_snprintf (feature, 20, "%s_Feature%d", rc_chip, j);
+                    g_snprintf (str_feature, 20, "%s_Feature%d", str_rcchip, idx_feature);
 
-                    if (xfce_rc_has_group (rc, feature)) {
-                        xfce_rc_set_group (rc, feature);
+                    if (xfce_rc_has_group (ptr_xfceresource, str_feature)) {
+                        xfce_rc_set_group (ptr_xfceresource, str_feature);
 
                         address=0;
 
-                        id = (gint) xfce_rc_read_int_entry (rc, "Id", 0);
-
-                        if ( strcmp(chip->sensorId, _("Hard disks")) != 0 )
-                            address = (gint) xfce_rc_read_int_entry (rc, "Address", 0);
-                        else
+                        id = (gint) xfce_rc_read_int_entry (ptr_xfceresource, "Id", 0);
 
-                         /* FIXME: compare strings, or also have hddtemp and acpi store numeric values */
+                        /* FIXME: compare strings, or also have hddtemp and acpi store numeric str_values */
 
-                        /* assert correctly saved file */
-                        if (strcmp(chip->sensorId, _("Hard disks")) != 0) { /* chip->name? */
-                            chipfeature = g_ptr_array_index(chip->chip_features, id);
+                        /* assert correctly saved str_file */
+                        if (strcmp(ptr_chip->sensorId, _("Hard disks")) != 0) { /* chip->name? */
+                            ptr_chipfeature = g_ptr_array_index(ptr_chip->chip_features, id);
+                            address = (gint) xfce_rc_read_int_entry (ptr_xfceresource, "Address", 0);
                             /* FIXME: it might be necessary to use sensors->addresses here */
-                            /* g_return_if_fail
-                                (chipfeature->address == address); */
-                            if (chipfeature->address != address)
+                            if (ptr_chipfeature->address != address)
                                 continue;
                         }
-                        else if ((value = xfce_rc_read_entry (rc, "DeviceName", NULL))
-                            && *value) {
-                            if (chipfeature->devicename)
-                                free (chipfeature->devicename);
-                            chipfeature->devicename = g_strdup(value);
-                            /* g_free (value); */
+                        else if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "DeviceName", NULL))
+                            && *str_value) {
+                            if (ptr_chipfeature->devicename)
+                                free (ptr_chipfeature->devicename);
+                            ptr_chipfeature->devicename = g_strdup(str_value);
+                            /* g_free (str_value); */
                         }
 
-                        if ((value = xfce_rc_read_entry (rc, "Name", NULL))
-                                && *value) {
-                            if (chipfeature->name)
-                                free (chipfeature->name);
-                            chipfeature->name = g_strdup (value);
-                            /* g_free (value); */
+                        if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "Name", NULL))
+                                && *str_value) {
+                            if (ptr_chipfeature->name)
+                                free (ptr_chipfeature->name);
+                            ptr_chipfeature->name = g_strdup (str_value);
+                            /* g_free (str_value); */
                         }
 
-                        if ((value = xfce_rc_read_entry (rc, "Color", NULL))
-                                && *value) {
-                            if (chipfeature->color)
-                                free (chipfeature->color);
-                            chipfeature->color = g_strdup (value);
-                            /* g_free (value); */
+                        if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "Color", NULL))
+                                && *str_value) {
+                            if (ptr_chipfeature->color)
+                                free (ptr_chipfeature->color);
+                            ptr_chipfeature->color = g_strdup (str_value);
+                            /* g_free (str_value); */
                         }
 
-                        chipfeature->show =
-                            xfce_rc_read_bool_entry (rc, "Show", FALSE);
+                        ptr_chipfeature->show =
+                            xfce_rc_read_bool_entry (ptr_xfceresource, "Show", FALSE);
 
-                        if ((value = xfce_rc_read_entry (rc, "Min", NULL))
-                                && *value)
-                            chipfeature->min_value = atof (value);
+                        if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "Min", NULL))
+                                && *str_value)
+                            ptr_chipfeature->min_value = atof (str_value);
 
-                        if ((value = xfce_rc_read_entry (rc, "Max", NULL))
-                                && *value)
-                            chipfeature->max_value = atof (value);
+                        if ((str_value = xfce_rc_read_entry (ptr_xfceresource, "Max", NULL))
+                                && *str_value)
+                            ptr_chipfeature->max_value = atof (str_value);
 
 
-                    } /* end if rc_grup has feature*/
+                    } /* end if rc_grup has str_feature*/
 
-                } /* end for features */
+                } /* end for str_features */
 
             } /* end if chip && strcmp */
 
-            if (sensorName != NULL)
-              g_free (sensorName);
+            if (str_sensorname != NULL)
+              g_free (str_sensorname);
 
-        } /* end if xfce_rc_has_group (rc, rc_chip) */
+        } /* end if xfce_rc_has_group (ptr_xfceresource, str_rcchip) */
 
     } /* end for num_sensorchips */
 
-    xfce_rc_close (rc);
+    xfce_rc_close (ptr_xfceresource);
 
-    if (!sensors->exec_command) {
-        g_signal_handler_block ( G_OBJECT(sensors->eventbox), sensors->doubleclick_id );
+    if (!ptr_sensors->exec_command) {
+        g_signal_handler_block ( G_OBJECT(ptr_sensors->eventbox), ptr_sensors->doubleclick_id );
     }
 
     TRACE ("leaves sensors_read_config");
diff --git a/lib/hddtemp.c b/lib/hddtemp.c
index 3f4f316..1c34f77 100644
--- a/lib/hddtemp.c
+++ b/lib/hddtemp.c
@@ -1,5 +1,5 @@
 /* $Id$ */
-/*  Copyright 2004-2010 Fabian Nowak (timystery at arcor.de)
+/*  Copyright 2004-2017 Fabian Nowak (timystery at arcor.de)
  *
  *  This program is free software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -72,105 +72,104 @@
 void notification_suppress_messages (NotifyNotification *n, gchar *action, gpointer *data);
 #endif
 
-void quick_message_notify (gchar *message);
-void quick_message (gchar *message);
-void quick_message_dialog (gchar *message);
-gboolean quick_message_with_checkbox (gchar *message, gchar *checkboxtext);
+void quick_message_notify (gchar *str_message);
+void quick_message (gchar *str_message);
+void quick_message_dialog (gchar *str_message);
+gboolean quick_message_with_checkbox (gchar *str_message, gchar *str_checkboxtext);
 
-void read_disks_netcat (t_chip *chip);
-void read_disks_linux26 (t_chip *chip);
-int get_hddtemp_d_str (char *buffer, size_t bufsize);
-void read_disks_fallback (t_chip *chip);
-void remove_unmonitored_drives (t_chip *chip, gboolean *suppressmessage);
-void populate_detected_drives (t_chip *chip);
+void read_disks_netcat (t_chip *ptr_chip);
+void read_disks_linux26 (t_chip *ptr_chip);
+int get_hddtemp_d_str (char *str_buffer, size_t siz_buffer);
+void read_disks_fallback (t_chip *ptr_chip);
+void remove_unmonitored_drives (t_chip *ptr_chip, gboolean *ptr_suppressmessage);
+void populate_detected_drives (t_chip *ptr_chip);
 
 #if defined(HAVE_LIBNOTIFY4) || defined(HAVE_LIBNOTIFY7)
 void
-notification_suppress_messages (NotifyNotification *n, gchar *action, gpointer *data)
+notification_suppress_messages (NotifyNotification *ptr_notification, gchar *str_action, gpointer *ptr_data)
 {
-    if (strcmp(action, "confirmed")!=0)
+    if (strcmp(str_action, "confirmed")!=0)
         return;
 
     /* FIXME: Use channels or propagate private object or use static global variable */
 }
 
 void
-quick_message_notify (gchar *message)
+quick_message_notify (gchar *str_message)
 {
-    NotifyNotification *nn;
-    gchar *summary, *body, *icon;
-    GError *error = NULL;
+    NotifyNotification *ptr_notification;
+    const gchar *str_summary, *str_icon;
+    GError *ptr_error = NULL;
 
-    summary = "Hddtemp Information";
-    body = message;
-    icon = "xfce-sensors";
+    str_summary = "Hddtemp Information";
+    str_icon = "xfce-sensors";
 
     if (!notify_is_initted())
         notify_init(PACKAGE); /* NOTIFY_APPNAME */
 
 #ifdef HAVE_LIBNOTIFY7
-    nn = notify_notification_new (summary, body, icon);
+    ptr_notification = notify_notification_new (str_summary, str_message, str_icon);
 #elif HAVE_LIBNOTIFY4
-    nn = notify_notification_new (summary, body, icon, NULL);
+    ptr_notification = notify_notification_new (str_summary, str_message, str_icon, NULL);
 #endif
     /* FIXME: Use channels or propagate private object or use static global variable */
-    //notify_notification_add_action (nn,
+    //notify_notification_add_action (ptr_notification,
                             //"confirmed",
                             //_("Don't show this message again"),
                             //(NotifyActionCallback) notification_suppress_messages,
                             //NULL);
-    notify_notification_show(nn, &error);
+    notify_notification_show(ptr_notification, &ptr_error);
 }
 #else
 void
-quick_message_dialog (gchar *message)
+quick_message_dialog (gchar *str_message)
 {
 
-    GtkWidget *dialog;  /*, *label; */
+    GtkWidget *ptr_dialog;  /*, *label; */
 
     TRACE ("enters quick_message");
 
-    dialog = gtk_message_dialog_new (NULL,
+    ptr_dialog = gtk_message_dialog_new (NULL,
                                   GTK_DIALOG_DESTROY_WITH_PARENT,
                                   GTK_MESSAGE_INFO,
                                   GTK_BUTTONS_CLOSE,
                                   message, NULL);
 
     g_signal_connect_swapped (dialog, "response",
-                             G_CALLBACK (gtk_widget_destroy), dialog);
+                             G_CALLBACK (gtk_widget_destroy), ptr_dialog);
 
-    gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_dialog_run(GTK_DIALOG(ptr_dialog));
 
     TRACE ("leaves quick_message");
 }
 
 
 gboolean
-quick_message_with_checkbox (gchar *message, gchar *checkboxtext) {
+quick_message_with_checkbox (gchar *str_message, gchar *str_checkboxtext) {
 
-    GtkWidget *dialog, *checkbox;  /*, *label; */
+    GtkWidget *ptr_dialog, *ptr_checkbox;  /*, *label; */
     gboolean is_active;
 
     TRACE ("enters quick_message");
 
-    dialog = gtk_message_dialog_new (NULL,
+    ptr_dialog = gtk_message_dialog_new (NULL,
                                   0, /* GTK_DIALOG_DESTROY_WITH_PARENT */
                                   GTK_MESSAGE_INFO,
                                   GTK_BUTTONS_CLOSE,
-                                  message, NULL);
+                                  str_message, NULL);
 
-    gtk_window_set_title(GTK_WINDOW(dialog), _("Sensors Plugin"));
+    gtk_window_set_title(GTK_WINDOW(ptr_dialog), _("Sensors Plugin"));
 
-    checkbox = gtk_check_button_new_with_mnemonic (checkboxtext);
+    ptr_checkbox = gtk_check_button_new_with_mnemonic (str_checkboxtext);
 
-    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(dialog)->vbox), checkbox, FALSE, FALSE, 0);
-    gtk_widget_show(checkbox);
+    gtk_box_pack_start (GTK_BOX(GTK_DIALOG(ptr_dialog)->vbox), ptr_checkbox, FALSE, FALSE, 0);
+    gtk_widget_show(ptr_checkbox);
 
-    gtk_dialog_run(GTK_DIALOG(dialog));
+    gtk_dialog_run(GTK_DIALOG(ptr_dialog));
 
-    is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(checkbox));
+    is_active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(ptr_checkbox));
 
-    gtk_widget_destroy (dialog);
+    gtk_widget_destroy (ptr_dialog);
 
     TRACE ("leaves quick_message");
 
@@ -180,73 +179,72 @@ quick_message_with_checkbox (gchar *message, gchar *checkboxtext) {
 
 
 void
-quick_message (gchar *message)
+quick_message (gchar *str_message)
 {
 #if defined(HAVE_LIBNOTIFY4) || defined(HAVE_LIBNOTIFY7)
-    quick_message_notify (message);
+    quick_message_notify (str_message);
 #else
-    quick_message_dialog (message);
+    quick_message_dialog (str_message);
 #endif
 }
 
 
 #ifdef HAVE_NETCAT
 void
-read_disks_netcat (t_chip *chip)
+read_disks_netcat (t_chip *ptr_chip)
 {
-    char reply[REPLY_MAX_SIZE], *tmp, *tmp2, *tmp3;
+    char str_reply[REPLY_MAX_SIZE], *str_tmp, *str_tmp2, *str_tmp3;
     int result;
 
-    t_chipfeature *cf;
+    t_chipfeature *ptr_chipfeature;
 
-    bzero(&reply, REPLY_MAX_SIZE);
-    result = get_hddtemp_d_str(reply, REPLY_MAX_SIZE);
-    DBG ("reply=%s with result=%d\n", reply, (int) result);
+    bzero(&str_reply, REPLY_MAX_SIZE);
+    result = get_hddtemp_d_str(str_reply, REPLY_MAX_SIZE);
+    DBG ("reply=%s with result=%d\n", str_reply, (int) result);
     if (result==-1)
     {
       return;
     }
 
-    tmp = str_split (reply, DOUBLE_DELIMITER);
+    str_tmp = str_split (str_reply, DOUBLE_DELIMITER);
     do {
-        //g_printf ("Found token: %s\n", tmp);
-        cf = g_new0(t_chipfeature, 1);
+        ptr_chipfeature = g_new0(t_chipfeature, 1);
 
-        tmp2 = g_strdup (tmp);
-        tmp3 = strtok (tmp2, SINGLE_DELIMITER);
-        cf->devicename = g_strdup(tmp3);
-        tmp3 = strtok (NULL, SINGLE_DELIMITER);
-        cf->name = g_strdup(tmp3);
+        str_tmp2 = g_strdup (str_tmp);
+        str_tmp3 = strtok (str_tmp2, SINGLE_DELIMITER);
+        ptr_chipfeature->devicename = g_strdup(str_tmp3);
+        str_tmp3 = strtok (NULL, SINGLE_DELIMITER);
+        ptr_chipfeature->name = g_strdup(str_tmp3);
 
-        g_ptr_array_add(chip->chip_features, cf);
-        chip->num_features++;
+        g_ptr_array_add(ptr_chip->chip_features, ptr_chipfeature);
+        ptr_chip->num_features++;
 
-        g_free (tmp2);
+        g_free (str_tmp2);
     }
-    while ( (tmp = str_split(NULL, DOUBLE_DELIMITER)) );
+    while ( (str_tmp = str_split(NULL, DOUBLE_DELIMITER)) );
 }
 #else
 void
 read_disks_fallback (t_chip *chip)
 {
-    GError *error;
-    GDir *gdir;
-    t_chipfeature *chipfeature;
-    const gchar* dirname;
+    GError *ptr_error;
+    GDir *ptr_dir;
+    t_chipfeature *ptr_chipfeature;
+    const gchar* str_devicename;
 
     TRACE ("enters read_disks_fallback");
 
     /* read from /proc/ide */
-    error = NULL;
-    gdir = g_dir_open ("/proc/ide/", 0, &error);
-
-    while ( (dirname = g_dir_read_name (gdir))!=NULL ) {
-        if ( strncmp (dirname, "hd", 2)==0 || strncmp (dirname, "sd", 2)==0) {
-            /* TODO: look, if /dev/dirname exists? */
-            chipfeature = g_new0 (t_chipfeature, 1);
-            chipfeature->devicename = g_strconcat ("/dev/", dirname, NULL);
-            chipfeature->name = g_strdup(chipfeature->devicename);
-            g_ptr_array_add (chip->chip_features, chipfeature);
+    ptr_error = NULL;
+    ptr_dir = g_dir_open ("/proc/ide/", 0, &ptr_error);
+
+    while ( (str_devicename = g_dir_read_name (ptr_dir))!=NULL ) {
+        if ( strncmp (str_devicename, "hd", 2)==0 || strncmp (str_devicename, "sd", 2)==0) {
+            /* TODO: look, if /dev/str_devicename exists? */
+            ptr_chipfeature = g_new0 (t_chipfeature, 1);
+            ptr_chipfeature->devicename = g_strconcat ("/dev/", str_devicename, NULL);
+            ptr_chipfeature->name = g_strdup(ptr_chipfeature->devicename);
+            g_ptr_array_add (chip->chip_features, ptr_chipfeature);
             chip->num_features++;
         }
     }
@@ -264,24 +262,24 @@ read_disks_linux26 (t_chip *chip)
 {
     GDir *gdir;
     t_chipfeature *chipfeature;
-    const gchar* dirname;
+    const gchar* str_devicename;
 
     TRACE ("enters read_disks_linux26");
 
     /* read from /sys/block */
     gdir = g_dir_open ("/sys/block/", 0, NULL);
-    while ( (dirname = g_dir_read_name (gdir))!=NULL ) {
-        /* if ( strncmp (dirname, "ram", 3)!=0 &&
-             strncmp (dirname, "loop", 4)!=0 &&
-             strncmp (dirname, "md", 2)!=0 &&
-             strncmp (dirname, "fd", 2)!=0 &&
-             strncmp (dirname, "mmc", 3)!=0 &&
-             strncmp (dirname, "dm-", 3)!=0 ) { */
-            if ( strncmp (dirname, "hd", 2)==0 ||
-                            strncmp (dirname, "sd", 2)==0 ) {
-            /* TODO: look, if /dev/dirname exists? */
+    while ( (str_devicename = g_dir_read_name (gdir))!=NULL ) {
+        /* if ( strncmp (str_devicename, "ram", 3)!=0 &&
+             strncmp (str_devicename, "loop", 4)!=0 &&
+             strncmp (str_devicename, "md", 2)!=0 &&
+             strncmp (str_devicename, "fd", 2)!=0 &&
+             strncmp (str_devicename, "mmc", 3)!=0 &&
+             strncmp (str_devicename, "dm-", 3)!=0 ) { */
+            if ( strncmp (str_devicename, "hd", 2)==0 ||
+                            strncmp (str_devicename, "sd", 2)==0 ) {
+            /* TODO: look, if /dev/str_devicename exists? */
             chipfeature = g_new0 (t_chipfeature, 1);
-            chipfeature->devicename = g_strconcat ("/dev/", dirname, NULL); /* /proc/ide/hda/model ?? */
+            chipfeature->devicename = g_strconcat ("/dev/", str_devicename, NULL); /* /proc/ide/hda/model ?? */
             chipfeature->name = g_strdup(chipfeature->devicename);
             g_ptr_array_add (chip->chip_features, chipfeature);
             chip->num_features++;
@@ -486,12 +484,13 @@ get_hddtemp_d_str (char *buffer, size_t bufsize)
 
     buffer[nbytes] = 0;
     close (sock);
+
     return nbytes;
 }
 
 
 double
-get_hddtemp_value (char* disk, gboolean *suppressmessage)
+get_hddtemp_value (char* str_disk, gboolean *ptr_suppressmessage)
 {
     gchar *ptr_str_stdout=NULL, *ptr_str_stderr=NULL;
     gchar *ptr_str_hddtemp_call=NULL, *ptr_str_message=NULL;
@@ -510,15 +509,15 @@ get_hddtemp_value (char* disk, gboolean *suppressmessage)
     int val_hddtemp_result;
 #endif
 
-    if (disk==NULL)
+    if (str_disk==NULL)
       return NO_VALID_TEMPERATURE_VALUE;
 
-    if (suppressmessage!=NULL)
-        f_nevershowagain = *suppressmessage;
+    if (ptr_suppressmessage!=NULL)
+        f_nevershowagain = *ptr_suppressmessage;
     else
         f_nevershowagain = FALSE;
 
-    TRACE ("enters get_hddtemp_value for %s with suppress=%d", disk, f_nevershowagain); /* *suppressmessage); */
+    TRACE ("enters get_hddtemp_value for %s with suppress=%d", str_disk, f_nevershowagain); /* *ptr_suppressmessage); */
 
 #ifdef HAVE_NETCAT
 
@@ -532,10 +531,9 @@ get_hddtemp_value (char* disk, gboolean *suppressmessage)
     tmp3 = "-255";
     tmp = str_split (reply, DOUBLE_DELIMITER);
     do {
-        //g_printf ("Found token: %s for disk %s\n", tmp, disk);
         tmp2 = g_strdup (tmp);
         tmp3 = strtok (tmp2, SINGLE_DELIMITER); // device name
-        if (strcmp(tmp3, disk)==0)
+        if (strcmp(tmp3, str_disk)==0)
         {
             strtok(NULL, SINGLE_DELIMITER); // name
             tmp3 = strdup(strtok(NULL, SINGLE_DELIMITER)); // value
@@ -551,15 +549,15 @@ get_hddtemp_value (char* disk, gboolean *suppressmessage)
     ptr_str_stdout = tmp3;
 
 #else
-    ptr_str_hddtemp_call = g_strdup_printf ( "%s -n -q %s", PATH_HDDTEMP, disk);
+    ptr_str_hddtemp_call = g_strdup_printf ( "%s -n -q %s", PATH_HDDTEMP, str_disk);
     f_result = g_spawn_command_line_sync ( (const gchar*) ptr_str_hddtemp_call,
             &ptr_str_stdout, &ptr_str_stderr, &exit_status, &ptr_f_error);
 #endif
 
-    DBG ("Exit code %d on %s with stdout of %s.\n", exit_status, disk, ptr_str_stdout);
+    DBG ("Exit code %d on %s with stdout of %s.\n", exit_status, str_disk, ptr_str_stdout);
 
     /* filter those with no sensors out */
-    if (exit_status==0 && strncmp(disk, "/dev/fd", 6)==0) { /* is returned for floppy disks */
+    if (exit_status==0 && strncmp(str_disk, "/dev/fd", 6)==0) { /* is returned for floppy disks */
         DBG("exit_status==0 && strncmp(disk, \"/dev/fd\", 6)==0");
         val_drive_temperature = NO_VALID_TEMPERATURE_VALUE;
     }
@@ -588,8 +586,8 @@ get_hddtemp_value (char* disk, gboolean *suppressmessage)
             f_nevershowagain = quick_message_with_checkbox(ptr_str_message, ptr_str_checkbutton);
 #endif
 
-            if (suppressmessage!=NULL)
-                *suppressmessage = f_nevershowagain;
+            if (ptr_suppressmessage!=NULL)
+                *ptr_suppressmessage = f_nevershowagain;
         }
         else {
             DBG  ("Suppressing dialog with exit_code=256 or output on ptr_str_stderr");
@@ -612,8 +610,8 @@ get_hddtemp_value (char* disk, gboolean *suppressmessage)
             f_nevershowagain = quick_message_with_checkbox (ptr_str_message, ptr_str_checkbutton);
 #endif
 
-            if (suppressmessage!=NULL)
-                *suppressmessage = f_nevershowagain;
+            if (ptr_suppressmessage!=NULL)
+                *ptr_suppressmessage = f_nevershowagain;
         }
         else {
             DBG  ("Suppressing dialog because of error in g_spawn_cl");
@@ -681,18 +679,3 @@ refresh_hddtemp (gpointer chip_feature, gpointer data)
 
     TRACE ("leaves refresh_hddtemp");
 }
-
-
-//void
-//free_hddtemp_chip (gpointer chip)
-//{
-    //t_chip *ptr_chip;
-
-    //ptr_chip = (t_chip *) chip;
-
-    ////if (ptr_chip->sensorId)
-        ////g_free (ptr_chip->sensorId);
-
-    ////if (ptr_chip->chip_name->)
-        ////g_free (ptr_chip->chip_name->);
-//}

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


More information about the Xfce4-commits mailing list