raster pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=beb6041646c2fe174ae4298f8d993771dc750030

commit beb6041646c2fe174ae4298f8d993771dc750030
Author: Carsten Haitzler (Rasterman) <ras...@rasterman.com>
Date:   Thu Aug 20 15:20:22 2020 +0100

    temp - bring back temp sesor select and nuke leaks on init
---
 src/modules/temperature/e_mod_config.c  | 23 ++++++++++++++++-------
 src/modules/temperature/e_mod_main.c    | 12 +++++++++---
 src/modules/temperature/e_mod_tempget.c | 21 ++++++++++-----------
 3 files changed, 35 insertions(+), 21 deletions(-)

diff --git a/src/modules/temperature/e_mod_config.c 
b/src/modules/temperature/e_mod_config.c
index 35e81a0ca..b83d7adaa 100644
--- a/src/modules/temperature/e_mod_config.c
+++ b/src/modules/temperature/e_mod_config.c
@@ -145,9 +145,12 @@ _fill_data_tempget(E_Config_Dialog_Data *cfdata)
                   EINA_LIST_FREE(l, name)
                     {
                        cfdata->sensors =
-                       eina_list_append(cfdata->sensors, name);
-                       if (!strcmp(cfdata->inst->sensor_name, name))
-                       cfdata->sensor = n;
+                         eina_list_append(cfdata->sensors, name);
+                       if (cfdata->inst->sensor_name)
+                         {
+                            if (!strcmp(cfdata->inst->sensor_name, name))
+                              cfdata->sensor = n;
+                         }
                        n++;
                     }
                }
@@ -167,9 +170,12 @@ _fill_data_tempget(E_Config_Dialog_Data *cfdata)
                        if (!strncmp(name, "thermal", 7))
                          {
                             cfdata->sensors =
-                            eina_list_append(cfdata->sensors, name);
-                            if (!strcmp(cfdata->inst->sensor_name, name))
-                            cfdata->sensor = n;
+                              eina_list_append(cfdata->sensors, name);
+                            if (cfdata->inst->sensor_name)
+                              {
+                                 if (!strcmp(cfdata->inst->sensor_name, name))
+                                   cfdata->sensor = n;
+                              }
                             n++;
                          }
                     }
@@ -209,7 +215,10 @@ _fill_sensors(E_Config_Dialog_Data *cfdata, const char 
*name)
      }
    EINA_LIST_FOREACH(cfdata->sensors, l, n)
      {
-        if (!strcmp(cfdata->inst->sensor_name, n)) break;
+        if (cfdata->inst->sensor_name)
+          {
+             if (!strcmp(cfdata->inst->sensor_name, n)) break;
+          }
         cfdata->sensor++;
      }
 }
diff --git a/src/modules/temperature/e_mod_main.c 
b/src/modules/temperature/e_mod_main.c
index dbd6e5547..765fc9fdf 100644
--- a/src/modules/temperature/e_mod_main.c
+++ b/src/modules/temperature/e_mod_main.c
@@ -123,7 +123,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, 
const char *style)
         inst->poll_interval = 128;
         inst->low = 30;
         inst->high = 80;
-        inst->sensor_type = SENSOR_TYPE_NONE;
+        inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
         inst->sensor_name = NULL;
         inst->temp = -900;
         inst->units = CELSIUS;
@@ -207,7 +207,7 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class 
EINA_UNUSED)
    inst->poll_interval = 128;
    inst->low = 30;
    inst->high = 80;
-   inst->sensor_type = SENSOR_TYPE_NONE;
+   inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
    inst->sensor_name = NULL;
    inst->units = CELSIUS;
    if (!temperature_config->faces)
@@ -271,16 +271,22 @@ _temperature_face_shutdown(const Eina_Hash *hash 
EINA_UNUSED, const void *key EI
 }
 
 static Eina_Bool
-_temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, 
void *hdata EINA_UNUSED, void *fdata)
+_temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, 
void *hdata, void *fdata)
 {
    const char *p;
    int *max;
    int num = -1;
+   Config_Face *cf = hdata;
 
    max = fdata;
    p = strrchr(key, '.');
    if (p) num = atoi(p + 1);
    if (num > *max) *max = num;
+#if defined (__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__)
+   cf->sensor_type = SENSOR_TYPE_FREEBSD;
+#else
+   cf->sensor_type = SENSOR_TYPE_LINUX_SYS;
+#endif
    return EINA_TRUE;
 }
 
diff --git a/src/modules/temperature/e_mod_tempget.c 
b/src/modules/temperature/e_mod_tempget.c
index 386d81769..50166f9dd 100644
--- a/src/modules/temperature/e_mod_tempget.c
+++ b/src/modules/temperature/e_mod_tempget.c
@@ -8,11 +8,11 @@
 #endif
 
 #ifdef __OpenBSD__
-#include <sys/param.h>
-#include <sys/sysctl.h>
-#include <sys/sensors.h>
-#include <errno.h>
-#include <err.h>
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# include <sys/sensors.h>
+# include <errno.h>
+# include <err.h>
 #endif
 
 typedef struct
@@ -163,11 +163,10 @@ init(Tempthread *tth)
              name = eina_list_data_get(therms);
              tth->sensor_type = SENSOR_TYPE_LINUX_ACPI;
              tth->sensor_name = eina_stringshare_add(name);
-             eina_list_free(therms);
+             EINA_LIST_FREE(therms, name) free(name);
           }
         else
           {
-             eina_list_free(therms);
              therms = ecore_file_ls("/sys/class/thermal");
              if (therms)
                {
@@ -185,9 +184,9 @@ init(Tempthread *tth)
                             break;
                          }
                     }
-                  if (therms) eina_list_free(therms);
+                  EINA_LIST_FREE(therms, name) free(name);
                }
-             if (therms)
+             else
                {
                   if (ecore_file_exists("/proc/omnibook/temperature"))
                     {
@@ -237,7 +236,7 @@ init(Tempthread *tth)
                                       tth->sensor_name = 
eina_stringshare_add(path);
                                    }
                               }
-                            eina_list_free(therms);
+                            EINA_LIST_FREE(therms, name) free(name);
                          }
                        if (!tth->sensor_path)
                          {
@@ -263,7 +262,7 @@ init(Tempthread *tth)
                                            tth->sensor_name = 
eina_stringshare_add(path);
                                         }
                                    }
-                                 eina_list_free(therms);
+                                 EINA_LIST_FREE(therms, name) free(name);
                               }
                          }
                     }

-- 


Reply via email to