From 2232685fe934caf698000813f6394b4e101c7d6c Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Thu, 22 Feb 2024 00:11:02 +0000 Subject: Deploy mate-desktop/mate-sensors-applet to github.com/mate-desktop/mate-sensors-applet.git:gh-pages --- .../0.html | 545 ++++ .../1.html | 489 ++++ .../10.html | 287 ++ .../11.html | 569 ++++ .../12.html | 287 ++ .../13.html | 679 +++++ .../14.html | 289 ++ .../15.html | 287 ++ .../16.html | 1179 ++++++++ .../17.html | 767 ++++++ .../18.html | 289 ++ .../19.html | 617 +++++ .../2.html | 287 ++ .../20.html | 287 ++ .../21.html | 681 +++++ .../22.html | 289 ++ .../23.html | 443 +++ .../24.html | 287 ++ .../25.html | 613 +++++ .../26.html | 287 ++ .../27.html | 591 ++++ .../28.html | 287 ++ .../29.html | 475 ++++ .../3.html | 479 ++++ .../30.html | 289 ++ .../31.html | 1143 ++++++++ .../32.html | 289 ++ .../33.html | 341 +++ .../34.html | 629 +++++ .../35.html | 365 +++ .../36.html | 445 +++ .../37.html | 389 +++ .../38.html | 1867 +++++++++++++ .../39.html | 357 +++ .../4.html | 289 ++ .../40.html | 335 +++ .../41.html | 2085 ++++++++++++++ .../42.html | 1905 +++++++++++++ .../43.html | 521 ++++ .../44.html | 1537 +++++++++++ .../45.html | 2911 ++++++++++++++++++++ .../5.html | 731 +++++ .../6.html | 287 ++ .../7.html | 685 +++++ .../8.html | 287 ++ .../9.html | 615 +++++ .../index.html | 445 +++ .../stats.html | 185 ++ .../style.css | 177 ++ 49 files changed, 30399 insertions(+) create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/0.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/1.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/10.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/11.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/12.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/13.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/14.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/15.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/16.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/17.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/18.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/19.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/2.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/20.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/21.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/22.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/23.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/24.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/25.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/26.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/27.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/28.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/29.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/3.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/30.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/31.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/32.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/33.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/34.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/35.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/36.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/37.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/38.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/39.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/4.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/40.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/41.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/42.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/43.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/44.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/45.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/5.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/6.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/7.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/8.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/9.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/index.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/stats.html create mode 100644 2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/style.css (limited to '2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master') diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/0.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/0.html new file mode 100644 index 0000000..a2d4c4d --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/0.html @@ -0,0 +1,545 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+extern const gchar *plugin_name;
+
+/* recursive function to find sensors in a given path */
+void sensors_applet_plugin_find_sensors(GList **sensors,
+                                        const gchar *path,
+                                        SensorsAppletPluginTestSensorFunc test_sensor) {
+    if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+        /* also test can actually open file for reading */
+        if (access(path, R_OK) == 0) {
+            test_sensor(sensors, path);
+        }
+    }
+
+    /* if is a directory (but not a symlinked dir as this
+       will lead us in circular loops) descend into it and look
+       for a sensor dir
+    */
+    if (g_file_test(path, G_FILE_TEST_IS_DIR) && !g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
+        GDir *dir;
+
+        if ((dir = g_dir_open(path, 0, NULL)) != NULL) {
+            const gchar *new_file;
+
+            while(NULL != (new_file = g_dir_read_name(dir))) {
+                gchar *new_path;
+
+                new_path = g_build_filename(path, new_file, NULL);
+                sensors_applet_plugin_find_sensors(sensors, new_path, test_sensor);
+                g_free(new_path);
+            }
+            g_dir_close(dir);
+        }
+    }
+}
+
+/* for error handling */
+GQuark sensors_applet_plugin_error_quark(void) {
+    static GQuark quark = 0;
+
+    if (quark == 0) {
+        gchar *string;
+
+        string = g_strdup_printf("%s-plugin-error", plugin_name);
+        quark = g_quark_from_string(string);
+        g_free(string);
+    }
+
+    return quark;
+}
+
+void sensors_applet_plugin_default_sensor_limits(SensorType type,
+                                                 gdouble *low_value,
+                                                 gdouble *high_value) {
+
+    switch (type) {
+    case TEMP_SENSOR:
+        *low_value = 20.0;
+        *high_value = 60.0;
+        break;
+    case FAN_SENSOR:
+        *low_value = 600.0;
+        *high_value = 3000.0;
+        break;
+    default:
+        *low_value = 0.0;
+        *high_value = 0.0;
+    }
+}
+
+void sensors_applet_plugin_add_sensor(GList **sensors,
+                                      const gchar *path,
+                                      const gchar *id,
+                                      const gchar *label,
+                                      SensorType type,
+                                      gboolean enable,
+                                      IconType icon,
+                                      const gchar *graph_color) {
+
+    gdouble low_value;
+    gdouble high_value;
+    sensors_applet_plugin_default_sensor_limits(type, &low_value, &high_value);
+
+    sensors_applet_plugin_add_sensor_with_limits(sensors,
+                                              path,
+                                              id,
+                                              label,
+                                              type,
+                                              enable,
+                                              low_value,
+                                              high_value,
+                                              icon,
+                                              graph_color);
+
+}
+
+void sensors_applet_plugin_add_sensor_with_limits(GList **sensors,
+                                                  const gchar *path,
+                                                  const gchar *id,
+                                                  const gchar *label,
+                                                  SensorType type,
+                                                  gboolean enable,
+                                                  gdouble low_value,
+                                                  gdouble high_value,
+                                                  IconType icon,
+                                                  const gchar *graph_color) {
+
+    SensorsAppletSensorInfo *info;
+
+    info = g_new0 (SensorsAppletSensorInfo, 1);
+
+    info->path = g_strdup(path);
+    info->id = g_strdup(id);
+    info->label = g_strdup(label);
+    info->type = type;
+    info->enable = enable;
+    info->low_value = low_value;
+    info->high_value = high_value;
+    info->multiplier = 1.0;
+    info->offset = 0.0;
+    info->icon = icon;
+    info->graph_color = g_strdup(graph_color);
+
+    *sensors = g_list_append(*sensors, info);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/1.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/1.html new file mode 100644 index 0000000..d662604 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/1.html @@ -0,0 +1,489 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "acpi-plugin.h"
+
+const gchar *plugin_name = "acpi";
+
+#define ACPI_THERMAL_ZONE_BASE_DIR "/proc/acpi/thermal_zone"
+#define ACPI_THERMAL_BASE_DIR "/proc/acpi/thermal"
+
+enum {
+    ACPI_DEVICE_FILE_OPEN_ERROR,
+    ACPI_DEVICE_FILE_READ_ERROR
+};
+
+static void acpi_plugin_add_sensor(GList **sensors, const gchar *path) {
+    gchar *dirname;
+    gchar *id;
+
+    dirname = g_path_get_dirname(path);
+    id = g_path_get_basename(dirname);
+    g_free(dirname);
+
+    sensors_applet_plugin_add_sensor(sensors,
+                                     path,
+                                     id,
+                                     _("CPU"),
+                                     TEMP_SENSOR,
+                                     TRUE,
+                                     CPU_ICON,
+                                     DEFAULT_GRAPH_COLOR);
+    g_free(id);
+}
+
+static void acpi_plugin_test_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    filename = g_path_get_basename(path);
+
+    if (g_ascii_strcasecmp(filename, "temperature") == 0 ||
+        g_ascii_strcasecmp(filename, "status") == 0) {
+            acpi_plugin_add_sensor(sensors, path);
+    }
+    g_free(filename);
+}
+
+/* to be called to setup for acpi sensors and returns the list of found sensors */
+static GList *acpi_plugin_init(void) {
+    GList *sensors = NULL;
+
+    /* call function to recursively look for sensors
+       starting at the defined base directory */
+    sensors_applet_plugin_find_sensors(&sensors, ACPI_THERMAL_ZONE_BASE_DIR, acpi_plugin_test_sensor);
+    sensors_applet_plugin_find_sensors(&sensors, ACPI_THERMAL_BASE_DIR, acpi_plugin_test_sensor);
+    return sensors;
+}
+
+static gdouble acpi_plugin_get_sensor_value(const gchar *path,
+                                            const gchar *id,
+                                            SensorType type,
+                                            GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat sensor_value = -1.0f;
+    gchar units[32];
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, ACPI_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return sensor_value;
+    }
+
+    if (fscanf(fp, "temperature: %f %31s", &sensor_value, units) < 1) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, ACPI_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+        fclose(fp);
+        return sensor_value;
+    }
+    fclose(fp);
+
+    /* need to convert if units are deciKelvin */
+    if (g_ascii_strcasecmp(units, "dK") == 0) {
+        sensor_value = (sensor_value / 10.0) - 273.0;
+    }
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return acpi_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return acpi_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/10.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/10.html new file mode 100644 index 0000000..124d3e6 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/10.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef I2C_SYS_PLUGIN_H
+#define I2C_SYS_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* I2C_SYS_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/11.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/11.html new file mode 100644 index 0000000..10717aa --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/11.html @@ -0,0 +1,569 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "i8k-plugin.h"
+
+const gchar *plugin_name = "i8k";
+
+#define I8K_DEVICE_PATH "/proc/i8k"
+#define I8K_DEVICE_FILE "i8k"
+
+enum {
+    I8K_DEVICE_FILE_OPEN_ERROR,
+    I8K_DEVICE_FILE_READ_ERROR
+};
+
+static void i8k_plugin_setup_manually(GList **sensors) {
+    if (g_file_test(I8K_DEVICE_PATH, G_FILE_TEST_EXISTS)) {
+        /* with i8k have only 3 fixed sensors, all accessed
+           from the I8K_DEVICE_PATH */
+        sensors_applet_plugin_add_sensor(sensors,
+                                         I8K_DEVICE_PATH,
+                                         "temp1",
+                                         _("CPU"),
+                                         TEMP_SENSOR,
+                                         TRUE,
+                                         CPU_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         I8K_DEVICE_PATH,
+                                         "fan1",
+                                         _("FAN1"),
+                                         FAN_SENSOR,
+                                         FALSE,
+                                         FAN_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         I8K_DEVICE_PATH,
+                                         "fan2",
+                                         _("FAN2"),
+                                         FAN_SENSOR,
+                                         FALSE,
+                                         FAN_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+    }
+}
+
+/* to be called externally to setup for i8k sensors */
+static GList *i8k_plugin_init(void) {
+    GList *sensors = NULL;
+
+    i8k_plugin_setup_manually(&sensors);
+
+    return sensors;
+}
+
+static
+gdouble i8k_plugin_get_sensor_value(const gchar *path,
+                                    const gchar *id,
+                                    SensorType type,
+                                    GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gint cpu_temp, fan1_status, fan2_status, fan1_rpm, fan2_rpm;
+    gint sensor_value;
+    gint space_count, file_length;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I8K_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+
+    space_count = 0;
+    file_length = 0;
+
+    /* count spaces but stop if have counted 100 characters and
+       still not found a space (to avoid infinite loop if file
+       format error) */
+    while (file_length < 100 && space_count < 3) {
+        if (fgetc(fp) == ' ') {
+            space_count++;
+        }
+        file_length++;
+    }
+
+    if (fscanf(fp, "%d %d %d %d %d", &cpu_temp, &fan1_status, &fan2_status, &fan1_rpm, &fan2_rpm) != 5) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I8K_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+        fclose(fp);
+        return -1.0;
+    }
+    fclose(fp);
+
+    switch (type) {
+        case TEMP_SENSOR:
+            sensor_value = cpu_temp;
+            break;
+
+        case FAN_SENSOR:
+            switch (id[3]) {
+                case '1':
+                    sensor_value = fan1_rpm;
+                    break;
+
+                case '2':
+                    sensor_value = fan2_rpm;
+                    break;
+
+                default:
+                    g_error("Error in i8k sensor get value function code for id %s", id);
+                    g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I8K_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                    return -1.0;
+            }
+            break;
+
+        default:
+            g_error("Unknown sensor type passed as parameter to i8k sensor interface, cannot get value for this sensor");
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I8K_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+            return -1.0;
+    } // end switch (sensor_type)
+
+    return (gdouble)sensor_value;
+
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return i8k_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return i8k_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/12.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/12.html new file mode 100644 index 0000000..b0e0d57 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/12.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef I8K_PLUGIN_H
+#define I8K_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* I8K_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/13.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/13.html new file mode 100644 index 0000000..2995117 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/13.html @@ -0,0 +1,679 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "ibm-acpi-plugin.h"
+
+const gchar *plugin_name = "ibm-acpi";
+
+#define IBM_ACPI_TEMPERATURE_FILE "/proc/acpi/ibm/thermal"
+#define IBM_ACPI_FAN_FILE "/proc/acpi/ibm/fan"
+
+/* sensor id's */
+#define CPU "CPU"
+#define MPCI "mPCI"
+#define HDD "HDD"
+#define GPU "GPU"
+#define BAT0 "BAT0"
+#define BAT1 "BAT1"
+#define FAN "FAN"
+
+enum {
+    IBM_ACPI_FILE_OPEN_ERROR,
+    IBM_ACPI_FILE_READ_ERROR
+};
+
+static void ibm_acpi_plugin_setup_manually(GList **sensors) {
+    if (g_file_test(IBM_ACPI_TEMPERATURE_FILE, G_FILE_TEST_EXISTS)) {
+        gchar *label;
+
+        /* with Ibm_Acpi have 8 fixed sensors, all accessed
+           from the IBM_ACPI_TEMPERATURE_FILE */
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         CPU,
+                                         _(CPU),
+                                         TEMP_SENSOR,
+                                         TRUE,
+                                         CPU_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         MPCI,
+                                         _("MiniPCI"),
+                                         TEMP_SENSOR,
+                                         FALSE,
+                                         GENERIC_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         HDD,
+                                         _(HDD),
+                                         TEMP_SENSOR,
+                                         FALSE,
+                                         HDD_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         GPU,
+                                         _(GPU),
+                                         TEMP_SENSOR,
+                                         FALSE,
+                                         GPU_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        label = g_strdup_printf("%s %d", _("Battery"), 0);
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         BAT0,
+                                         label,
+                                         TEMP_SENSOR,
+                                         FALSE,
+                                         BATTERY_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        g_free(label);
+
+        label = g_strdup_printf("%s %d", _("Battery"), 0);
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_TEMPERATURE_FILE,
+                                         BAT1,
+                                         label,
+                                         TEMP_SENSOR,
+                                         FALSE,
+                                         BATTERY_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+        g_free(label);
+    }
+
+    if (g_file_test(IBM_ACPI_FAN_FILE, G_FILE_TEST_EXISTS)) {
+        sensors_applet_plugin_add_sensor(sensors,
+                                         IBM_ACPI_FAN_FILE,
+                                         FAN,
+                                         _("Fan"),
+                                         FAN_SENSOR,
+                                         FALSE,
+                                         FAN_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+
+    }
+}
+
+/* to be called externally to setup for ibm_acpi sensors */
+static
+GList *ibm_acpi_plugin_init(void) {
+    GList *sensors = NULL;
+
+    ibm_acpi_plugin_setup_manually(&sensors);
+
+    return sensors;
+}
+
+static
+gdouble ibm_acpi_plugin_get_sensor_value(const gchar *path,
+                                         const gchar *id,
+                                         SensorType type,
+                                         GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gint sensor_value = 0;
+    gint cpu_temp, minipci_temp, hdd_temp, gpu_temp, bat0_temp, bat1_temp, unknown0, unknown1;
+    gint fan_speed;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, IBM_ACPI_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+
+    switch (type) {
+        case TEMP_SENSOR:
+            if (fscanf(fp, "temperatures:   %d %d %d %d %d %d %d %d", &cpu_temp, &minipci_temp, &hdd_temp, &gpu_temp, &bat0_temp, &unknown0, &bat1_temp, &unknown1) != 8) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, IBM_ACPI_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+
+            if (g_ascii_strcasecmp(id, CPU) == 0) {
+                sensor_value = cpu_temp;
+            } else if (g_ascii_strcasecmp(id, MPCI) == 0) {
+                sensor_value = minipci_temp;
+            } else if (g_ascii_strcasecmp(id, HDD) == 0) {
+                sensor_value = hdd_temp;
+            } else if (g_ascii_strcasecmp(id, GPU) == 0) {
+                sensor_value = gpu_temp;
+            } else if (g_ascii_strcasecmp(id, BAT0) == 0) {
+                sensor_value = bat0_temp;
+            } else if (g_ascii_strcasecmp(id, BAT1) == 0) {
+                sensor_value = bat1_temp;
+            }
+            break;
+
+        case FAN_SENSOR:
+            /*fscanf(fp, "%*[^\n]");*/   /* Skip to the End of the Line */
+            /*fscanf(fp, "%*1[\n]");*/   /* Skip One Newline */
+            if (fscanf(fp, "%*[^\n]%*1[\n]speed:   %d", &fan_speed) != 1) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, IBM_ACPI_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+
+            if (g_ascii_strcasecmp(id, "FAN") == 0) {
+                sensor_value = fan_speed;
+            }
+            break;
+
+        default:
+            g_error("Unknown sensor type passed as parameter to ibm-acpi sensor interface, cannot get value for this sensor");
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, IBM_ACPI_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+            fclose(fp);
+            return -1.0;
+    }
+
+    fclose(fp);
+
+    return (gdouble)sensor_value;
+
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return ibm_acpi_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return ibm_acpi_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/14.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/14.html new file mode 100644 index 0000000..e355f99 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/14.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef IBM_ACPI_PLUGIN_H
+#define IBM_ACPI_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* IBM_ACPI_PLUGIN_H */
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/15.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/15.html new file mode 100644 index 0000000..b81a2d0 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/15.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef LIBSENSORS_SENSORS_INTERFACE_H
+#define LIBSENSORS_SENSORS_INTERFACE_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* LIBSENSORS_SENSORS_INTERFACE_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/16.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/16.html new file mode 100644 index 0000000..c85c69d --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/16.html @@ -0,0 +1,1179 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_SENSORS_SENSORS_H
+#include <sensors/sensors.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "libsensors-plugin.h"
+
+const gchar *plugin_name = "libsensors";
+
+GHashTable *hash_table = NULL;
+
+enum {
+    LIBSENSORS_CHIP_PARSE_ERROR,
+    LIBSENSORS_MISSING_FEATURE_ERROR,
+    LIBSENSORS_REGEX_URL_COMPILE_ERROR,
+    LIBSENSORS_CHIP_NOT_FOUND_ERROR
+};
+
+#if SENSORS_API_VERSION < 0x400
+#define LIBSENSORS_CONFIG_FILE "/etc/sensors.conf"
+#define LIBSENSORS_ALTERNATIVE_CONFIG_FILE "/usr/local/etc/sensors.conf"
+#endif
+
+GRegex *uri_re;
+
+static char *get_chip_name_string(const sensors_chip_name *chip) {
+    char *name;
+
+#if SENSORS_API_VERSION < 0x400
+    /* taken from lm-sensors:prog/sensors/main.c:sprintf_chip_name */
+    switch (chip->bus) {
+        case SENSORS_CHIP_NAME_BUS_ISA:
+            name = g_strdup_printf ("%s-isa-%04x", chip->prefix, chip->addr);
+            break;
+        case SENSORS_CHIP_NAME_BUS_DUMMY:
+            name = g_strdup_printf ("%s-%s-%04x", chip->prefix, chip->busname, chip->addr);
+            break;
+            case SENSORS_CHIP_NAME_BUS_PCI:
+                    name = g_strdup_printf ("%s-pci-%04x", chip->prefix, chip->addr);
+                    break;
+        default:
+            name = g_strdup_printf ("%s-i2c-%d-%02x", chip->prefix, chip->bus, chip->addr);
+            break;
+    }
+
+#else
+/* adapted from lm-sensors:prog/sensors/main.c:sprintf_chip_name in lm-sensors-3.0 */
+#define BUF_SIZE 200
+    static char buf[BUF_SIZE];
+    if (sensors_snprintf_chip_name(buf, BUF_SIZE, chip) < 0) {
+        name = NULL;
+    } else {
+        name = g_strdup (buf);
+    }
+#endif
+
+    return name;
+}
+
+#if SENSORS_API_VERSION < 0x400
+static SensorType get_sensor_type (const char *name) {
+    SensorType type = CURRENT_SENSOR;
+
+    if (g_strrstr(name, "in")) {
+        type = VOLTAGE_SENSOR;
+    }
+    else if (g_strrstr(name, "fan")) {
+        type = FAN_SENSOR;
+    }
+    else if (g_strrstr(name, "temp")) {
+        type = TEMP_SENSOR;
+    } else {
+        g_debug("sensor %s not recognised as either voltage, fan or temp sensor - assuming is a current sensor", name);
+        type = CURRENT_SENSOR;
+    }
+    return type;
+}
+
+/* If a sensor is 'interesting' to us then return its label, otherwise NULL. */
+static char *get_sensor_interesting_label (sensors_chip_name chip, int feature) {
+    char *label;
+
+    if (sensors_get_ignored(chip, feature) && (sensors_get_label(chip, feature, &label) == 0)) {
+        if (! (strcmp ("alarms", label) == 0 || strncmp ("sensor", label, 6) == 0)) {
+            return label;
+        } else {
+            free (label);
+        }
+    }
+
+    return NULL;
+}
+
+static const sensors_feature_data * get_sensor_min_max(const sensors_chip_name *chip,
+                                                        int *n1, int *n2,
+                                                        int number,
+                                                        gdouble *low_value,
+                                                        gdouble *high_value) {
+
+    const sensors_feature_data *data;
+    double value;
+
+    /* The sub features are returned directly after the main feature by
+       sensors_get_all_features(), so no need to iterate over all features */
+    while ((data = sensors_get_all_features (*chip, n1, n2)) != NULL && data->mapping == number) {
+        if ((data->mode & SENSORS_MODE_R) && (sensors_get_feature(*chip, data->number, &value) == 0) && data->name != NULL) {
+
+            if (g_str_has_suffix(data->name, "_min")) {
+                *low_value = value;
+                g_debug("overriding low value of sensor %s with value %f", data->name, value);
+            } else if (g_str_has_suffix(data->name, "_max")) {
+                *high_value = value;
+                g_debug("overriding high value of sensor %s with value %f", data->name, value);
+            }
+        }
+    }
+    return data;
+}
+
+#endif
+
+static IconType get_sensor_icon (SensorType type) {
+    switch (type) {
+        case TEMP_SENSOR:
+            return CPU_ICON;
+        case FAN_SENSOR:
+            return FAN_ICON;
+        default:
+            return GENERIC_ICON;
+        }
+}
+
+#if SENSORS_API_VERSION < 0x400
+static void check_sensor_with_data(GList **sensors,
+                                   const char * const chip_name,
+                                   const sensors_chip_name *chip,
+                                   int *n1, int *n2,
+                                   const sensors_feature_data *data) {
+
+    char *label;
+    double value;
+    SensorsAppletSensorInfo *sensor_info = NULL;<--- Variable 'sensor_info' can be declared as pointer to const<--- Variable 'sensor_info' is assigned a value that is never used.
+
+    /* ... some of which are boring ... */
+    if ((label = get_sensor_interesting_label (*chip, data->number))) {
+        /* ... and some of which are actually sensors */
+        if ((data->mode & SENSORS_MODE_R) &&
+            (data->mapping == SENSORS_NO_MAPPING) &&
+            (sensors_get_feature(*chip, data->number, &value) == 0)) {    /* make sure we can actually get a value for it */
+
+            SensorType type;
+            gboolean visible;
+            IconType icon;
+            gdouble low_value, high_value;
+
+            gchar *url;
+
+            type = get_sensor_type (data->name);
+            visible = (type == TEMP_SENSOR ? TRUE : FALSE);
+            icon = get_sensor_icon(type);
+
+            /* the 'path' contains all the information we need to identify this sensor later */
+            url = g_strdup_printf ("sensor://%s/%d", chip_name, data->number);
+
+            /* get low and high values */
+            sensors_applet_plugin_default_sensor_limits(type, &low_value, &high_value);
+
+            data = get_sensor_min_max(chip, n1, n2, data->number, &low_value, &high_value);
+            if (data != NULL) {
+                /* try adding this one */
+                /* at this point we have called sensors_get_all_features() and stopped when we have a potential new sensor, so make sure we try this as well - do a recursive call */
+                check_sensor_with_data(sensors, chip_name, chip, n1, n2, data);
+            }
+
+            g_hash_table_insert(hash_table, g_strdup(url), (void *)chip);
+            /* the id identifies a particular sensor for the user; */
+            /* we default to the label returned by libsensors */
+            sensors_applet_plugin_add_sensor_with_limits(sensors,
+                                                         url,
+                                                         label,
+                                                         label,
+                                                         type,
+                                                         visible,
+                                                         low_value,
+                                                         high_value,
+                                                         icon,
+                                                         DEFAULT_GRAPH_COLOR);
+            g_free(url);
+        }
+        free (label);
+    }
+
+}
+
+#endif
+
+static GList *libsensors_plugin_get_sensors(void) {
+    const sensors_chip_name *chip_name;
+    GList *sensors = NULL;
+
+#if SENSORS_API_VERSION < 0x400
+    FILE *file;
+    int i;
+    g_debug("%s: using libsensors version < 4", __FUNCTION__);
+
+    /* try to open config file, otherwise try alternate config
+     * file - if neither succeed, exit */
+    if ((file = fopen (LIBSENSORS_CONFIG_FILE, "r")) == NULL) {
+        if ((file = fopen (LIBSENSORS_ALTERNATIVE_CONFIG_FILE, "r")) == NULL) {
+            g_debug("%s: error opening libsensors config file... ", __FUNCTION__);
+            return sensors;
+        }
+    }
+
+    /* at this point should have an open config file, if is not
+     * valid, close file and return */
+    if (sensors_init(file) != 0) {
+        fclose(file);
+        g_debug("%s: error initing libsensors from config file...", __FUNCTION__);
+        return sensors;
+    }
+    fclose(file);
+
+    /* libsensors exposes a number of chips -  ... */
+    i = 0;
+    while ((chip_name = sensors_get_detected_chips (&i)) != NULL) {
+        char *chip_name_string;
+        const sensors_feature_data *data;
+        int n1 = 0, n2 = 0;
+
+        chip_name_string = get_chip_name_string(chip_name);
+
+        /* ... each of which has one or more 'features' ... */
+        while ((data = sensors_get_all_features (*chip_name, &n1, &n2)) != NULL) { /* error */
+            /* fill in list for us */
+            check_sensor_with_data(&sensors, chip_name_string, chip_name, &n1, &n2, data);
+        }
+        g_free (chip_name_string);
+    }
+
+#else
+    g_debug("%s: using libsensors version >= 4", __FUNCTION__);
+
+    int nr = 0;
+    if (sensors_init(NULL) != 0) {
+        g_debug("%s: error initing libsensors", __FUNCTION__);
+        return sensors;
+    }
+
+    while ((chip_name = sensors_get_detected_chips(NULL, &nr))) {
+
+        char *chip_name_string, *label;
+        const sensors_subfeature *input_feature;
+        const sensors_subfeature *low_feature;
+        const sensors_subfeature *high_feature;
+        const sensors_feature *main_feature;
+        SensorType type;
+        gint nr1 = 0;
+        gdouble value, low, high;
+        gchar *path;
+        gboolean visible;
+        IconType icon;
+
+        chip_name_string = get_chip_name_string(chip_name);
+        if (chip_name_string == NULL) {
+            g_debug("%s: %d: error getting name string for sensor: %s\n", __FILE__, __LINE__, chip_name->path);
+            continue;
+        }
+
+        while ((main_feature = sensors_get_features(chip_name, &nr1))) {
+            switch (main_feature->type) {
+                case SENSORS_FEATURE_IN:
+                    type = VOLTAGE_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_MIN);
+                    high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_IN_MAX);
+                    break;
+
+                case SENSORS_FEATURE_FAN:
+                    type = FAN_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_FAN_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_FAN_MIN);
+                    /* no fan max feature */
+                    high_feature = NULL;
+                    break;
+
+                case SENSORS_FEATURE_TEMP:
+                    type = TEMP_SENSOR;
+                    input_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_INPUT);
+                    low_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_MIN);
+                    high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_MAX);
+                    if (!high_feature)
+                        high_feature = sensors_get_subfeature(chip_name, main_feature, SENSORS_SUBFEATURE_TEMP_CRIT);
+                    break;
+
+                default:
+                    g_debug("%s: %d: error determining type for: %s\n", __FILE__, __LINE__, chip_name_string);
+                    continue;
+            }
+
+            if (!input_feature) {
+                g_debug("%s: %d: could not get input subfeature for: %s\n", __FILE__, __LINE__, chip_name_string);
+                continue;
+            }
+
+            /* if still here we got input feature so get label */
+            label = sensors_get_label(chip_name, main_feature);
+            if (!label) {
+                g_debug("%s: %d: error: could not get label for: %s\n", __FILE__, __LINE__, chip_name_string);
+                continue;
+            }
+
+            g_assert(chip_name_string && label);
+
+            icon = get_sensor_icon(type);
+            visible = (type == TEMP_SENSOR ? TRUE : FALSE);
+            sensors_applet_plugin_default_sensor_limits(type, &low, &high);
+            if (low_feature) {
+                sensors_get_value(chip_name, low_feature->number, &low);
+            }
+
+            if (high_feature) {
+                sensors_get_value(chip_name, high_feature->number, &high);
+            }
+
+            if (sensors_get_value(chip_name, input_feature->number, &value) < 0) {
+                g_debug("%s: %d: error: could not get value for input feature of sensor: %s\n", __FILE__, __LINE__, chip_name_string);
+                free(label);
+                continue;
+            }
+
+            g_debug("for chip %s (type %s) got label %s and value %f", chip_name_string,
+                (type == TEMP_SENSOR ? "temp" : (type == FAN_SENSOR ? "fan" : (type == VOLTAGE_SENSOR ? "voltage" : "error"))), label, value);
+
+            path = g_strdup_printf ("sensor://%s/%d", chip_name_string, input_feature->number);
+            g_hash_table_insert(hash_table, g_strdup(path), (void *)chip_name);
+
+            sensors_applet_plugin_add_sensor_with_limits(&sensors,
+                                                         path,
+                                                         label,
+                                                         label,
+                                                         type,
+                                                         visible,
+                                                         low,
+                                                         high,
+                                                         icon,
+                                                         DEFAULT_GRAPH_COLOR);
+        }
+        g_free(chip_name_string);
+
+    }
+#endif
+
+    return sensors;
+}
+
+static gdouble libsensors_plugin_get_sensor_value(const gchar *path,
+                                                    const gchar *id,
+                                                    SensorType type,
+                                                    GError **error) {
+    gdouble result = 0;
+    GMatchInfo *m;
+
+    /* parse the uri into a (chip, feature) tuplet */
+    g_regex_match (uri_re, path, 0, &m);
+    if (g_match_info_matches (m)) {
+        const sensors_chip_name *found_chip;
+        int feature;
+
+        if ((found_chip = g_hash_table_lookup(hash_table, path)) != NULL) {
+            gdouble value;
+            gchar *feature_str;
+
+            feature_str = g_match_info_fetch (m, 1);
+            feature = atoi(feature_str);
+            g_free (feature_str);
+
+#if SENSORS_API_VERSION < 0x400
+            /* retrieve the value of the feature */
+            if (sensors_get_feature (*found_chip, feature, &value) == 0) {
+                result = value;
+            } else {
+                g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_MISSING_FEATURE_ERROR, "Error retrieving sensor value");
+            }
+#else
+            if (sensors_get_value(found_chip, feature, &value) >= 0) {
+                result = value;
+            } else {
+                g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_MISSING_FEATURE_ERROR, "Error retrieving sensor value");
+            }
+#endif
+
+        } else {
+            g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_CHIP_NOT_FOUND_ERROR, "Chip not found");
+        }
+    } else {
+        g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, LIBSENSORS_REGEX_URL_COMPILE_ERROR, "Error compiling URL regex: Not match");
+    }
+    g_match_info_free (m);
+    return result;
+}
+
+static GList *libsensors_plugin_init(void) {
+    GError *err = NULL;
+
+    /* compile the regular expressions */
+    uri_re = g_regex_new ("^sensor://[a-z0-9_-]+/([0-9]+)$", G_REGEX_CASELESS | G_REGEX_OPTIMIZE, G_REGEX_MATCH_ANCHORED, &err);
+    if (err) {
+        g_debug("Error compiling regexp: %s\nnot initing libsensors sensors interface", err->message);
+        g_error_free (err);
+        return NULL;
+    }
+
+    /* create hash table to associate path strings with sensors_chip_name
+     * pointers - make sure it free's the keys strings on destroy */
+    hash_table = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+    return libsensors_plugin_get_sensors();
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return libsensors_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return libsensors_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/17.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/17.html new file mode 100644 index 0000000..abe503c --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/17.html @@ -0,0 +1,767 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
/*
+ * Copyright (C) 2010 Daniele Napolitano <dnax88@gmail.com>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "mbmon-plugin.h"
+
+const gchar *plugin_name = "mbmon";
+
+#define MBMON_SERVER_IP_ADDRESS "127.0.0.1"
+#define MBMON_PORT_NUMBER 411
+#define MBMON_OUTPUT_BUFFER_LENGTH 1024
+
+enum {
+    MBMON_SOCKET_OPEN_ERROR,
+    MBMON_SOCKET_CONNECT_ERROR,
+    MBMON_GIOCHANNEL_ERROR,
+    MBMON_GIOCHANNEL_READ_ERROR
+};
+
+static const gchar *mbmon_plugin_query_mbmon_daemon(GError **error) {
+    static gboolean first_run = FALSE;
+    gint output_length = 0;
+    gchar *pc;
+
+    struct sockaddr_in address;
+    static char* buffer = NULL;
+    static gint64 previous_query_time;
+    gint64 current_query_time;
+
+    if (NULL == buffer) {
+        /* initialise buffer and current time */
+        buffer = g_new0(char, MBMON_OUTPUT_BUFFER_LENGTH);
+        previous_query_time = g_get_monotonic_time ();
+        first_run = TRUE;
+    }
+    current_query_time = g_get_monotonic_time ();
+
+    /* only query if more than 2 seconds has elapsed,
+    mbmon daemon will send a new value every 2 seconds */
+    if (first_run || current_query_time - previous_query_time > 2 * G_TIME_SPAN_SECOND) {
+        int sockfd;
+        ssize_t n;
+
+        previous_query_time = current_query_time;
+
+        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
+            /* couldn't open socket */
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, MBMON_SOCKET_OPEN_ERROR, "Error opening socket for mbmon");
+            return NULL;
+        }
+
+        address.sin_family = AF_INET;
+        address.sin_addr.s_addr = inet_addr(MBMON_SERVER_IP_ADDRESS);
+        address.sin_port = htons(MBMON_PORT_NUMBER);
+
+        if (connect(sockfd, (struct sockaddr *)&address, (socklen_t)sizeof(address)) == -1) {
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, MBMON_SOCKET_CONNECT_ERROR, "Error connecting to mbmon daemon on port %i on %s", htons(MBMON_PORT_NUMBER), MBMON_SERVER_IP_ADDRESS);
+            return NULL;
+        }
+
+        pc = buffer;
+        while ((n = read(sockfd, pc, MBMON_OUTPUT_BUFFER_LENGTH - output_length)) > 0) {
+            output_length += n;
+            pc = &pc[n];
+        }
+        /* always null terminate the end of the buffer
+         * regardless of how much stuff is in it already */
+        buffer[output_length] = '\0';
+        close(sockfd);
+    }
+
+    return buffer;
+}
+
+static SensorType get_sensor_type (const char *name) {
+    SensorType type = CURRENT_SENSOR;
+
+    if (g_strrstr(name, "FAN")) {
+        type = FAN_SENSOR;
+    } else if (g_strrstr(name, "TEMP")) {
+        type = TEMP_SENSOR;
+    } else {
+        type = VOLTAGE_SENSOR;
+    }
+    return type;
+}
+
+static IconType get_sensor_icon (SensorType type) {
+    switch (type) {
+        case TEMP_SENSOR:
+            return CPU_ICON;
+        case FAN_SENSOR:
+            return FAN_ICON;
+        default:
+            return GENERIC_ICON;
+    }
+}
+
+static void mbmon_plugin_get_sensors(GList **sensors) {
+
+    GError *error = NULL;
+    const gchar *mbmon_output;
+    gchar **output_vector = NULL, **pv;
+
+    mbmon_output = mbmon_plugin_query_mbmon_daemon(&error);
+
+    if (error) {
+        g_error_free(error);
+        return;
+    }
+
+    pv = output_vector = g_strsplit(mbmon_output, "\n", -1);
+
+    while(pv[0] != NULL) {
+        gchar **pv2;
+
+        pv2 = g_strsplit(pv[0], ":", -1);
+        gchar *name, *label;
+        SensorType type;
+        gboolean visible;
+        IconType icon;
+        gdouble low_value, high_value;
+
+        type = get_sensor_type(pv2[0]);
+        icon = get_sensor_icon(type);
+        name = g_strstrip(pv2[0]);
+        label = NULL;
+        visible = (type == TEMP_SENSOR ? TRUE : FALSE);
+
+        if(type == VOLTAGE_SENSOR) {
+            if(g_strrstr(name, "VC0")) {
+                label = g_strdup("Core Voltage 1");
+            } else if(g_strrstr(name, "VC1")) {
+                label = g_strdup("Core Voltage 2");
+            } else if(g_strrstr(name, "V33")) {
+                label = g_strdup("+3.3v Voltage");
+            } else if(g_strrstr(name, "V50P")) {
+                label = g_strdup("+5v Voltage");
+            } else if(g_strrstr(name, "V12P")) {
+                label = g_strdup("+12v Voltage");
+            } else if(g_strrstr(name, "V12N")) {
+                label = g_strdup("-12v Voltage");
+            } else if(g_strrstr(name, "V50N")) {
+                label = g_strdup("-5v Voltage");
+            }
+        }
+
+        label = (label == NULL ? name : label);
+
+        sensors_applet_plugin_default_sensor_limits(type, &low_value, &high_value);
+
+        sensors_applet_plugin_add_sensor_with_limits(sensors,
+                                                     name,
+                                                     name,
+                                                     label,
+                                                     type,
+                                                     visible,
+                                                     low_value,
+                                                     high_value,
+                                                     icon,
+                                                     DEFAULT_GRAPH_COLOR);
+
+        g_strfreev(pv2);
+        pv++;
+    }
+    g_strfreev(output_vector);
+
+}
+
+/* to be called to setup for mbmon sensors */
+static GList *mbmon_plugin_init(void) {
+    GList *sensors = NULL;
+    mbmon_plugin_get_sensors(&sensors);
+    return sensors;
+}
+
+/* returns the value of the sensor_list at the given iter, or if an
+   error occurs, instatiates error with an error message */
+static gdouble mbmon_plugin_get_sensor_value(const gchar *path,
+                                            const gchar *id,
+                                            SensorType type,
+                                            GError **error) {
+
+    const gchar *mbmon_output;
+    gchar **output_vector = NULL, **pv, **pv2;
+
+    gfloat sensor_value = -1.0f;
+
+    mbmon_output = mbmon_plugin_query_mbmon_daemon(error);
+
+    if (*error) {
+        return sensor_value;
+    }
+
+    pv = output_vector = g_strsplit(mbmon_output, "\n", -1);
+
+    while(pv[0] != NULL) {
+        if (g_strrstr(pv[0], path) != NULL) {
+
+            pv2 = g_strsplit(pv[0], ":", -1);
+            sensor_value = (gfloat)(g_ascii_strtod(pv2[1], NULL));
+            g_strfreev(pv2);
+            break;
+        }
+        pv++;
+    }
+    g_strfreev(output_vector);
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return mbmon_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return mbmon_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/18.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/18.html new file mode 100644 index 0000000..9a42ab0 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/18.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2010 Daniele Napolitano <dnax88@gmail.com>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#ifndef MBMON_PLUGIN_H
+#define MBMON_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* MBMON_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/19.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/19.html new file mode 100644 index 0000000..787a4f5 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/19.html @@ -0,0 +1,617 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
/*
+ * Copyright (C) 2018 Jared McNeill <jmcneill@invisible.ca>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <prop/proplib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/envsys.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "netbsd-plugin.h"
+
+static int sysmon_fd = -1;
+
+static gdouble netbsd_plugin_get_sensor_value(const gchar *path,
+					      const gchar *id,
+					      SensorType type,
+					      GError **error) {
+
+	prop_dictionary_t dict;
+	prop_array_t array;
+	prop_object_iterator_t iter, siter;
+	prop_object_t obj, sobj;
+	const gchar *desc = NULL, *state = NULL;
+	gdouble sensor_val = -1.0f;
+	int64_t val;
+
+	if (prop_dictionary_recv_ioctl(sysmon_fd, ENVSYS_GETDICTIONARY, &dict) == -1)
+		return sensor_val;
+
+	iter = prop_dictionary_iterator(dict);
+	while ((obj = prop_object_iterator_next(iter)) != NULL) {
+		if (strcmp(path, prop_dictionary_keysym_cstring_nocopy(obj)) != 0)
+			continue;
+
+		array = prop_dictionary_get_keysym(dict, obj);
+		siter = prop_array_iterator(array);
+		while ((sobj = prop_object_iterator_next(siter)) != NULL) {
+			if (prop_dictionary_get_cstring_nocopy(sobj, "description", &desc) == false)
+				continue;
+			if (strcmp(id, desc) != 0)
+				continue;
+
+			prop_dictionary_get_cstring_nocopy(sobj, "state", &state);
+			prop_dictionary_get_int64(sobj, "cur-value", &val);
+
+			if (strcmp(state, "valid") == 0) {
+				switch (type) {
+				case TEMP_SENSOR:
+					/* K to C */
+					sensor_val = ((val - 273150000) / 1000000.0);
+					break;
+				case FAN_SENSOR:
+					/* RPM */
+					sensor_val = (gdouble)val;
+					break;
+				case VOLTAGE_SENSOR:
+					/* uV to V */
+					sensor_val = val / 1000000.0;
+					break;
+				default:
+					break;
+				}
+			}
+			break;
+		}
+		prop_object_iterator_release(siter);
+		break;
+	}
+	prop_object_iterator_release(iter);
+
+	prop_object_release(dict);
+
+	return sensor_val;
+}
+
+static IconType netbsd_plugin_get_sensor_icon(const gchar *desc) {
+	IconType icontype = GENERIC_ICON;
+
+	if (strcasestr(desc, "cpu") != NULL)
+		icontype = CPU_ICON;
+	else if (strcasestr(desc, "gpu") != NULL)
+		icontype = GPU_ICON;
+	else if (strcasestr(desc, "batt") != NULL)
+		icontype = BATTERY_ICON;
+	else if (strcasestr(desc, "mem") != NULL)
+		icontype = MEMORY_ICON;
+	else if (strcasestr(desc, "disk") != NULL || strcasestr(desc, "hdd") != NULL)
+		icontype = HDD_ICON;
+
+	return icontype;
+}
+
+static void netbsd_plugin_get_sensors(GList **sensors) {
+	prop_dictionary_t dict;
+	prop_array_t array;
+	prop_object_iterator_t iter, siter;
+	prop_object_t obj, sobj;
+
+	sysmon_fd = open("/dev/sysmon", O_RDONLY);
+	if (sysmon_fd == -1)
+		return;
+
+	if (prop_dictionary_recv_ioctl(sysmon_fd, ENVSYS_GETDICTIONARY, &dict) == -1) {
+		close(sysmon_fd);
+		return;
+	}
+
+	iter = prop_dictionary_iterator(dict);
+	while ((obj = prop_object_iterator_next(iter)) != NULL) {
+		const gchar *path = prop_dictionary_keysym_cstring_nocopy(obj);
+		array = prop_dictionary_get_keysym(dict, obj);
+		siter = prop_array_iterator(array);
+		while ((sobj = prop_object_iterator_next(siter)) != NULL) {
+			const gchar *type = NULL, *desc = NULL;
+			if (prop_dictionary_get_cstring_nocopy(sobj, "type", &type) == false)
+				continue;
+			if (prop_dictionary_get_cstring_nocopy(sobj, "description", &desc) == false)
+				continue;
+
+			SensorType sensortype;
+			if (strcmp(type, "Fan") == 0)
+				sensortype = FAN_SENSOR;
+			else if (strcmp(type, "Temperature") == 0)
+				sensortype = TEMP_SENSOR;
+			else if (strcmp(type, "Voltage AC") == 0 || strcmp(type, "Voltage DC") == 0)
+				sensortype = VOLTAGE_SENSOR;
+			else
+				continue;
+
+			IconType icontype = netbsd_plugin_get_sensor_icon(desc);
+
+			sensors_applet_plugin_add_sensor(sensors,
+							 g_strdup(path),
+							 g_strdup(desc),
+							 g_strdup(desc),
+							 sensortype,
+							 TRUE,
+							 icontype,
+							 DEFAULT_GRAPH_COLOR);
+		}
+		prop_object_iterator_release(siter);
+	}
+	prop_object_iterator_release(iter);
+
+	prop_object_release(dict);
+}
+
+static GList *netbsd_plugin_init(void) {
+	GList *sensors = NULL;
+
+	netbsd_plugin_get_sensors(&sensors);
+
+	return sensors;
+}
+
+/* API functions */
+const gchar *sensors_applet_plugin_name(void) {
+	return "netbsd";
+}
+
+GList *sensors_applet_plugin_init(void) {
+	return netbsd_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+					       const gchar *id,
+					       SensorType type,
+					       GError **error) {
+
+	return netbsd_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/2.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/2.html new file mode 100644 index 0000000..a6353a5 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/2.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef ACPI_PLUGIN_H
+#define ACPI_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* ACPI_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/20.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/20.html new file mode 100644 index 0000000..d49c813 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/20.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2018 Jared McNeill <jmcneill@invisible.ca>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef NETBSD_PLUGIN_H
+#define NETBSD_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* NETBSD_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/21.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/21.html new file mode 100644 index 0000000..b4dcac4 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/21.html @@ -0,0 +1,681 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
/*
+ * Copyright (C) 2006 Sven Peter <svpe@gmx.net>
+ * Copyright (C) 2006 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <X11/Xlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <NVCtrl/NVCtrl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <NVCtrl/NVCtrlLib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "nvidia-plugin.h"
+
+const gchar *plugin_name = "nvidia";
+
+#define THERMAL_SENSOR_TEMP "SensorTemp"
+#define THERMAL_COOLER_LEVEL "CoolerLevel"
+#define GPU_CORE_TEMP "CoreTemp"
+#define AMBIENT_TEMP "AmbientTemp"
+
+/* global variables */
+Display *nvidia_sensors_dpy; /* the connection to the X server */
+
+/* returns the value of the sensor */
+static gdouble nvidia_plugin_get_sensor_value(const gchar *path,
+                                              const gchar *id,
+                                              SensorType type,
+                                              GError **error) {
+
+    Bool res;
+    int temp;
+    int i;
+
+    i = g_ascii_strtoll(id + strlen("GPU"), NULL, 10);
+    if (g_ascii_strcasecmp(path, THERMAL_SENSOR_TEMP) == 0) {
+        res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                          NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
+                          i,
+                          0,
+                          NV_CTRL_THERMAL_SENSOR_READING,
+                          &temp);
+
+    } else if (g_ascii_strcasecmp(path, THERMAL_COOLER_LEVEL) == 0) {
+        res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                          NV_CTRL_TARGET_TYPE_COOLER,
+                          i,
+                          0,
+                          NV_CTRL_THERMAL_COOLER_LEVEL,
+                          &temp);
+
+    } else if (g_ascii_strcasecmp(path, GPU_CORE_TEMP) == 0) {
+        res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                          NV_CTRL_TARGET_TYPE_GPU,
+                          i,
+                          0,
+                          NV_CTRL_GPU_CORE_TEMPERATURE,
+                          &temp);
+
+    } else if (g_ascii_strcasecmp(path, AMBIENT_TEMP) == 0) {
+        res = XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                          NV_CTRL_TARGET_TYPE_GPU,
+                          i,
+                          0,
+                          NV_CTRL_AMBIENT_TEMPERATURE,
+                          &temp);
+
+    } else {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Invalid path string passed to nvidia_plugin_get_sensor_value");
+        return 0;
+    }
+
+    if (res != True) {
+        /* when res isn't true something went wrong */
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, 0, "XNVCTRLQueryAttribute returned false");
+        return 0;
+    }
+
+    /* convert the int to gdouble and return it */
+    return (gdouble)temp;
+}
+
+/* creates the connection to the X server and checks whether the
+ * NV-CONTROL extension is loaded */
+static GList *nvidia_plugin_init(void) {
+    int dummy;
+    int event_base, error_base;
+    GList *sensors = NULL;
+
+    /* create the connection to the X server */
+    if (!(nvidia_sensors_dpy = XOpenDisplay(NULL))) {
+        /* no connection to the X server avaible */
+        return sensors;
+    }
+
+    /* check if the NV-CONTROL extension is available on this X
+         * server - if so add the two sensors if they exist */
+    if (XNVCTRLQueryExtension(nvidia_sensors_dpy, &event_base, &error_base)) {
+        int i, cnt;
+
+        if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+                        NV_CTRL_TARGET_TYPE_THERMAL_SENSOR,
+                        &cnt)) {
+
+            for (i = 0; i < cnt; i++) {
+                gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_SENSOR_TEMP);
+
+                sensors_applet_plugin_add_sensor(&sensors,
+                                                 THERMAL_SENSOR_TEMP,
+                                                 id,
+                                                 _("GPU"),
+                                                 TEMP_SENSOR,
+                                                 TRUE,
+                                                 GPU_ICON,
+                                                 DEFAULT_GRAPH_COLOR);
+
+                g_free(id);
+            }
+        }
+
+        if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+                        NV_CTRL_TARGET_TYPE_COOLER,
+                        &cnt)) {
+
+            for (i = 0; i < cnt; i++) {
+                gchar *id = g_strdup_printf("GPU%d%s", i, THERMAL_COOLER_LEVEL);
+
+                sensors_applet_plugin_add_sensor(&sensors,
+                                                 THERMAL_COOLER_LEVEL,
+                                                 id,
+                                                 _("GPU"),
+                                                 FAN_SENSOR,
+                                                 TRUE,
+                                                 FAN_ICON,
+                                                 DEFAULT_GRAPH_COLOR);
+
+                g_free(id);
+            }
+        }
+
+        if (XNVCTRLQueryTargetCount(nvidia_sensors_dpy,
+                        NV_CTRL_TARGET_TYPE_GPU,
+                        &cnt)) {
+
+            for (i = 0; i < cnt; i++) {
+                if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                                NV_CTRL_TARGET_TYPE_GPU,
+                                i,
+                                       0, NV_CTRL_GPU_CORE_TEMPERATURE, &dummy)) {
+
+                    gchar *id = g_strdup_printf("GPU%d%s", i, GPU_CORE_TEMP);
+
+                    sensors_applet_plugin_add_sensor(&sensors,
+                                                     GPU_CORE_TEMP,
+                                                     id,
+                                                     _("GPU"),
+                                                     TEMP_SENSOR,
+                                                     TRUE,
+                                                     GPU_ICON,
+                                                     DEFAULT_GRAPH_COLOR);
+                    g_free(id);
+                }
+
+                if (XNVCTRLQueryTargetAttribute(nvidia_sensors_dpy,
+                                NV_CTRL_TARGET_TYPE_GPU,
+                                i,
+                                       0, NV_CTRL_AMBIENT_TEMPERATURE, &dummy)) {
+                    gchar *id = g_strdup_printf("GPU%d%s", i, AMBIENT_TEMP);
+
+                    sensors_applet_plugin_add_sensor(&sensors,
+                                                     AMBIENT_TEMP,
+                                                     id,
+                                                     _("Ambient"),
+                                                     TEMP_SENSOR,
+                                                     FALSE,
+                                                     GENERIC_ICON,
+                                                     DEFAULT_GRAPH_COLOR);
+                    g_free(id);
+                }
+            }
+        }
+
+    }
+    return sensors;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return nvidia_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return nvidia_plugin_get_sensor_value(path, id, type, error);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/22.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/22.html new file mode 100644 index 0000000..6284f14 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/22.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2006 Sven Peter <svpe@gmx.net>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef NVIDIA_PLUGIN_H
+#define NVIDIA_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* NVIDIA_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/23.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/23.html new file mode 100644 index 0000000..6791e53 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/23.html @@ -0,0 +1,443 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "omnibook-plugin.h"
+
+const gchar *plugin_name = "omnibook";
+
+#define OMNIBOOK_DEVICE_FILE "/proc/omnibook/temperature"
+
+enum {
+    OMNIBOOK_DEVICE_FILE_OPEN_ERROR,
+    OMNIBOOK_DEVICE_FILE_READ_ERROR
+};
+
+static void omnibook_plugin_setup_manually(GList **sensors) {
+    /* omnibook only has the one device file with one temp in it */
+    if (g_file_test(OMNIBOOK_DEVICE_FILE, G_FILE_TEST_EXISTS)) {
+
+        sensors_applet_plugin_add_sensor(sensors,
+                                         OMNIBOOK_DEVICE_FILE,
+                                         _("temperature"),
+                                         _("CPU"),
+                                         TEMP_SENSOR,
+                                         TRUE,
+                                         CPU_ICON,
+                                         DEFAULT_GRAPH_COLOR);
+    }
+}
+
+/* to be called to setup for sys sensors */
+static GList *omnibook_plugin_init(void) {
+    GList *sensors = NULL;
+    /* call function to recursively look for sensors starting at the defined base directory */
+    omnibook_plugin_setup_manually(&sensors);
+
+    return sensors;
+}
+
+static gdouble omnibook_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat sensor_value;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, OMNIBOOK_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+
+    if (fscanf(fp, "CPU temperature: %f", &sensor_value) != 1) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, OMNIBOOK_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+        fclose(fp);
+        return -1.0;
+    }
+
+    fclose(fp);
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return omnibook_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return omnibook_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/24.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/24.html new file mode 100644 index 0000000..62d0a3f --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/24.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef OMNIBOOK_PLUGIN_H
+#define OMNIBOOK_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* OMNIBOOK_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/25.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/25.html new file mode 100644 index 0000000..5595be8 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/25.html @@ -0,0 +1,613 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "pmu-sys-plugin.h"
+
+const gchar *plugin_name = "pmu-sys";
+
+#define PMU_SYS_BASE_DIR "/sys/devices/temperatures/"
+#define PMU_WT_SYS_BASE_DIR "/sys/devices/temperature/"
+
+#define SENSOR1 "sensor1"
+#define CPU "cpu"
+#define SENSOR2 "sensor2"
+#define GPU "gpu"
+#define CASE "case"
+#define TEMPERATURE "_temperature"
+#define FAN_SPEED "_fan_speed"
+
+enum {
+    PMU_SYS_DEVICE_FILE_OPEN_ERROR,
+    PMU_SYS_DEVICE_FILE_READ_ERROR
+};
+
+static void pmu_sys_plugin_add_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    gchar *label = NULL;
+    gboolean enable;
+    SensorType sensor_type;
+    IconType icon_type = GENERIC_ICON;
+
+    filename = g_path_get_basename(path);
+
+    if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
+        label = g_strdup(_("CPU"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = CPU_ICON;
+    } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
+        label = g_strdup(_("GPU"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = GPU_ICON;
+    } else if (g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0) {
+        label = g_strdup(_("CASE"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = CASE_ICON;
+    } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+        label = g_strdup(_("FAN"));
+        sensor_type = FAN_SENSOR;
+        enable = TRUE;
+        icon_type = FAN_ICON;
+    } else {
+        /* disable all other sensors */
+        enable = FALSE;
+    }
+
+    /* only add these 3 sensors */
+    if (enable) {
+        sensors_applet_plugin_add_sensor(sensors,
+                                         path,
+                                         filename,
+                                         label,
+                                         sensor_type,
+                                         enable,
+                                         icon_type,
+                                         DEFAULT_GRAPH_COLOR);
+
+    }
+
+    g_free(filename);
+    g_free(label);
+}
+
+static void pmu_sys_plugin_test_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    filename = g_path_get_basename(path);
+    if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
+        g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, CASE TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+
+        pmu_sys_plugin_add_sensor(sensors, path);
+    }
+
+    g_free(filename);
+}
+
+/* to be called to setup for sys sensors */
+static
+GList *pmu_sys_plugin_init(void) {
+    GList *sensors = NULL;
+    /* call function to recursively look for sensors
+       starting at the defined base directory */
+    sensors_applet_plugin_find_sensors(&sensors, PMU_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
+    sensors_applet_plugin_find_sensors(&sensors, PMU_WT_SYS_BASE_DIR, pmu_sys_plugin_test_sensor);
+    return sensors;
+}
+
+/* returns the value of the sensor_list at the given iter, or if an
+   error occurs, instatiates error with an error message */
+static
+gdouble pmu_sys_plugin_get_sensor_value(const gchar *path,
+                                        const gchar *id,
+                                        SensorType type,
+                                        GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat sensor_value, dummy;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+    switch(type) {
+        case FAN_SENSOR:
+            if (fscanf(fp, "%f (%f rpm)", &dummy, &sensor_value) != 2) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+            break;
+
+        case TEMP_SENSOR:
+            if (fscanf(fp, "%f", &sensor_value) != 1) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+            break;
+
+        default:
+            /* should only have added temp or fan sensors */
+            g_error("Unknown sensor type passed as parameter to pmu-sys sensor interface, cannot get value for this sensor");
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, PMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+            fclose(fp);
+            return -1.0;
+
+    }
+    fclose(fp);
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return pmu_sys_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return pmu_sys_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/26.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/26.html new file mode 100644 index 0000000..89ab318 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/26.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef PMU_SYS_PLUGIN_H
+#define PMU_SYS_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* PMU_SYS_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/27.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/27.html new file mode 100644 index 0000000..ac91371 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/27.html @@ -0,0 +1,591 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "smu-sys-plugin.h"
+
+const gchar *plugin_name = "smu-sys";
+
+#define SMU_SYS_BASE_DIR "/sys/devices/platform/windfarm.0"
+
+#define SENSOR1 "sensor1"
+#define CPU "cpu"
+#define SENSOR2 "sensor2"
+#define GPU "gpu"
+#define TEMPERATURE "-temp"
+#define FAN_SPEED "-fan"
+
+enum {
+    SMU_SYS_DEVICE_FILE_OPEN_ERROR,
+    SMU_SYS_DEVICE_FILE_READ_ERROR
+};
+
+static void smu_sys_plugin_add_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    gchar *label = NULL;
+    gboolean enable;
+    SensorType sensor_type;
+    IconType icon_type = GENERIC_ICON;
+
+    filename = g_path_get_basename(path);
+
+    if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0) {
+        label = g_strdup(_("CPU"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = CPU_ICON;
+    } else if (g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 || g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0) {
+        label = g_strdup(_("GPU"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = GPU_ICON;
+    } else if (g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0|| g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+        label = g_strdup(_("FAN"));
+        sensor_type = FAN_SENSOR;
+        enable = TRUE;
+        icon_type = FAN_ICON;
+    } else {
+        /* disable all other sensors */
+        enable = FALSE;
+    }
+
+    /* only add these 3 sensors */
+    if (enable) {
+        sensors_applet_plugin_add_sensor(sensors,
+                                         path,
+                                         filename,
+                                         label,
+                                         sensor_type,
+                                         enable,
+                                         icon_type,
+                                         DEFAULT_GRAPH_COLOR);
+
+    }
+
+    g_free(filename);
+    g_free(label);
+}
+
+static void smu_sys_plugin_test_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+
+    filename = g_path_get_basename(path);
+    if (g_ascii_strcasecmp(filename, SENSOR1 TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, SENSOR2 TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, SENSOR1 FAN_SPEED) == 0 ||
+        g_ascii_strcasecmp(filename, CPU TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, GPU TEMPERATURE) == 0 ||
+        g_ascii_strcasecmp(filename, CPU FAN_SPEED) == 0) {
+
+        smu_sys_plugin_add_sensor(sensors, path);
+    }
+    g_free(filename);
+}
+
+/* to be called to setup for sys sensors */
+static GList *smu_sys_plugin_init(void) {
+    GList *sensors = NULL;
+
+    /* call function to recursively look for sensors
+       starting at the defined base directory */
+    sensors_applet_plugin_find_sensors(&sensors, SMU_SYS_BASE_DIR, smu_sys_plugin_test_sensor);
+
+    return sensors;
+}
+
+/* returns the value of the sensor_list at the given iter, or if an
+   error occurs, instatiates error with an error message */
+static
+gdouble smu_sys_plugin_get_sensor_value(const gchar *path,
+                                        const gchar *id,
+                                        SensorType type,
+                                        GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat sensor_value = -1.0;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+    switch(type) {
+        case FAN_SENSOR:
+            if (fscanf(fp, "%f", &sensor_value) != 1) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+            break;
+
+        case TEMP_SENSOR:
+            if (fscanf(fp, "%f", &sensor_value) != 1) {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                fclose(fp);
+                return -1.0;
+            }
+            break;
+
+        default:
+            /* should only have added temp or fan sensors */
+            g_error("Unknown sensor type passed as parameter to smu-sys sensor interface, cannot get value for this sensor");
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SMU_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+    }
+    fclose(fp);
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return smu_sys_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return smu_sys_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/28.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/28.html new file mode 100644 index 0000000..2368ba0 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/28.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SMU_SYS_PLUGIN_H
+#define SMU_SYS_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* SMU_SYS_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/29.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/29.html new file mode 100644 index 0000000..11b1d66 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/29.html @@ -0,0 +1,475 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
/*
+ * Copyright (C) 2006-2008 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_FCNTL_H */
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_SYS_IOCTL_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sonypi-plugin.h"
+
+#include <stdint.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+const gchar *plugin_name = "sonypi";
+
+/* These values are taken from spicctrl by Stelian Pop */
+#define SONYPI_DEV       "/dev/sonypi"
+#define SONYPI_IOCGFAN   _IOR('v', 10, uint8_t)
+#define SONYPI_IOCGTEMP  _IOR('v', 12, uint8_t)
+#define SONYPI_TEMP "sonypi_temp"
+
+enum {
+    SONYPI_DEVICE_FILE_OPEN_ERROR,
+    SONYPI_DEVICE_FILE_READ_ERROR
+};
+
+static
+GList *sonypi_plugin_init(void) {
+    int fd;
+    GList *sensors = NULL;
+
+    if ( (fd = open(SONYPI_DEV, O_RDONLY)) != -1 ) {
+        if ( close(fd) != -1 ) {
+            sensors_applet_plugin_add_sensor(&sensors,
+                                             SONYPI_DEV,
+                                             SONYPI_TEMP,
+                                             _("CPU TEMP"),
+                                             TEMP_SENSOR,
+                                             TRUE,
+                                             CPU_ICON,
+                                             DEFAULT_GRAPH_COLOR);
+        }
+    }
+    return sensors;
+}
+
+static
+gdouble sonypi_plugin_get_sensor_value(const gchar *path,
+                                       const gchar *id,
+                                       SensorType type,
+                                       GError **error) {
+
+    int fd;
+    guint8 value8;
+
+    gdouble sensor_value = -1.0;
+
+    if ((fd = open(path, O_RDONLY)) != -1) {
+        /* only use temp sensor */
+        if (g_ascii_strcasecmp(id, SONYPI_TEMP) == 0) {
+            if (ioctl(fd, SONYPI_IOCGTEMP, &value8) != -1) {
+                sensor_value = (gdouble)value8;
+            } else {
+                g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+            }
+        }
+        close(fd);
+    } else {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, SONYPI_DEVICE_FILE_OPEN_ERROR, "Error opening from sensor device file %s", path);
+    }
+
+    return sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return sonypi_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return sonypi_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/3.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/3.html new file mode 100644 index 0000000..83525f9 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/3.html @@ -0,0 +1,479 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
/*
+ * Copyright (C) 2018 info-cppsp <info@cppsp.de>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/* Dummy plugin to be able to test msa in a VM */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "dummy-plugin.h"
+
+// remove // from next line for syslog debug
+//#define DPDBG              1
+
+#ifdef DPDBG
+#include <syslog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+const gchar *plugin_name = "dummy";
+
+static void dummy_plugin_get_sensors(GList **sensors) {
+
+    /* dummy HDD temp sensor */
+    sensors_applet_plugin_add_sensor(sensors,
+                                     "/sys/devices/platform/it87.656/hwmon/hwmon1/temp2_input",
+                                     "temp2",
+                                     "CPU",
+                                     TEMP_SENSOR,
+                                     TRUE,
+                                     CPU_ICON,
+                                     DEFAULT_GRAPH_COLOR);
+
+    /* dummy HDD temp sensor */
+    sensors_applet_plugin_add_sensor(sensors,
+                                     "/sys/devices/platform/it87.656/hwmon/hwmon1/fan1_input",
+                                     "fan1",
+                                     "fan1",
+                                     FAN_SENSOR,
+                                     TRUE,
+                                     FAN_ICON,
+                                     DEFAULT_GRAPH_COLOR);
+
+    /* dummy HDD temp sensor */
+    sensors_applet_plugin_add_sensor(sensors,
+                                     "HDD 2154884654-5648HG-546821",
+                                     "Disk Temperature",
+                                     "HDD 2154884654",
+                                     TEMP_SENSOR,
+                                     TRUE,
+                                     HDD_ICON,
+                                     DEFAULT_GRAPH_COLOR);
+
+}
+
+/* this is the function called every refresh cycle */
+static gdouble dummy_plugin_get_sensor_value(const gchar *path,
+                                             const gchar *id,
+                                             SensorType type,
+                                             GError **error) {
+
+    switch (type) {
+        case TEMP_SENSOR:
+            return (gdouble) (rand() % 40 + 20);
+            break;
+
+        case FAN_SENSOR:
+            return (gdouble) (rand() % 3000);
+            break;
+
+        default:
+            g_assert_not_reached();
+    }
+
+}
+
+/* API functions */
+const gchar *sensors_applet_plugin_name(void) {
+    return plugin_name;
+}
+
+static GList *dummy_plugin_init(void) {
+    GList *sensors = NULL;
+
+    /* init random number generation */
+    srand(time(NULL));
+
+    dummy_plugin_get_sensors(&sensors);
+
+    return sensors;
+}
+
+GList *sensors_applet_plugin_init(void) {
+    return dummy_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                               const gchar *id,
+                                               SensorType type,
+                                               GError **error) {
+
+    return dummy_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/30.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/30.html new file mode 100644 index 0000000..95bb180 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/30.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2006 Thanate Dhirasakdanon <dthanate@gmail.com>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SONYPI_PLUGIN_H
+#define SONYPI_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* SONYPI_PLUGIN_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/31.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/31.html new file mode 100644 index 0000000..cdf5de0 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/31.html @@ -0,0 +1,1143 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
/*
+ * Copyright (C) 2017 info-cppsp <info@cppsp.de>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/*
+Udisks2 plugin for the mate-sensors-applet
+
+written using the structure and code of the previous version
+from Pramod Dematagoda <pmd.lotr.gandalf@gmail.com>
+
+dbus-glib documentation
+https://dbus.freedesktop.org/doc/dbus-glib/
+GDBUS documentation
+https://developer.gnome.org/gio/stable/index.html
+
+*/
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "udisks2-plugin.h"
+
+/* remove // from next line for syslog debug */
+//#define UD2PD              1
+
+#ifdef UD2PD
+#include <syslog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#define UDISKS2_BUS_NAME              "org.freedesktop.UDisks2"
+#define UDISKS2_INTERFACE_NAME        "org.freedesktop.DBus.ObjectManager"
+#define UDISKS2_DEVICE_INTERFACE_NAME "org.freedesktop.UDisks2.Drive"
+#define UDISKS2_DEVICE_INTERFACE2_NAME "org.freedesktop.UDisks2.Drive.Ata"
+
+#define UDISKS2_PROPERTIES_INTERFACE  "org.freedesktop.DBus.Properties"
+#define UDISKS2_OBJECT_PATH           "/org/freedesktop/UDisks2"
+
+/* Info about a single sensor */
+typedef struct _DevInfo {
+    gchar *path;
+    gchar *id;
+    gdouble temp;
+    GDBusProxy *sensor_proxy;       /* dbus object */
+    GError *error;
+} DevInfo;
+
+const gchar *plugin_name = "udisks2";
+
+/* a container for the devices found to have smart enabled */
+GHashTable *devices = NULL;
+
+/* This is a global variable for convenience */
+GDBusConnection *connection = NULL;
+
+static void update_device (DevInfo *info) {
+    GError *error = NULL;
+    GVariant *tempgvar = NULL;
+    GVariant *tempgvar2 = NULL;
+    gdouble temp;
+
+    /* check valid input parameter */
+    g_return_if_fail (info != NULL);
+
+    /* check connection too */
+    g_return_if_fail (connection != NULL);
+
+    g_clear_error (&info->error);
+
+    /* check for sensor_proxy, which should exist at this point, make one if necessary and save it into DevInfo
+     * this is used to get the temp value the direct way */
+    if (NULL == info->sensor_proxy) {
+        info->sensor_proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                                    UDISKS2_BUS_NAME,
+                                                    info->path,
+                                                    UDISKS2_PROPERTIES_INTERFACE,
+                                                    NULL, &error);
+
+        /* check, just to be sure */
+        if (NULL == info->sensor_proxy) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Failed to get drive temperature 1");
+#endif
+            g_debug ("Failed to get drive temperature 1: %s", error->message);
+            g_clear_error (&error);
+            return;
+        }
+    }
+
+/* note on timing:
+ * it seems to me that smart updates occur automatically every 10 minutes
+ * mate-sensor-applet has a default refresh of 2 seconds...
+ * it is possible to force a smart update with udisks2: SmartUpdate (IN  a{sv} options); */
+
+    /* directly asking the device's DBus object for the temp */
+    tempgvar = g_dbus_proxy_call_sync (info->sensor_proxy, "Get",
+                g_variant_new ("(ss)",
+                    UDISKS2_DEVICE_INTERFACE2_NAME,
+                    "SmartTemperature"),                /* parameters */
+                G_DBUS_CALL_FLAGS_NONE,                 /* flags */
+                -1,                                     /* timeout */
+                NULL,                                   /* cancellable */
+                &error);
+
+    if (NULL == tempgvar) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Failed to get drive temperature 2");
+#endif
+        g_debug ("Failed to get drive temperature 2: %s", error->message);
+        g_clear_error (&error);
+        /* throw away proxy, maybe next time it will be better */
+        g_clear_object (&info->sensor_proxy);
+        return;
+
+    } else {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "tempgvar value: %s", g_variant_print(tempgvar, TRUE));
+/* leaks memory! */
+//syslog(LOG_ERR, "tempgvar value: %s", g_variant_print(g_variant_get_variant(g_variant_get_child_value(tempgvar, 0)), TRUE));
+#endif
+
+        /* tempgvar comes back as something along the lines of array(gvariant(tempasdouble))
+         * hence unpacking
+         * need to free up every param / return value, so can't do it like:
+         * temp = g_variant_get_double(g_variant_get_variant(g_variant_get_child_value(tempgvar, 0))); */
+        tempgvar2 = g_variant_get_child_value (tempgvar, 0);
+        g_variant_unref (tempgvar);
+        tempgvar = g_variant_get_variant (tempgvar2);
+        g_variant_unref (tempgvar2);
+        temp = g_variant_get_double (tempgvar);
+        g_variant_unref (tempgvar);
+
+        /* temp in K */
+        info->temp = temp - 273.15;
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Refresh udisks2 device temp: '%f'\n", info->temp);
+#endif
+
+    }
+
+}
+
+/* in this function we would like to get a list of device (hdd/ssd) paths
+ * then with each path we get the temperature
+ * it is possible with udisks2 to get all the above information in one g_dbus_proxy_call_sync(), so that is how I did it
+ * maybe a better version would be to use GDBusObjectManager Server + Client ?? */
+static void udisks2_plugin_get_sensors (GList **sensors) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "fstart");
+#endif
+
+    GDBusProxy *proxy = NULL;
+    GError *error = NULL;
+
+    DevInfo *info;
+
+    /* This connection will be used for everything, including the obtaining of sensor data */
+    connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+    if (NULL == connection) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "dbus conn fail");
+#endif
+
+        g_debug ("Failed to open connection to DBUS: %s", error->message);
+        g_clear_error (&error);
+        return;
+    }
+
+#ifdef UD2PD
+syslog(LOG_ERR, "dbus conn success");
+#endif
+
+    /* I use this proxy to get all info of all devices at once */
+    proxy = g_dbus_proxy_new_sync (connection, G_DBUS_PROXY_FLAGS_NONE, NULL,
+                                   UDISKS2_BUS_NAME,
+                                   UDISKS2_OBJECT_PATH,
+                                   UDISKS2_INTERFACE_NAME,
+                                   NULL, &error);
+
+    if (NULL == proxy) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "dbus conn proxy fail");
+#endif
+        g_debug ("dbus conn proxy fail: %s", error->message);
+        g_clear_error (&error);
+        g_clear_object (&connection);
+        return;
+    }
+
+#ifdef UD2PD
+syslog(LOG_ERR, "dbus conn proxy success");
+#endif
+
+    /* The object paths of the disks are enumerated and placed in an array of object paths
+     * "GetManagedObjects" returns dict of (objectpath, (dict of (string [ie. if. name], dict of(string [ie. property name], variant [ie. prop. value])))) */
+
+    /* g_dbus_proxy_call_sync() returns NULL on error, GVariant * otherwise
+     * need second variable to prevent memory leak */
+    GVariant *managed_objects = NULL;
+    GVariant *managed_objects2 = NULL;
+
+    managed_objects2 = g_dbus_proxy_call_sync (proxy, "GetManagedObjects",
+                                               NULL,                           /* parameters */
+                                               G_DBUS_CALL_FLAGS_NONE,         /* flags */
+                                               -1,                             /* timeout */
+                                               NULL,                           /* cancellable */
+                                               &error);
+
+    if (NULL == managed_objects2) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Failed to enumerate disk devices");
+#endif
+
+        g_debug ("Failed to enumerate disk devices: %s", error->message);
+        g_clear_error (&error);
+        g_clear_object (&proxy);
+        g_clear_object (&connection);
+        return;
+    }
+
+    /* the result dictionary is enclosed in an array, unpack */
+    managed_objects = g_variant_get_child_value (managed_objects2, 0);
+    g_variant_unref (managed_objects2);
+
+#ifdef UD2PD
+//syslog(LOG_ERR, "managed_objects type: %s", g_variant_print(managed_objects, TRUE));
+syslog(LOG_ERR, "success to enumerate disk devices");
+#endif
+
+    /* iterator for the result dictionary
+     * iterator code is based on the g_variant_iter_next() documentation
+     * iter is freed if the GVariant is, when using g_variant_iter_init() */
+    GVariantIter iter;
+    gchar *key = NULL;         /* object path (like '/org/freedesktop/UDisks2/drives/Samsung_SSD_840_EVO_250GB_*insert drive serial nr.*') */
+    GVariant *value = NULL;
+
+#ifdef UD2PD
+/* log collection size */
+syslog(LOG_ERR, "iter init count: %d", (int) g_variant_iter_init (&iter, managed_objects));
+#else
+    g_variant_iter_init (&iter, managed_objects);
+#endif
+
+    /* "{sv}"  is a GVariant format string
+     * {} dictionary of, s string, v GVariant
+     * changed to "{oa{sa{sv}}}" on error message 'the GVariant format string '{sv}' has a type of '{sv}' but the given value has a type of 'a{oa{sa{sv}}}''
+     * a is array, o is object path
+     * NOO!! the right format string is "{o@*}", which means get an object path into the 1st variable (key)
+     * and get 'everything else' (as a GVariant) into the 2nd variable (value)
+     * needs the & before the key and value params! */
+    while (g_variant_iter_next (&iter, "{o@*}", &key, &value)) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "in iter while loop");
+syslog(LOG_ERR, "key value: %s", key);
+//syslog(LOG_ERR, "value type: %s", g_variant_print(value, TRUE));
+#endif
+
+        /* level 2
+         * create a dictionary of value
+         * the two interface names that we are searching for are known and defined
+         * can't use GVariantDict, it only supports '{sv}' but the given value has a type of '{sa{sv}}'
+         * using general lookup */
+
+        GVariant *propdict = NULL;          /* drive data */
+        GVariant *propdict2 = NULL;         /* drive smart data */
+
+        /* make two dictionaries that contain the properties of the drive interfaces */
+        propdict = g_variant_lookup_value (value, UDISKS2_DEVICE_INTERFACE_NAME, G_VARIANT_TYPE_DICTIONARY);
+        propdict2 = g_variant_lookup_value (value, UDISKS2_DEVICE_INTERFACE2_NAME, G_VARIANT_TYPE_DICTIONARY);
+
+        /* do we have the right ifname keys? */
+        if ((NULL != propdict) && (NULL != propdict2)) {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "propdict type: %s", g_variant_print(propdict, TRUE));
+syslog(LOG_ERR, "propdict2 type: %s", g_variant_print(propdict2, TRUE));
+#endif
+
+            /* get data */
+            gchar *id = NULL;
+            gchar *model = NULL;
+
+            gboolean smartenabled;
+            gdouble temp;
+
+            /* NULL, bc we don't care about the length of the string
+             * typecast bc g_variant_get_string() returns const char* */
+            id = (gchar *) g_variant_get_string (g_variant_lookup_value (propdict, "Id", G_VARIANT_TYPE_STRING), NULL);
+            model = (gchar *) g_variant_get_string (g_variant_lookup_value (propdict, "Model", G_VARIANT_TYPE_STRING), NULL);
+
+            smartenabled = g_variant_get_boolean (g_variant_lookup_value (propdict2, "SmartEnabled", G_VARIANT_TYPE_BOOLEAN));
+            temp = g_variant_get_double (g_variant_lookup_value (propdict2, "SmartTemperature", G_VARIANT_TYPE_DOUBLE));
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Found udisks2 device id: '%s'\n", id);
+syslog(LOG_ERR, "Found udisks2 device model: '%s'\n", model);
+syslog(LOG_ERR, "Found udisks2 device smartenabled: '%d'\n", smartenabled);
+syslog(LOG_ERR, "Found udisks2 device temp: '%f'\n", temp);
+#endif
+
+            /* only go on if smart is enabled
+             * save data */
+            if (smartenabled) {
+
+                info = g_new0 (DevInfo, 1);
+                if (NULL == devices) {
+                    devices = g_hash_table_new (g_str_hash, g_str_equal);
+                }
+
+                info->id =  g_strdup (id);
+                info->path =  g_strdup (key);
+
+                /* temp in K
+                 * this could be left at 0.0, 2 seconds later it will be refreshed anyway */
+                info->temp = (gdouble) temp - 273.15;
+                g_hash_table_insert (devices, info->id, info);
+
+                /* Write the sensor data */
+                sensors_applet_plugin_add_sensor (sensors,
+                                                  id,
+                                                  "Disk Temperature",
+                                                  model,
+                                                  TEMP_SENSOR,
+                                                  FALSE,
+                                                  HDD_ICON,
+                                                  DEFAULT_GRAPH_COLOR);
+
+                g_debug ("Added %s", id);
+
+#ifdef UD2PD
+syslog(LOG_ERR, "Added %s", id);
+#endif
+
+            } else {
+
+#ifdef UD2PD
+syslog(LOG_ERR, "No temp data for device: %s\n", key);
+#endif
+
+                g_debug ("No temp data for device: %s\n", key);
+            }
+
+#ifdef UD2PD
+syslog(LOG_ERR, "b4 free1");
+#endif
+
+            g_free (id);
+            g_free (model);
+
+        }
+
+#ifdef UD2PD
+syslog(LOG_ERR, "b4 free2");
+#endif
+
+        /* free propdict, propdict2
+         * g_variant_dict_unref() may not work a few times, gives error
+         * this one seems to do fine */
+        if (NULL != propdict) {g_variant_unref (propdict);}
+        if (NULL != propdict2) {g_variant_unref (propdict2);}
+
+#ifdef UD2PD
+syslog(LOG_ERR, "b4 free3");
+#endif
+
+        g_free (key);
+        g_variant_unref (value);
+
+    }       /* end of while loop */
+
+    g_variant_unref (managed_objects);
+    g_clear_object (&proxy);
+    if (NULL == devices) {
+        g_clear_object (&connection);
+    }
+}
+
+/* this function is called every refresh cycle */
+static gdouble udisks2_plugin_get_sensor_value (const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+    DevInfo *info = NULL;
+
+    /* get device stuct from data store */
+    info = (DevInfo *) g_hash_table_lookup (devices, path);
+    if (NULL == info) {
+        g_set_error (error, SENSORS_APPLET_PLUGIN_ERROR, 0, "Error finding disk with path %s", path);
+        return 0.0;
+    }
+
+    if (info->error) {
+        *error = info->error;
+        info->error = NULL;
+        return 0.0;
+    }
+
+    /* refresh device temp */
+    update_device (info);
+    return info->temp;
+}
+
+/* API functions */
+const gchar *sensors_applet_plugin_name (void) {
+    return plugin_name;
+}
+
+static GList *udisks2_plugin_init (void) {
+    GList *sensors = NULL;
+
+    udisks2_plugin_get_sensors (&sensors);
+
+    return sensors;
+}
+
+GList *sensors_applet_plugin_init (void) {
+    return udisks2_plugin_init ();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value (const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return udisks2_plugin_get_sensor_value (path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/32.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/32.html new file mode 100644 index 0000000..ebaaf1f --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/32.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2017 info-cppsp <info@cppsp.de>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef UDISKS2_PLUGIN_H
+#define UDISKS2_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* UDISKS2_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/33.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/33.html new file mode 100644 index 0000000..f615d4f --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/33.html @@ -0,0 +1,341 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "about-dialog.h"
+
+void about_dialog_open(SensorsApplet *sensors_applet) {
+    const gchar *authors[] = {
+        "Alex Murray <murray.alex@gmail.com>",
+        "Stefano Karapetsas <stefano@karapetsas.com>",
+        NULL
+    };
+
+    /* Construct the about dialog */
+    gtk_show_about_dialog(NULL,
+                  "icon-name", "mate-sensors-applet",
+                  "program-name", PACKAGE_NAME,
+                  "version", PACKAGE_VERSION,
+                  "copyright", _("Copyright \xc2\xa9 2005-2009 Alex Murray\n"
+                                 "Copyright \xc2\xa9 2011 Stefano Karapetsas\n"
+                                 "Copyright \xc2\xa9 2012-2021 MATE developers"),
+                  "authors", authors,
+                  "documenters", authors,
+                  /* To translator: Put your name here to show up in the About dialog as the translator */
+                  "translator-credits", _("translator-credits"),
+                  "logo-icon-name", SENSORS_APPLET_ICON,
+                  "website", PACKAGE_URL,
+                  NULL);
+
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/34.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/34.html new file mode 100644 index 0000000..8f2d7ac --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/34.html @@ -0,0 +1,629 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SENSORS_APPLET_H
+#define SENSORS_APPLET_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-panel-applet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensors-applet-sensor.h"
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_LIBNOTIFY
+#include <libnotify/notify.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+typedef struct _ActiveSensor ActiveSensor;
+
+#include "prefs-dialog.h"
+
+#define GRAPH_FRAME_EXTRA_WIDTH 6
+#define SENSORS_APPLET_ICON "mate-sensors-applet"
+
+static const gchar * const stock_icons[NUM_ICONS] = {
+    "mate-sensors-applet-cpu",
+    "mate-sensors-applet-drive-harddisk",
+    "mate-sensors-applet-battery",
+    "mate-sensors-applet-memory",
+    "mate-sensors-applet-gpu",
+    "mate-sensors-applet-chip",
+    "mate-sensors-applet-fan",
+    "mate-sensors-applet-case"
+};
+
+#define DEFAULT_ICON_SIZE 22
+
+#define UNITS_CELSIUS "\302\260C"
+#define UNITS_FAHRENHEIT "\302\260F"
+#define UNITS_KELVIN ""
+#define UNITS_RPM _("RPM")
+#define UNITS_VOLTAGE  _("V")
+#define UNITS_CURRENT  _("A")
+
+/* enumeration used to identify columns in the GtkTreeStore data structure */
+enum {
+    PATH_COLUMN = 0,
+    ID_COLUMN,
+    LABEL_COLUMN,
+    INTERFACE_COLUMN,
+    SENSOR_TYPE_COLUMN,
+    ENABLE_COLUMN,
+    VISIBLE_COLUMN,
+    LOW_VALUE_COLUMN,
+    HIGH_VALUE_COLUMN,
+    ALARM_ENABLE_COLUMN,
+    LOW_ALARM_COMMAND_COLUMN,
+    HIGH_ALARM_COMMAND_COLUMN,
+    ALARM_TIMEOUT_COLUMN,
+    MULTIPLIER_COLUMN,
+    OFFSET_COLUMN,
+    ICON_TYPE_COLUMN,
+    ICON_PIXBUF_COLUMN,
+    GRAPH_COLOR_COLUMN,
+    N_COLUMNS
+};
+
+/* for display mode */
+typedef enum {
+    DISPLAY_LABEL_WITH_VALUE = 0,
+    DISPLAY_ICON_WITH_VALUE,
+    DISPLAY_VALUE,
+    DISPLAY_ICON,
+    DISPLAY_GRAPH
+} DisplayMode;
+
+typedef enum {
+    VALUE_BESIDE_LABEL = 0,
+    VALUE_BELOW_LABEL
+} LayoutMode;
+
+typedef enum {
+    KELVIN = 0,
+    CELSIUS,
+    FAHRENHEIT
+} TemperatureScale;
+
+/* types of Notifs - low and high alarm warnings and error conditions */
+typedef enum {
+    LOW_ALARM = 0,
+    HIGH_ALARM,
+    SENSOR_INTERFACE_ERROR,
+    NUM_NOTIFS
+} NotifType;
+
+/* only always two type of alarms - may have more notif types */
+#define NUM_ALARMS 2
+
+struct _SensorsApplet {
+    /* the actual applet for this instance */
+    MatePanelApplet* applet;
+    gint size;
+
+    GtkTreeStore *sensors;
+    gchar **sensors_hash_array;
+    GtkTreeSelection *selection;
+
+    GHashTable *required_plugins;
+    GHashTable *plugins;
+
+    guint timeout_id;
+    /* preferences and about windows (if Gtk < 2.6) */
+    PrefsDialog *prefs_dialog;
+
+    /* primary grid to contain the panel dispay - we pack the
+     * list of labels and sensor values into this container */
+    GtkWidget *grid;
+    GList *active_sensors;
+
+    GSettings *settings;
+
+#ifdef HAVE_LIBNOTIFY
+    NotifyNotification *notification;
+#endif // HAVE_LIBNOTIFY
+
+    gboolean show_tooltip;
+};
+
+/* non-static function prototypes */
+void sensors_applet_init(SensorsApplet *sensors_applet);
+void sensors_applet_sensor_enabled(SensorsApplet *sensors_applet, GtkTreePath *path);
+void sensors_applet_sensor_disabled(SensorsApplet *sensors_applet, GtkTreePath *path);
+gboolean sensors_applet_update_active_sensors(SensorsApplet *sensors_applet);
+/**
+ * to be called by things like prefs dialog to turn off a sensor alarm
+ */
+void sensors_applet_alarm_off(SensorsApplet *sensors_applet,
+                              GtkTreePath *path,
+                              NotifType notif_type);
+void sensors_applet_all_alarms_off(SensorsApplet *sensors_applet, GtkTreePath *path);
+void sensors_applet_icon_changed(SensorsApplet *sensors_applet, GtkTreePath *path);
+void sensors_applet_update_sensor(SensorsApplet *sensors_applet, GtkTreePath *path);
+
+void sensors_applet_display_layout_changed(SensorsApplet *sensors_applet);
+void sensors_applet_reorder_sensors(SensorsApplet *sensors_applet);
+gdouble sensors_applet_convert_temperature(gdouble value,
+                                           TemperatureScale old,
+                                           TemperatureScale new);
+
+void sensors_applet_notify_end(ActiveSensor *active_sensor, NotifType notif_type);
+void sensors_applet_notify_end_all(SensorsApplet *sensors_applet);
+void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType notif_type);
+GdkPixbuf *sensors_applet_load_icon(IconType icon_type);
+void sensors_applet_graph_size_changed(SensorsApplet *sensors_applet);
+
+typedef void SensorsInterfaceTestSensorFunc(SensorsApplet *sensors_applet, const gchar *path);
+void sensors_applet_find_sensors(SensorsApplet *sensors_applet,
+                                 const gchar *path,
+                                 SensorsInterfaceTestSensorFunc test_sensor);
+
+gboolean sensors_applet_add_sensor(SensorsApplet *sensors_applet,
+                                   const gchar *path,
+                                   const gchar *id,
+                                   const gchar *label,
+                                   const gchar *interface,
+                                   SensorType type,
+                                   gboolean enable,
+                                   gdouble low_value,
+                                   gdouble high_value,
+                                   gboolean alarm_enable,
+                                   const gchar *low_alarm_command,
+                                   const gchar *high_alarm_command,
+                                   gint alarm_timeout,
+                                   gdouble multiplier,
+                                   gdouble offset,
+                                   IconType icon_type,
+                                   const gchar *graph_color);
+
+#endif /* SENSORS_APPLET_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/35.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/35.html new file mode 100644 index 0000000..7993d32 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/35.html @@ -0,0 +1,365 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SENSORS_APPLET_SENSOR_H
+#define SENSORS_APPLET_SENSOR_H
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+/* forward declare for plugins to use */
+typedef struct _SensorsApplet SensorsApplet;
+
+#define DEFAULT_GRAPH_COLOR "#ff0000"
+
+/* device icons */
+typedef enum {
+    CPU_ICON = 0,
+    HDD_ICON,
+    BATTERY_ICON,
+    MEMORY_ICON,
+    GPU_ICON,
+    GENERIC_ICON,
+    FAN_ICON,
+    CASE_ICON,
+    NUM_ICONS,
+} IconType;
+
+typedef enum {
+    CURRENT_SENSOR = 0,
+    FAN_SENSOR,
+    TEMP_SENSOR,
+    VOLTAGE_SENSOR
+} SensorType;
+
+typedef struct _SensorsAppletSensorInfo {
+    gchar *path; /* must be dynamically allocated */
+    gchar *id; /* must be dynamically allocated */
+    gchar *label; /* must be dynamically allocated */
+    SensorType type;
+    gboolean enable;
+    gdouble low_value;
+    gdouble high_value;
+    gdouble multiplier;
+    gdouble offset;
+    IconType icon;
+    gchar *graph_color; /* must be dynamically allocated */
+} SensorsAppletSensorInfo;
+
+#endif // SENSORS_APPLET_SENSOR_H
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/36.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/36.html new file mode 100644 index 0000000..1c3a46b --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/36.html @@ -0,0 +1,445 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_LIBNOTIFY
+#include <libnotify/notify.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "active-sensor-libnotify.h"
+
+static void notif_closed_cb(NotifyNotification *notification,<--- Parameter 'notification' can be declared as pointer to const
+                            ActiveSensor *active_sensor) {
+
+    g_assert(notification != NULL && active_sensor != NULL);
+
+    int i;
+
+    g_debug("Notification was closed.. setting reference to NULL so we can show again if needed.");
+
+    // set notif reference to NULL
+    for (i = 0; i < NUM_NOTIFS; i++) {
+        if (active_sensor->notification[i] == notification) {
+            active_sensor->notification[i] = NULL;
+            break;
+        }
+    }
+}
+
+void active_sensor_libnotify_notify_end(ActiveSensor *active_sensor,
+                                        NotifType notif_type) {
+
+    GError *error = NULL;
+    if (active_sensor->notification[notif_type]) {
+        g_debug("Closing notification");
+        if(!notify_notification_close(active_sensor->notification[notif_type], &error)) {
+            g_warning("Error closing notification: %s", error->message);
+            g_error_free(error);
+        }
+        g_object_unref(active_sensor->notification[notif_type]);
+        active_sensor->notification[notif_type] = NULL;
+    }
+}
+
+void active_sensor_libnotify_notify(ActiveSensor *active_sensor,
+                                    NotifType notif_type,
+                                    const gchar *summary,
+                                    const gchar *message,
+                                    const gchar *icon_filename,
+                                    gint timeout_msecs) {
+
+    GError *error = NULL;
+
+    if (!notify_is_initted()) {
+        if (!notify_init(PACKAGE)) {
+            return;
+        }
+    }
+    g_debug("Doing notification %s: %s: %s", (notif_type == SENSOR_INTERFACE_ERROR ? "interface-error" : "other") ,summary, message);
+
+    /* leave any existing notification since most likely hasn't changed */
+    if (active_sensor->notification[notif_type] != NULL) {
+        return;
+        /* active_sensor_libnotify_notify_end(active_sensor, notif_type); */
+    }
+
+    /* now create a new one */
+    g_debug("Creating new notification");
+    active_sensor->notification[notif_type] = notify_notification_new(summary, message, icon_filename);
+    g_signal_connect(active_sensor->notification[notif_type], "closed",
+                     G_CALLBACK(notif_closed_cb),<--- You might need to cast the function pointer here
+                     active_sensor);
+
+    notify_notification_set_urgency(active_sensor->notification[notif_type], NOTIFY_URGENCY_CRITICAL);
+
+    /* timeout may have changed so update it */
+    notify_notification_set_timeout(active_sensor->notification[notif_type], timeout_msecs);
+
+    g_debug("showing notification");
+    if (!notify_notification_show(active_sensor->notification[notif_type], &error)) {
+        g_debug("Error showing notification: %s", error->message);
+        g_error_free(error);
+    }
+
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/37.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/37.html new file mode 100644 index 0000000..976ed45 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/37.html @@ -0,0 +1,389 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef ACTIVE_SENSOR_H
+#define ACTIVE_SENSOR_H
+
+#ifdef HAVE_LIBNOTIFY
+#include <time.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <libnotify/notify.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "active-sensor-libnotify.h"
+#endif
+
+#include "sensors-applet.h"
+
+struct _ActiveSensor {
+    SensorsApplet *sensors_applet;
+
+    /* widgets to render to display the sensor */
+    GtkWidget *label;
+    GtkWidget *icon;
+    GtkWidget *value;
+    GtkWidget *graph;
+    GtkWidget *graph_frame;
+
+    GdkRGBA graph_color;
+
+    GtkTreeRowReference *sensor_row;
+
+#ifdef HAVE_LIBNOTIFY
+    NotifyNotification *notification[NUM_NOTIFS];
+    /* error timestamp - save the time of the last SENSOR_INTERFACE_ERROR */
+    time_t ierror_ts;
+#endif
+
+    gboolean updated;
+
+    /* alarm related stuff */
+    gint alarm_timeout_id[NUM_ALARMS];
+    gchar *alarm_command[NUM_ALARMS];
+    gint alarm_timeout;
+
+    /* buffer of sensor values */
+    gdouble *sensor_values;
+
+    /* length of sensor_values buffer */
+    gint num_samples;
+
+    gdouble sensor_low_value;
+    gdouble sensor_high_value;
+};
+
+ActiveSensor *active_sensor_new(SensorsApplet *sensors_applet, GtkTreeRowReference *sensor_row);
+void active_sensor_destroy(ActiveSensor *active_sensor);
+gint active_sensor_compare(ActiveSensor *a, ActiveSensor *b);
+void active_sensor_update(ActiveSensor *sensor, SensorsApplet *sensors_applet);
+void active_sensor_icon_changed(ActiveSensor *sensor, SensorsApplet *sensors_applet);
+void active_sensor_update_graph_dimensions(ActiveSensor *as, gint dimensions[2]);
+void active_sensor_alarm_off(ActiveSensor *active_sensor, NotifType notif_type);
+
+#endif /* ACTIVE_SENSOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/38.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/38.html new file mode 100644 index 0000000..ce60570 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/38.html @@ -0,0 +1,1867 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_STRING_H
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_STRING_H */
+
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "active-sensor.h"
+#include "sensors-applet-plugins.h"
+#include "sensors-applet-settings.h"
+
+typedef enum {
+    VERY_LOW_SENSOR_VALUE = 0,
+    LOW_SENSOR_VALUE,
+    NORMAL_SENSOR_VALUE,
+    HIGH_SENSOR_VALUE,
+    VERY_HIGH_SENSOR_VALUE
+} SensorValueRange;
+
+/* Cast a given value to a valid SensorValueRange */
+#define SENSOR_VALUE_RANGE(x) ((SensorValueRange)(CLAMP(x, VERY_LOW_SENSOR_VALUE, VERY_HIGH_SENSOR_VALUE)))
+
+#define CAIRO_GRAPH_COLOR_GRADIENT 0.4
+
+static const gchar * const temp_overlay_icons[] = {
+    PIXMAPS_DIR "very-low-temp-icon.png",
+    PIXMAPS_DIR "low-temp-icon.png",
+    PIXMAPS_DIR "normal-temp-icon.png",
+    PIXMAPS_DIR "high-temp-icon.png",
+    PIXMAPS_DIR "very-high-temp-icon.png"
+};
+
+static gdouble sensor_value_range_normalised(gdouble value,
+                                          gdouble low_value,
+                                          gdouble high_value) {
+
+    return ((value - low_value)/(high_value - low_value));
+}
+
+static SensorValueRange sensor_value_range(gdouble sensor_value,
+                                            gdouble low_value,
+                                            gdouble high_value) {
+
+    gdouble range;
+    range = sensor_value_range_normalised(sensor_value, low_value, high_value)*(gdouble)(VERY_HIGH_SENSOR_VALUE);
+
+    /* check if need to round up, otherwise let int conversion
+     * round down for us and make sure it is a valid range
+     * value */
+    return SENSOR_VALUE_RANGE(((gint)range + ((range - ((gint)range)) >= 0.5)));
+}
+
+static gboolean active_sensor_execute_alarm(ActiveSensor *active_sensor,
+                                            NotifType notif_type) {
+
+    gboolean ret;
+    GError *error = NULL;
+
+    sensors_applet_notify_active_sensor(active_sensor, notif_type);
+    g_debug("EXECUTING %s ALARM: %s",
+            (notif_type == LOW_ALARM ?
+             "LOW" : "HIGH"),
+            active_sensor->alarm_command[notif_type]);
+    ret = g_spawn_command_line_async (active_sensor->alarm_command[notif_type], &error);
+    g_debug("Command executed in shell");
+
+    if (error)
+        g_error_free (error);
+
+    return ret;
+}
+
+static gboolean active_sensor_execute_low_alarm(ActiveSensor *active_sensor) {
+    return active_sensor_execute_alarm(active_sensor, LOW_ALARM);
+}
+
+static gboolean active_sensor_execute_high_alarm(ActiveSensor *active_sensor) {
+    return active_sensor_execute_alarm(active_sensor, HIGH_ALARM);
+}
+
+/* needs to be able to be called by the config dialog when the alarm command changes */
+void active_sensor_alarm_off(ActiveSensor *active_sensor,
+                             NotifType notif_type) {
+
+    g_assert(active_sensor);
+
+    if (active_sensor->alarm_timeout_id[notif_type] != -1) {
+        g_debug("Disabling %s alarm.", (notif_type == LOW_ALARM ? "LOW" : "HIGH"));
+        if (!g_source_remove(active_sensor->alarm_timeout_id[notif_type])) {
+            g_debug("Error removing alarm source");
+        }
+        g_free(active_sensor->alarm_command[notif_type]);
+        active_sensor->alarm_timeout_id[notif_type] = -1;
+
+    }
+    sensors_applet_notify_end(active_sensor, notif_type);
+}
+
+static void active_sensor_all_alarms_off(ActiveSensor *active_sensor) {
+    /* turn off any alarms */
+    int i;
+    for (i = 0; i < NUM_ALARMS; i++) {
+        if (active_sensor->alarm_timeout_id[i] >= 0) {
+            g_debug("-- turning off notif with type %d ---", i);
+            active_sensor_alarm_off(active_sensor, i);
+        }
+    }
+}
+
+static void active_sensor_alarm_on(ActiveSensor *active_sensor,
+                                   NotifType notif_type) {
+
+    GtkTreeModel *model;
+    GtkTreePath *tree_path;
+    GtkTreeIter iter;
+
+    g_assert(active_sensor);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    tree_path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    if (gtk_tree_model_get_iter(model, &iter, tree_path)) {
+
+        if (active_sensor->alarm_timeout_id[notif_type] == -1) {
+            /* alarm is not currently on */
+            gtk_tree_model_get(model,
+                       &iter,
+                       (notif_type == LOW_ALARM ?
+                            LOW_ALARM_COMMAND_COLUMN :
+                            HIGH_ALARM_COMMAND_COLUMN),
+                       &(active_sensor->alarm_command[notif_type]),
+                       ALARM_TIMEOUT_COLUMN, &(active_sensor->alarm_timeout),
+                       -1);
+
+            g_debug("Activating alarm to repeat every %d seconds", active_sensor->alarm_timeout);
+
+            /* execute alarm once, then add to time to keep repeating it */
+            active_sensor_execute_alarm(active_sensor, notif_type);
+            int timeout = (active_sensor->alarm_timeout <= 0 ? G_MAXINT : active_sensor->alarm_timeout);
+            switch (notif_type) {
+                case LOW_ALARM:
+                    active_sensor->alarm_timeout_id[notif_type] = g_timeout_add_seconds(timeout,
+                                                                                        (GSourceFunc)active_sensor_execute_low_alarm,
+                                                                                        active_sensor);
+                    break;
+
+                case HIGH_ALARM:
+                    active_sensor->alarm_timeout_id[notif_type] = g_timeout_add_seconds(timeout,
+                                                                                        (GSourceFunc)active_sensor_execute_high_alarm,
+                                                                                        active_sensor);
+                    break;
+
+                default:
+                    g_debug("Unknown notif type: %d", notif_type);
+            }
+
+        }
+    }
+
+    gtk_tree_path_free(tree_path);
+}
+
+/**
+ * Compares two ActiveSensors and returns -1 if a comes before b in the tree,
+ * 0 if refer to same row, 1 if b comes before a
+ */
+gint active_sensor_compare(ActiveSensor *a, ActiveSensor *b) {
+    GtkTreePath *a_tree_path, *b_tree_path;
+    gint ret_val;
+
+    g_assert(a);
+    g_assert(b);
+
+    a_tree_path = gtk_tree_row_reference_get_path(a->sensor_row);
+    b_tree_path = gtk_tree_row_reference_get_path(b->sensor_row);
+
+    ret_val = gtk_tree_path_compare(a_tree_path, b_tree_path);
+
+    gtk_tree_path_free(a_tree_path);
+    gtk_tree_path_free(b_tree_path);
+
+    return ret_val;
+}
+
+static void active_sensor_update_icon(ActiveSensor *active_sensor,
+                                      GdkPixbuf *base_icon,
+                                      SensorType sensor_type) {
+
+    GdkPixbuf *new_icon;
+    const gchar *overlay_icon_filename = NULL;
+    SensorValueRange value_range;
+
+    g_assert(active_sensor);
+
+    /* select overlay icon depending on sensor value */
+    value_range = sensor_value_range(active_sensor->sensor_values[0],
+                                     active_sensor->sensor_low_value,
+                                     active_sensor->sensor_high_value);
+
+    if (sensor_type == TEMP_SENSOR) {
+        overlay_icon_filename = temp_overlay_icons[value_range];
+    }
+
+    /* load base icon */
+    new_icon = gdk_pixbuf_copy(base_icon);
+
+    /* only load overlay if required */
+    if (overlay_icon_filename) {
+        GdkPixbuf *overlay_icon;
+
+        overlay_icon = gdk_pixbuf_new_from_file_at_size(overlay_icon_filename,
+                                DEFAULT_ICON_SIZE,
+                                DEFAULT_ICON_SIZE,
+                                NULL);
+
+        if (overlay_icon) {
+            gdk_pixbuf_composite(overlay_icon, new_icon,
+                                 0, 0,
+                                 DEFAULT_ICON_SIZE, DEFAULT_ICON_SIZE,
+                                 0, 0,
+                                 1.0, 1.0,
+                                 GDK_INTERP_BILINEAR,
+                                 255);
+
+            g_object_unref(overlay_icon);
+        }
+    }
+
+    gtk_image_set_from_pixbuf(GTK_IMAGE(active_sensor->icon),
+                              new_icon);
+    g_object_unref(new_icon);
+
+}
+
+static void active_sensor_update_graph(ActiveSensor *as, cairo_t *cr) {
+    GtkAllocation allocation;
+    gdouble line_height;
+    gdouble width, height;
+    gdouble x = 0.0, y = 0.0;
+    cairo_pattern_t *pattern;
+    gint i;
+
+    gtk_widget_get_allocation (as->graph, &allocation);
+    width = allocation.width;
+    height = allocation.height;
+
+    /* so we can set a clipping area, as well as fill the * back of the graph black */
+    cairo_rectangle(cr,
+                    0, 0,
+                    width,
+                    height);
+    /* clip to rectangle and keep it as a path so can be
+     * filled below */
+    cairo_clip_preserve(cr);
+
+    /* use black for bg color of graphs */
+    cairo_set_source_rgb(cr, 0.0, 0.0, 0.0);
+    cairo_fill(cr);
+
+    /* determine height to scale line at for each value -
+     * only do as many as will fit or the number of
+     * samples that we have */
+    for (i = 0; i < MIN(as->num_samples, width); i++) {
+        /* need to remove one more to make it line up
+         * properly  when drawing */
+        x = width - i - 1;
+        y = height;
+
+        line_height = sensor_value_range_normalised(as->sensor_values[i],
+                                                    as->sensor_low_value,
+                                                    as->sensor_high_value) * height;
+
+        if (line_height > 0) {
+            cairo_move_to(cr, x, y);
+            cairo_line_to(cr, x, y - line_height);
+        }
+    }
+
+    /* make lines a gradient from slightly darker than
+     * chosen color at bottom of graph, to slightly
+     * lighter than chosen color at top of graph */
+    pattern = cairo_pattern_create_linear(x, y, x, 0);
+    cairo_pattern_add_color_stop_rgb(pattern,
+                                     0,
+                                     as->graph_color.red - CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.green - CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.blue - CAIRO_GRAPH_COLOR_GRADIENT);
+
+    cairo_pattern_add_color_stop_rgb(pattern,
+                                     height,
+                                     as->graph_color.red + CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.green + CAIRO_GRAPH_COLOR_GRADIENT,
+                                     as->graph_color.blue + CAIRO_GRAPH_COLOR_GRADIENT);
+
+    cairo_set_source(cr, pattern);
+    cairo_stroke(cr);
+    cairo_pattern_destroy(pattern);
+}
+
+void active_sensor_destroy(ActiveSensor *active_sensor) {
+    g_debug("-- destroying active sensor label...");
+    gtk_widget_destroy(active_sensor->label);
+
+    g_debug("-- destroying active sensor icon..");
+    gtk_widget_destroy(active_sensor->icon);
+
+    g_debug("-- destroying active sensor value...");
+    gtk_widget_destroy(active_sensor->value);
+
+    g_debug("-- destroying active sensor graph and frame...");
+    gtk_widget_destroy(active_sensor->graph);
+    gtk_widget_destroy(active_sensor->graph_frame);
+
+    g_debug("-- destroying active sensor values...");
+    g_free(active_sensor->sensor_values);
+
+    active_sensor_all_alarms_off(active_sensor);
+
+    g_free(active_sensor);
+}
+
+static
+gboolean graph_draw_cb(GtkWidget *graph,
+                       cairo_t *cr,
+                       gpointer data) {
+
+    ActiveSensor *as;
+
+    as = (ActiveSensor *)data;
+
+    active_sensor_update_graph(as, cr);
+    /* propagate event onwards */
+
+    return FALSE;
+}
+
+static void active_sensor_set_graph_dimensions(ActiveSensor *as,
+                                               gint width,
+                                               gint height) {
+
+    gint num_samples, old_num_samples;
+    gint graph_width, graph_height;
+
+    /* dimensions are really for graph frame, so need to remove
+     * extra width added by graph frame - make sure not less than
+     * 1 - always need atleast 1 sample */
+    graph_width = CLAMP(width - GRAPH_FRAME_EXTRA_WIDTH, 1, width - GRAPH_FRAME_EXTRA_WIDTH);
+    graph_height = CLAMP(height - GRAPH_FRAME_EXTRA_WIDTH, 1 , height - GRAPH_FRAME_EXTRA_WIDTH);
+
+    g_debug("setting graph dimensions to %d x %d", graph_width, graph_height);
+    num_samples = graph_width;
+
+    if (as->sensor_values) {
+        gdouble *old_values;
+
+        old_values = as->sensor_values;
+        old_num_samples = as->num_samples;
+
+        as->num_samples = num_samples;
+        as->sensor_values = g_new0 (gdouble, as->num_samples);
+        memcpy(as->sensor_values,
+               old_values,
+               MIN(old_num_samples, as->num_samples)*sizeof(gdouble));
+
+        g_free(old_values);
+    } else {
+        as->sensor_values = g_new0 (gdouble, num_samples);
+        as->num_samples = num_samples;
+    }
+
+    /* update graph frame size request */
+    gtk_widget_set_size_request(as->graph,
+                                graph_width,
+                                graph_height);
+}
+
+void active_sensor_update_graph_dimensions(ActiveSensor *as,
+                                     gint sizes[2]) {
+
+    active_sensor_set_graph_dimensions(as, sizes[0], sizes[1]);
+    gtk_widget_queue_draw (as->graph);
+}
+
+ActiveSensor *active_sensor_new(SensorsApplet *sensors_applet,
+                                GtkTreeRowReference *sensor_row) {
+
+    ActiveSensor *active_sensor;
+    MatePanelAppletOrient orient;
+    gint graph_size;
+    gboolean horizontal;
+
+    g_assert(sensors_applet);
+    g_assert(sensor_row);
+
+    g_debug("creating new active sensor");
+
+    active_sensor = g_new0(ActiveSensor, 1);
+    active_sensor->sensors_applet = sensors_applet;
+
+    active_sensor->sensor_row = sensor_row;
+
+#ifdef HAVE_LIBNOTIFY
+    /* set a base time, creation -5 minutes */
+    active_sensor->ierror_ts = time(NULL) - 300;
+#endif
+
+    int i;
+    for (i = 0; i < NUM_ALARMS; i++) {
+        active_sensor->alarm_timeout_id[i] = -1;
+    }
+
+    active_sensor->label = gtk_label_new("");
+    active_sensor->value = gtk_label_new("");
+    active_sensor->icon = gtk_image_new();
+
+    active_sensor->graph = gtk_drawing_area_new();
+    active_sensor->graph_frame = gtk_frame_new(NULL);
+    gtk_frame_set_shadow_type(GTK_FRAME(active_sensor->graph_frame),
+                              GTK_SHADOW_IN);
+    gtk_container_add(GTK_CONTAINER(active_sensor->graph_frame),
+                      active_sensor->graph);
+    gtk_widget_add_events(active_sensor->graph_frame,
+                          GDK_ALL_EVENTS_MASK);
+
+    /* need to set size according to orientation */
+    orient = mate_panel_applet_get_orient(active_sensor->sensors_applet->applet);
+    graph_size = g_settings_get_int(active_sensor->sensors_applet->settings, GRAPH_SIZE);
+
+    horizontal = ((orient == MATE_PANEL_APPLET_ORIENT_UP) ||
+                  (orient == MATE_PANEL_APPLET_ORIENT_DOWN));
+
+    active_sensor_set_graph_dimensions(active_sensor,
+                                       (horizontal ? graph_size : sensors_applet->size),
+                                       (horizontal ? sensors_applet->size : graph_size));
+
+    g_signal_connect(G_OBJECT(active_sensor->graph),
+                     "draw",
+                     G_CALLBACK(graph_draw_cb),
+                     active_sensor);
+
+    active_sensor->updated = FALSE;
+    return active_sensor;
+}
+
+static void active_sensor_update_sensor_value(ActiveSensor *as,
+                                              gdouble sensor_value) {
+
+    /* only if have more than 1 sample stored */
+    if (as->num_samples > 1) {
+        memmove(&(as->sensor_values[1]),
+                as->sensor_values,
+                (as->num_samples - 1)*sizeof(gdouble));
+    }
+
+    as->sensor_values[0] = sensor_value;
+}
+
+void active_sensor_update(ActiveSensor *active_sensor,
+                          SensorsApplet *sensors_applet) {
+
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+
+    /* instance data from the tree for this sensor */
+    gchar *sensor_path = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_label = NULL;
+    SensorType sensor_type;
+    gchar *sensor_interface;
+    gboolean sensor_enabled;
+    gdouble sensor_low_value;
+    gdouble sensor_high_value;
+    gboolean sensor_alarm_enabled;
+    gdouble sensor_multiplier;
+    gdouble sensor_offset;
+    gdouble sensor_value;
+    GdkPixbuf *icon_pixbuf;
+    gchar *graph_color;
+    gint label_min_width;
+    GtkRequisition  req;
+
+    /* to build the list of labels as we go */
+    gchar *value_text = NULL;
+
+    TemperatureScale scale;
+    DisplayMode display_mode;
+
+    GError *error = NULL;
+
+    gchar *tooltip = NULL;
+    gchar *value_tooltip = NULL;
+
+    /* hidden gsettings options */
+    gint font_size = 0;
+    gboolean hide_units = FALSE;
+    gboolean hide_units_old = FALSE;
+
+    g_assert(active_sensor);
+    g_assert(active_sensor->sensor_row);
+    g_assert(sensors_applet);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    /* if can successfully get iter can proceed */
+    if (gtk_tree_model_get_iter(model, &iter, path)) {
+        gtk_tree_path_free(path);
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                   &iter,
+                   PATH_COLUMN, &sensor_path,
+                   ID_COLUMN, &sensor_id,
+                   LABEL_COLUMN, &sensor_label,
+                   INTERFACE_COLUMN, &sensor_interface,
+                   SENSOR_TYPE_COLUMN, &sensor_type,
+                   ENABLE_COLUMN, &sensor_enabled,
+                   LOW_VALUE_COLUMN, &sensor_low_value,
+                   HIGH_VALUE_COLUMN, &sensor_high_value,
+                   ALARM_ENABLE_COLUMN, &sensor_alarm_enabled,
+                   MULTIPLIER_COLUMN, &sensor_multiplier,
+                   OFFSET_COLUMN, &sensor_offset,
+                   ICON_PIXBUF_COLUMN, &icon_pixbuf,
+                   GRAPH_COLOR_COLUMN, &graph_color,
+                   -1);
+
+        SensorsAppletPluginGetSensorValue get_sensor_value;
+        /* only call function if is in hash table for plugin */
+        if ((get_sensor_value = sensors_applet_plugins_get_sensor_value_func(sensors_applet, sensor_interface)) != NULL) {
+            sensor_value = get_sensor_value(sensor_path,
+                                            sensor_id,
+                                            sensor_type,
+                                            &error);
+
+            if (error) {
+                g_debug("Error updating active sensor: %s", error->message);
+                sensors_applet_notify_active_sensor(active_sensor,
+                                                    SENSOR_INTERFACE_ERROR);
+
+                /* hard code text as ERROR */
+                value_text = g_strdup(_("ERROR"));
+                value_tooltip = g_strdup_printf("- %s", error->message);
+                g_error_free(error);
+                error = NULL;
+
+                /* set sensor value to an error code -
+                 * note this is not unique */
+                sensor_value = -1;
+            } else {
+                /* use hidden gsettings key for hide_units */
+                hide_units_old = hide_units;
+                hide_units = g_settings_get_boolean(sensors_applet->settings, HIDE_UNITS);
+
+                /* scale value and set text using this value */
+                switch (sensor_type) {
+                    case TEMP_SENSOR:
+                        scale = (TemperatureScale) g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE);
+                        /* scale value */
+                        sensor_value = sensors_applet_convert_temperature(sensor_value, CELSIUS, scale);
+
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        switch (scale) {
+                            case FAHRENHEIT:
+                                value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_FAHRENHEIT));
+                                /* tooltip should
+                                 * always display
+                                 * units */
+                                value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_FAHRENHEIT);
+
+                                break;
+                            case CELSIUS:
+                                value_text = g_strdup_printf("%2.0f %s", sensor_value, (hide_units ? "" : UNITS_CELSIUS));
+                                value_tooltip = g_strdup_printf("%2.0f %s", sensor_value, UNITS_CELSIUS);
+                                break;
+                            case KELVIN:
+                                value_text = g_strdup_printf("%2.0f", sensor_value);
+                                value_tooltip = g_strdup(value_text);
+                                break;
+                        }
+                        break;
+
+                    case FAN_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.0f %s", sensor_value, (hide_units ? "" : UNITS_RPM));
+                        value_tooltip = g_strdup_printf("%4.0f %s", sensor_value, UNITS_RPM);
+                        break;
+
+                    case VOLTAGE_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_VOLTAGE));
+                        value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_VOLTAGE);
+                        break;
+
+                    case CURRENT_SENSOR:
+                        sensor_value = (sensor_value * sensor_multiplier) + sensor_offset;
+                        value_text = g_strdup_printf("%4.2f %s", sensor_value, (hide_units ? "" : UNITS_CURRENT));
+                        value_tooltip = g_strdup_printf("%4.2f %s", sensor_value, UNITS_CURRENT);
+                        break;
+
+                } /* end switch(sensor_type) */
+            } /* end else on error */
+
+            /* setup for tooltips */
+            if (sensors_applet->show_tooltip)
+                    tooltip = g_strdup_printf("%s %s", sensor_label, value_tooltip);
+            g_free(value_tooltip);
+
+            /* only do icons and labels / graphs if needed */
+            display_mode = g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+
+            /* most users wont have a font size set */
+            font_size = g_settings_get_int (sensors_applet->settings, FONT_SIZE);
+
+            /* do icon if needed */
+            if (display_mode == DISPLAY_ICON ||
+                display_mode == DISPLAY_ICON_WITH_VALUE) {
+
+                /* update icon if icon range has changed if no
+                 * update has been done before */
+                if ((sensor_value_range(sensor_value, sensor_low_value, sensor_high_value) != sensor_value_range(active_sensor->sensor_values[0], active_sensor->sensor_low_value, active_sensor->sensor_high_value)) ||
+                    !(active_sensor->updated)) {
+
+                    active_sensor_update_sensor_value(active_sensor, sensor_value);
+                    active_sensor->sensor_low_value = sensor_low_value;
+                    active_sensor->sensor_high_value = sensor_high_value;
+                    active_sensor_update_icon(active_sensor, icon_pixbuf, sensor_type);
+                }
+
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->icon, tooltip);
+                }
+            }
+
+            active_sensor_update_sensor_value(active_sensor, sensor_value);
+            active_sensor->sensor_low_value = sensor_low_value;
+            active_sensor->sensor_high_value = sensor_high_value;
+
+            /* do graph if needed */
+            if (display_mode == DISPLAY_GRAPH) {
+                /* update graph color in case has changed */
+                gdk_rgba_parse(&(active_sensor->graph_color), graph_color);
+
+                gtk_widget_queue_draw (active_sensor->graph);
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->graph, tooltip);
+                }
+            }
+
+            gchar *old_value_text = value_text;
+
+            if (sensor_alarm_enabled) {
+                if (sensor_value >= sensor_high_value || sensor_value <= sensor_low_value) {
+
+                    /* make value text red and
+                     * activate alarm */
+                    if (display_mode == DISPLAY_LABEL_WITH_VALUE ||
+                        display_mode == DISPLAY_ICON_WITH_VALUE ||
+                        display_mode == DISPLAY_VALUE) {
+
+                        value_text = g_markup_printf_escaped("<span foreground=\"#FF0000\">%s</span>", old_value_text);
+                        g_free(old_value_text);
+                    }
+
+                    /* could have both coditions at once */
+                    if (sensor_value >= sensor_high_value) {
+                        active_sensor_alarm_on(active_sensor, HIGH_ALARM);
+                    }
+
+                    if (sensor_value <= sensor_low_value) {
+                        active_sensor_alarm_on(active_sensor, LOW_ALARM);
+                    }
+
+                } else {
+                    /* make sure alarms are off */
+                    active_sensor_all_alarms_off(active_sensor);
+                }
+            } else {
+                /* else for if alarm enabled */
+                /* make sure all alarms are off */
+                active_sensor_all_alarms_off(active_sensor);
+            }
+
+            /* do value label */
+            if (display_mode == DISPLAY_LABEL_WITH_VALUE ||
+                display_mode == DISPLAY_ICON_WITH_VALUE ||
+                display_mode == DISPLAY_VALUE) {
+
+                if (font_size) {
+                    old_value_text = value_text;
+
+                    value_text = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text);
+                    g_free(old_value_text);
+                }
+
+                /*Keep the label as large as previous size unless hide_units has changed */
+                gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value), &req, NULL);
+                if (!(hide_units_old == hide_units)) {
+                    label_min_width = 0;
+                } else {
+                    label_min_width = req.width;
+                }
+
+                gtk_label_set_markup(GTK_LABEL(active_sensor->value), value_text);
+
+                gtk_widget_get_preferred_size (GTK_WIDGET (active_sensor->value), &req, NULL);
+                gtk_widget_set_size_request (GTK_WIDGET (active_sensor->value), label_min_width, req.height);
+
+                if (tooltip) {
+                    gtk_widget_set_tooltip_text(active_sensor->value, tooltip);
+                }
+            }
+            /* finished with value text */
+            g_free(value_text);
+
+            /* do label label */
+            if (display_mode == DISPLAY_LABEL_WITH_VALUE) {
+                if (font_size) {
+                    old_value_text = sensor_label;
+                    sensor_label = g_strdup_printf("<span font_desc=\"%d\">%s</span>", font_size, old_value_text);
+                    g_free(old_value_text);
+                }
+
+                gtk_label_set_markup(GTK_LABEL(active_sensor->label), sensor_label);
+                if (tooltip) {
+                        gtk_widget_set_tooltip_text(active_sensor->label, tooltip);
+                }
+            }
+
+            g_free(tooltip);
+        } else {
+            g_debug("no get_sensor_value function yet installed for interface %s.", sensor_interface);
+        }
+
+        g_free(sensor_path);
+        g_free(sensor_id);
+        g_free(sensor_label);
+        g_free(sensor_interface);
+        g_free(graph_color);
+        g_object_unref(icon_pixbuf);
+
+    } else {
+        g_debug("Error getting iter when updating sensor...");
+    }
+
+    active_sensor->updated = TRUE;
+
+}
+
+/* to be called when the icon within the GtkRowReference that this
+ * sensor references is changed - updates icon based upon value in the
+ * ActiveSensor */
+void active_sensor_icon_changed(ActiveSensor *active_sensor, SensorsApplet *sensors_applet) {
+
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    SensorType sensor_type;
+    GdkPixbuf *icon_pixbuf;
+
+    g_assert(active_sensor);
+    g_assert(sensors_applet);
+
+    model = gtk_tree_row_reference_get_model(active_sensor->sensor_row);
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+
+    /* if can successfully get iter can proceed */
+    if (gtk_tree_model_get_iter(model, &iter, path)) {
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                                           &iter,
+                                           SENSOR_TYPE_COLUMN, &sensor_type,
+                                           ICON_PIXBUF_COLUMN, &icon_pixbuf,
+                                           -1);
+
+        active_sensor_update_icon(active_sensor, icon_pixbuf, sensor_type);
+        g_object_unref(icon_pixbuf);
+    }
+    gtk_tree_path_free(path);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/39.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/39.html new file mode 100644 index 0000000..14f880f --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/39.html @@ -0,0 +1,357 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ *               2013 Stefano Karapetsas <stefano@karapetsas.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SENSORS_APPLET_SETTINGS_H
+#define SENSORS_APPLET_SETTINGS_H
+
+#include "sensors-applet.h"
+#include <mate-panel-applet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <mate-panel-applet-gsettings.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#define FONT_SIZE             "font-size"
+#define HIDE_UNITS            "hide-units"
+#define DISPLAY_MODE          "display-mode"
+#define LAYOUT_MODE           "layout-mode"
+#define TEMPERATURE_SCALE     "temperature-scale"
+#define DISPLAY_NOTIFICATIONS "display-notifications"
+#define TIMEOUT               "timeout-delay"
+#define GRAPH_SIZE            "graph-size"
+#define SENSORS_LIST          "sensors-list"
+
+#define PATH                  "path"
+#define ID                    "id"
+#define INTERFACE             "interface"
+#define LABEL                 "label"
+#define ENABLED               "enabled"
+#define LOW_VALUE             "low-value"
+#define HIGH_VALUE            "high-value"
+#define ALARM_ENABLED         "alarm-enabled"
+#define LOW_ALARM_COMMAND     "low-alarm-command"
+#define HIGH_ALARM_COMMAND    "high-alarm-command"
+#define ALARM_TIMEOUT         "alarm-timeout"
+#define SENSOR_TYPE           "sensor-type"
+#define MULTIPLIER            "multiplier"
+#define OFFSET                "offset"
+#define ICON_TYPE             "icon-type"
+#define GRAPH_COLOR           "graph-color"
+
+gchar* sensors_applet_settings_get_unique_id (const gchar *interface, const gchar *id, const gchar *path);
+gboolean sensors_applet_settings_load_sensors (SensorsApplet *sensors_applet);
+gboolean sensors_applet_settings_sort_sensors (SensorsApplet *sensors_applet);
+gboolean sensors_applet_settings_save_sensors (SensorsApplet *sensors_applet);
+
+#endif /* SENSORS_APPLET_SETTINGS_H*/
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/4.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/4.html new file mode 100644 index 0000000..e996c23 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/4.html @@ -0,0 +1,289 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
/*
+ * Copyright (C) 2018 info-cppsp <info@cppsp.de>
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef DUMMY_PLUGIN_H
+#define DUMMY_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* DUMMY_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/40.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/40.html new file mode 100644 index 0000000..8393ba4 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/40.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <mate-panel-applet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensors-applet.h"
+
+static gboolean sensors_applet_fill(MatePanelApplet *applet,
+                                    const gchar *iid,
+                                    gpointer data) {
+
+    gboolean retval = FALSE;
+
+    if (strcmp(iid, "SensorsApplet") == 0) {
+        SensorsApplet *sensors_applet;
+
+        sensors_applet = g_new0(SensorsApplet, 1);
+        sensors_applet->applet = applet;
+        sensors_applet_init(sensors_applet);
+        retval = TRUE;
+    }
+    return retval;
+}
+
+PANEL_APPLET_FACTORY ("SensorsAppletFactory",
+                      PANEL_TYPE_APPLET,
+                      "SensorsApplet",
+                      sensors_applet_fill,
+                      NULL);
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/41.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/41.html new file mode 100644 index 0000000..f38ce9d --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/41.html @@ -0,0 +1,2085 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
+829
+830
+831
+832
+833
+834
+835
+836
+837
+838
+839
+840
+841
+842
+843
+844
+845
+846
+847
+848
+849
+850
+851
+852
+853
+854
+855
+856
+857
+858
+859
+860
+861
+862
+863
+864
+865
+866
+867
+868
+869
+870
+871
+872
+873
+874
+875
+876
+877
+878
+879
+880
+881
+882
+883
+884
+885
+886
+887
+888
+889
+890
+891
+892
+893
+894
+895
+896
+897
+898
+899
+900
+901
+902
+903
+904
+905
+906
+907
+908
+909
+910
+911
+912
+913
+914
+915
+916
+917
+918
+919
+920
+921
+922
+923
+924
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensors-applet-settings.h"
+#include "prefs-dialog.h"
+#include "sensor-config-dialog.h"
+
+#define OLD_TEMP_SCALE 0
+#define NEW_TEMP_SCALE 1
+
+/* when a user closes the prefs-dialog we assume that applet is now
+   setup, so store all values in gsettings */
+void prefs_dialog_close(SensorsApplet *sensors_applet) {
+
+    if (sensors_applet->sensors != NULL) {
+        sensors_applet_settings_save_sensors(sensors_applet);
+    }
+
+    if (sensors_applet->prefs_dialog) {
+        gtk_widget_destroy(GTK_WIDGET(sensors_applet->prefs_dialog->dialog));
+        g_free(sensors_applet->prefs_dialog);
+        sensors_applet->prefs_dialog = NULL;
+    }
+
+    if (sensors_applet->timeout_id == 0) {
+        sensors_applet->timeout_id = g_timeout_add_seconds(g_settings_get_int (sensors_applet->settings, TIMEOUT) / 1000, (GSourceFunc)sensors_applet_update_active_sensors, sensors_applet);
+    }
+
+}
+
+static
+void prefs_dialog_response(GtkDialog *prefs_dialog,
+                           gint response,
+                           gpointer data) {
+
+    SensorsApplet *sensors_applet;
+    GError *error = NULL;
+    gint current_page;
+    gchar *uri;
+
+    sensors_applet = (SensorsApplet *)data;
+
+    switch (response) {
+        case GTK_RESPONSE_HELP:
+            g_debug("loading help in prefs");
+            current_page = gtk_notebook_get_current_page(sensors_applet->prefs_dialog->notebook);
+            uri = g_strdup_printf("help:mate-sensors-applet/%s",
+                          ((current_page == 0) ?
+                           "sensors-applet-general-options" :
+                           ((current_page == 1) ?
+                        "sensors-applet-sensors" :
+                        NULL)));
+            gtk_show_uri_on_window(NULL, uri, gtk_get_current_event_time(), &error);
+            g_free(uri);
+
+            if (error) {
+                g_debug("Could not open help document: %s ",error->message);
+                g_error_free (error);
+            }
+            break;
+        default:
+            g_debug("closing prefs dialog");
+            prefs_dialog_close(sensors_applet);
+    }
+}
+
+static gboolean prefs_dialog_convert_low_and_high_values(GtkTreeModel *model,
+                                                         GtkTreePath *path,
+                                                         GtkTreeIter *iter,
+                                                         TemperatureScale scales[2]) {
+
+    SensorType sensor_type;
+    gdouble low_value, high_value;
+
+    gtk_tree_model_get(model,
+                       iter,
+                       SENSOR_TYPE_COLUMN, &sensor_type,
+                       LOW_VALUE_COLUMN, &low_value,
+                       HIGH_VALUE_COLUMN, &high_value,
+                       -1);
+
+    if (sensor_type == TEMP_SENSOR) {
+        low_value = sensors_applet_convert_temperature(low_value,
+                                                       scales[OLD_TEMP_SCALE],
+                                                       scales[NEW_TEMP_SCALE]);
+
+        high_value = sensors_applet_convert_temperature(high_value,
+                                                        scales[OLD_TEMP_SCALE],
+                                                        scales[NEW_TEMP_SCALE]);
+
+        gtk_tree_store_set(GTK_TREE_STORE(model),
+                           iter,
+                           LOW_VALUE_COLUMN, low_value,
+                           HIGH_VALUE_COLUMN, high_value,
+                           -1);
+    }
+    return FALSE;
+}
+
+static void prefs_dialog_timeout_changed(GtkSpinButton *button,
+                                         PrefsDialog *prefs_dialog) {
+
+    gint value;
+    value = (gint)(gtk_spin_button_get_value(button) * 1000);
+    g_settings_set_int (prefs_dialog->sensors_applet->settings, TIMEOUT, value);
+}
+
+static void prefs_dialog_display_mode_changed(GtkComboBox *display_mode_combo_box,
+                                              PrefsDialog *prefs_dialog) {
+
+    int display_mode;
+
+    display_mode = gtk_combo_box_get_active(display_mode_combo_box);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
+                             (display_mode != DISPLAY_ICON) &&
+                             (display_mode != DISPLAY_VALUE) &&
+                             (display_mode != DISPLAY_GRAPH));
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+                             (display_mode != DISPLAY_ICON) &&
+                             (display_mode != DISPLAY_VALUE) &&
+                             (display_mode != DISPLAY_GRAPH));
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label),
+                             (display_mode == DISPLAY_GRAPH));
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
+                             (display_mode == DISPLAY_GRAPH));
+
+    g_settings_set_int (prefs_dialog->sensors_applet->settings,
+                        DISPLAY_MODE,
+                        gtk_combo_box_get_active(display_mode_combo_box));
+
+    sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
+}
+
+static void prefs_dialog_layout_mode_changed(GtkComboBox *layout_mode_combo_box,
+                                             PrefsDialog *prefs_dialog) {
+
+    g_settings_set_int (prefs_dialog->sensors_applet->settings,
+                        LAYOUT_MODE,
+                        gtk_combo_box_get_active(layout_mode_combo_box));
+
+    sensors_applet_display_layout_changed(prefs_dialog->sensors_applet);
+}
+
+static void prefs_dialog_temperature_scale_changed(GtkComboBox *temperature_scale_combo_box,
+                                                   PrefsDialog *prefs_dialog) {
+
+    /* get old temp scale value */
+    TemperatureScale scales[2];
+    GtkTreeModel *model;
+
+    scales[OLD_TEMP_SCALE] = (TemperatureScale) g_settings_get_int (prefs_dialog->sensors_applet->settings, TEMPERATURE_SCALE);
+
+    scales[NEW_TEMP_SCALE] = (TemperatureScale)gtk_combo_box_get_active(temperature_scale_combo_box);
+
+    g_settings_set_int (prefs_dialog->sensors_applet->settings,
+                        TEMPERATURE_SCALE,
+                        scales[NEW_TEMP_SCALE]);
+
+    /* now go thru and convert all low and high sensor values in
+     * the tree to either celcius or Fahrenheit */
+    model = gtk_tree_view_get_model(prefs_dialog->view);
+    gtk_tree_model_foreach(model,
+                           (GtkTreeModelForeachFunc)prefs_dialog_convert_low_and_high_values,
+                           scales);
+
+    /* finally update display of active sensors */
+    sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
+}
+
+// hide/show units
+static void prefs_dialog_show_units_toggled (GtkCheckButton *show_units, PrefsDialog *prefs_dialog) {
+    gboolean state;
+
+    state = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (show_units));
+    g_settings_set_boolean (prefs_dialog->sensors_applet->settings, HIDE_UNITS, !state);
+    sensors_applet_update_active_sensors (prefs_dialog->sensors_applet);
+}
+
+#ifdef HAVE_LIBNOTIFY
+static void prefs_dialog_display_notifications_toggled(GtkCheckButton *display_notifications,
+                                                       PrefsDialog *prefs_dialog) {
+
+    gboolean notify;
+
+    notify = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(display_notifications));
+    g_settings_set_boolean(prefs_dialog->sensors_applet->settings,
+                           DISPLAY_NOTIFICATIONS,
+                           notify);
+
+    if (notify) {
+        sensors_applet_update_active_sensors(prefs_dialog->sensors_applet);
+    } else {
+        sensors_applet_notify_end_all(prefs_dialog->sensors_applet);
+    }
+}
+#endif
+
+static void prefs_dialog_graph_size_changed(GtkSpinButton *button,
+                                            PrefsDialog *prefs_dialog) {
+
+    gint value;
+    value = (gint)(gtk_spin_button_get_value(button));
+    g_settings_set_int(prefs_dialog->sensors_applet->settings, GRAPH_SIZE, value);
+
+    /* notify change of number of samples */
+    sensors_applet_graph_size_changed(prefs_dialog->sensors_applet);
+
+}
+
+/* callbacks for the tree of sensors */
+static void prefs_dialog_sensor_toggled(GtkCellRenderer *renderer, gchar *path_str, PrefsDialog *prefs_dialog) {
+    GtkTreeIter iter;
+    GtkTreePath *path;
+
+    gboolean old_value;
+
+    path = gtk_tree_path_new_from_string(path_str);
+
+    gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
+    gtk_tree_model_get(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors),
+                       &iter,
+                       ENABLE_COLUMN, &old_value,
+                       -1);
+
+    if (old_value) {
+        sensors_applet_sensor_disabled(prefs_dialog->sensors_applet, path);
+    } else {
+        sensors_applet_sensor_enabled(prefs_dialog->sensors_applet, path);
+    }
+
+    gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter,
+                       ENABLE_COLUMN, !old_value,
+                       -1);
+
+    gtk_tree_path_free(path);
+}
+
+static void prefs_dialog_sensor_name_changed(GtkCellRenderer *renderer, gchar *path_str, gchar *new_text, PrefsDialog *prefs_dialog) {
+    GtkTreeIter iter;
+    GtkTreePath *path = gtk_tree_path_new_from_string(path_str);
+
+    gtk_tree_model_get_iter(GTK_TREE_MODEL(prefs_dialog->sensors_applet->sensors), &iter, path);
+
+    gtk_tree_store_set(prefs_dialog->sensors_applet->sensors, &iter, LABEL_COLUMN, new_text, -1);
+
+    sensors_applet_update_sensor(prefs_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void prefs_dialog_row_activated(GtkTreeView *view, GtkTreePath *path, GtkTreeViewColumn *column, PrefsDialog *prefs_dialog) {
+    /* only bring up dialog this if is a sensor - ie has no
+     * children */
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+
+    model = gtk_tree_view_get_model(view);
+    /* make sure can set iter first */
+    if (gtk_tree_model_get_iter(model, &iter, path) && !gtk_tree_model_iter_has_child(model, &iter)) {
+        sensor_config_dialog_create(prefs_dialog->sensors_applet);
+    }
+}
+
+static void prefs_dialog_sensor_up_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
+        /* if has no prev node set up button insentive */
+        GtkTreePath *path;
+
+        path = gtk_tree_model_get_path(model, &iter);
+        if (gtk_tree_path_prev(path)) {
+
+            GtkTreeIter prev_iter;
+            /* check is a valid node in out model */
+            if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
+
+                gtk_tree_store_move_before(GTK_TREE_STORE(model),
+                                           &iter,
+                                           &prev_iter);
+                g_signal_emit_by_name(prefs_dialog->sensors_applet->selection, "changed");
+                sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
+
+            }
+        }
+
+        gtk_tree_path_free(path);
+
+    }
+}
+
+static void prefs_dialog_sensor_down_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkTreeIter iter_next;
+
+    if (gtk_tree_selection_get_selected(prefs_dialog->sensors_applet->selection, &model, &iter)) {
+        iter_next = iter;
+        /* if has no next node set down button insentive */
+        if (gtk_tree_model_iter_next(model, &iter_next)) {
+
+                gtk_tree_store_move_after(GTK_TREE_STORE(model),
+                                          &iter,
+                                          &iter_next);
+                g_signal_emit_by_name(prefs_dialog->sensors_applet->selection, "changed");
+                sensors_applet_reorder_sensors(prefs_dialog->sensors_applet);
+
+        }
+    }
+}
+
+static void prefs_dialog_sensor_config_button_clicked(GtkButton *button, PrefsDialog *prefs_dialog) {
+    sensor_config_dialog_create(prefs_dialog->sensors_applet);
+}
+
+/* if a sensor is selected, make config sure button is able to be
+ * clicked and also set the sensitivities properly for the up and down
+ * buttons */
+static void prefs_dialog_selection_changed(GtkTreeSelection *selection,
+                                           PrefsDialog *prefs_dialog) {
+
+    GtkTreeIter iter;
+    GtkTreeModel *model;
+
+    /* if there is a selection with no children make config button sensitive */
+    if (gtk_tree_selection_get_selected(selection, &model, &iter)) {
+        GtkTreePath *path;
+
+        if (!gtk_tree_model_iter_has_child(model, &iter)) {
+            gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), TRUE);
+        } else {
+            /* otherwise make insensitive */
+            gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
+        }
+
+        /* if has no prev node set up button insentive */
+        path = gtk_tree_model_get_path(model, &iter);
+        if (gtk_tree_path_prev(path)) {
+            GtkTreeIter prev_iter;
+            /* check is a valid node in out model */
+            if (gtk_tree_model_get_iter(model, &prev_iter, path)) {
+                gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), TRUE);
+            } else {
+                gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+            }
+        }  else {
+            gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+        }
+
+        gtk_tree_path_free(path);
+
+        /* if has no next node set down button insentive */
+        if (gtk_tree_model_iter_next(model, &iter)) {
+            gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), TRUE);
+        } else {
+            gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
+        }
+
+    } else {
+        /* otherwise make all insensitive */
+        gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_config_button), FALSE);
+        gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+        gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
+
+    }
+}
+
+void prefs_dialog_open(SensorsApplet *sensors_applet) {
+    gchar *header_text;
+    PrefsDialog *prefs_dialog;
+    DisplayMode display_mode;
+    GtkWidget *content_area;
+
+    g_assert(sensors_applet->prefs_dialog == NULL);
+
+    /* while prefs dialog is open, stop the updating of sensors so
+     * we don't get any race conditions due to concurrent updates
+     * of the labels, values and icons linked lists etc. */
+    if (sensors_applet->timeout_id != 0) {
+        if (g_source_remove(sensors_applet->timeout_id)) {
+            sensors_applet->timeout_id = 0;
+        }
+    }
+
+    sensors_applet->prefs_dialog = g_new0(PrefsDialog, 1);
+    prefs_dialog = sensors_applet->prefs_dialog;
+
+    prefs_dialog->sensors_applet = sensors_applet;
+
+    prefs_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(_("Sensors Applet Preferences"),
+                                                                  NULL,
+                                                                  0,
+                                                                  "gtk-help",
+                                                                  GTK_RESPONSE_HELP,
+                                                                  "gtk-close",
+                                                                  GTK_RESPONSE_CLOSE,
+                                                                  NULL));
+
+    gtk_window_set_icon_name(GTK_WINDOW(prefs_dialog->dialog), "mate-sensors-applet");
+
+    g_object_set(prefs_dialog->dialog,
+                 "border-width", 12,
+                 "default-width", 480,
+                 "default-height", 350,
+                 NULL);
+
+    content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
+    gtk_box_set_homogeneous(GTK_BOX(content_area), FALSE);
+
+    gtk_box_set_spacing(GTK_BOX(content_area), 5);
+
+    g_signal_connect(prefs_dialog->dialog,
+                     "response", G_CALLBACK(prefs_dialog_response),
+                     sensors_applet);
+
+    g_signal_connect_swapped(prefs_dialog->dialog,
+                             "delete-event", G_CALLBACK(prefs_dialog_close),
+                             sensors_applet);
+
+    g_signal_connect_swapped(prefs_dialog->dialog,
+                             "destroy", G_CALLBACK(prefs_dialog_close),
+                             sensors_applet);
+
+    /* if no SensorsList's have been created, this is because
+       we haven't been able to access any sensors */
+    if (sensors_applet->sensors == NULL) {
+        GtkWidget *label = gtk_label_new(_("No sensors found!"));
+        gtk_box_pack_start (GTK_BOX(content_area), label, FALSE, FALSE, 0);
+        return;
+    }
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Display"));
+    prefs_dialog->display_header = g_object_new(GTK_TYPE_LABEL,
+                                                "use-markup", TRUE,
+                                                "label", header_text,
+                                                "xalign", 0.0,
+                                                NULL);
+    g_free(header_text);
+
+    prefs_dialog->display_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+    /*expand the whole column */
+    gtk_widget_set_hexpand(GTK_WIDGET(prefs_dialog->display_mode_combo_box), TRUE);
+
+    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("label with value"));
+    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon with value"));
+    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("value only"));
+    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("icon only"));
+    gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(prefs_dialog->display_mode_combo_box), _("graph only"));
+
+    display_mode = g_settings_get_int(sensors_applet->settings, DISPLAY_MODE);
+    gtk_combo_box_set_active(GTK_COMBO_BOX(prefs_dialog->display_mode_combo_box), display_mode);
+
+    g_signal_connect(prefs_dialog->display_mode_combo_box,
+                     "changed",
+                     G_CALLBACK(prefs_dialog_display_mode_changed),
+                     prefs_dialog);
+
+    /* use spaces in label to indent */
+    prefs_dialog->display_mode_label = g_object_new(GTK_TYPE_LABEL,
+                                                    "use-underline", TRUE,
+                                                    "label", _("_Display sensors in panel as"),
+                                                    "mnemonic-widget", prefs_dialog->display_mode_combo_box,
+                                                    "xalign", 0.0,
+                                                    NULL);
+
+    prefs_dialog->layout_mode_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+                             (display_mode != DISPLAY_ICON) &&
+                             (display_mode != DISPLAY_VALUE) &&
+                             (display_mode != DISPLAY_GRAPH));
+
+    gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("beside labels / icons"));
+    gtk_combo_box_text_append_text(prefs_dialog->layout_mode_combo_box, _("below labels / icons"));
+
+    gtk_combo_box_set_active(
+            GTK_COMBO_BOX(prefs_dialog->layout_mode_combo_box),
+            g_settings_get_int(sensors_applet->settings, LAYOUT_MODE));
+
+    g_signal_connect(prefs_dialog->layout_mode_combo_box,
+                     "changed",
+                     G_CALLBACK(prefs_dialog_layout_mode_changed),
+                     prefs_dialog);
+
+    prefs_dialog->layout_mode_label = g_object_new(GTK_TYPE_LABEL,
+                                                   "use-underline", TRUE,
+                                                   "label", _("Preferred _position of sensor values"),
+                                                   "mnemonic-widget", prefs_dialog->layout_mode_combo_box,
+                                                   "xalign", 0.0,
+                                                   NULL);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->layout_mode_label),
+                             (display_mode != DISPLAY_ICON) &&
+                             (display_mode != DISPLAY_VALUE) &&
+                             (display_mode != DISPLAY_GRAPH));
+
+    prefs_dialog->temperature_scale_combo_box = GTK_COMBO_BOX_TEXT(gtk_combo_box_text_new());
+
+    gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Kelvin"));
+    gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Celsius"));
+    gtk_combo_box_text_append_text(prefs_dialog->temperature_scale_combo_box, _("Fahrenheit"));
+
+    gtk_combo_box_set_active(
+            GTK_COMBO_BOX(prefs_dialog->temperature_scale_combo_box),
+            g_settings_get_int(sensors_applet->settings, TEMPERATURE_SCALE));
+
+    g_signal_connect(prefs_dialog->temperature_scale_combo_box,
+                     "changed",
+                     G_CALLBACK(prefs_dialog_temperature_scale_changed),
+                     prefs_dialog);
+
+    prefs_dialog->temperature_scale_label = g_object_new(GTK_TYPE_LABEL,
+                                                         "use-underline", TRUE,
+                                                         "label", _("_Temperature scale"),
+                                                         "mnemonic-widget", prefs_dialog->temperature_scale_combo_box,
+                                                         "xalign", 0.0,
+                                                         NULL);
+
+    prefs_dialog->graph_size_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                                   "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
+                                                   "lower", 1.0,
+                                                   "upper", 100.0,
+                                                   "step-increment", 1.0,
+                                                   "page-increment", 10.0,
+                                                   "page-size", 0.0,
+                                                   NULL);
+
+    prefs_dialog->graph_size_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                       "adjustment", prefs_dialog->graph_size_adjust,
+                                                       "climb-rate", 1.0,
+                                                       "digits", 0,
+                                                       "value", (gdouble)g_settings_get_int(sensors_applet->settings, GRAPH_SIZE),
+                                                       "width-chars", 4,
+                                                       NULL);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_spinbutton), (display_mode == DISPLAY_GRAPH));
+
+    prefs_dialog->graph_size_label = g_object_new(GTK_TYPE_LABEL,
+                                                  "use-underline", TRUE,
+                                                  "label", _("Graph _size (pixels)"),
+                                                  "mnemonic-widget", prefs_dialog->graph_size_spinbutton,
+                                                  "xalign", 0.0,
+                                                  NULL);
+
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->graph_size_label), (display_mode == DISPLAY_GRAPH));
+
+    g_signal_connect(prefs_dialog->graph_size_spinbutton, "value-changed",
+                     G_CALLBACK(prefs_dialog_graph_size_changed),
+                     prefs_dialog);
+
+    // hide/show units
+    prefs_dialog->show_units = gtk_check_button_new_with_label (_("Show _units"));
+    gtk_button_set_use_underline (GTK_BUTTON (prefs_dialog->show_units), TRUE);
+    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (prefs_dialog->show_units),
+                        !g_settings_get_boolean (sensors_applet->settings, HIDE_UNITS));
+    g_signal_connect (prefs_dialog->show_units, "toggled",
+                        G_CALLBACK (prefs_dialog_show_units_toggled),
+                        prefs_dialog);
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Update"));
+    prefs_dialog->update_header = g_object_new(GTK_TYPE_LABEL,
+                                               "use-markup", TRUE,
+                                               "label", header_text,
+                                               "xalign", 0.0,
+                                               NULL);
+    g_free(header_text);
+
+    prefs_dialog->timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                                "value", 2.0,
+                                                "lower", 1.5,
+                                                "upper", 10.0,
+                                                "step-increment", 0.5,
+                                                "page-increment", 1.0,
+                                                "page-size", 0.0,
+                                                NULL);
+
+    prefs_dialog->timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                    "adjustment", prefs_dialog->timeout_adjust,
+                                                    "climb-rate", 0.5,
+                                                    "digits", 1,
+                                                    "value", (gdouble) g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000.0,
+                                                    "width-chars", 4,
+                                                    NULL);
+
+    prefs_dialog->timeout_label = g_object_new(GTK_TYPE_LABEL,
+                                               "use-underline", TRUE,
+                                               "label", _("Update _interval (secs)"),
+                                               "mnemonic-widget", prefs_dialog->timeout_spinbutton,
+                                               "xalign", 0.0,
+                                               NULL);
+
+    g_signal_connect(prefs_dialog->timeout_spinbutton, "value-changed",
+                     G_CALLBACK(prefs_dialog_timeout_changed),
+                     prefs_dialog);
+
+#ifdef HAVE_LIBNOTIFY
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Notifications"));
+    prefs_dialog->notifications_header = g_object_new(GTK_TYPE_LABEL,
+                                                      "use-markup", TRUE,
+                                                      "label", header_text,
+                                                      "xalign", 0.0,
+                                                      NULL);
+    g_free(header_text);
+
+    prefs_dialog->display_notifications = g_object_new(GTK_TYPE_CHECK_BUTTON,
+                                                       "use-underline", TRUE,
+                                                       "label", _("Display _notifications"),
+                                                       NULL);
+    gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(prefs_dialog->display_notifications),
+                                 g_settings_get_boolean(sensors_applet->settings,
+                                                        DISPLAY_NOTIFICATIONS));
+    g_signal_connect(prefs_dialog->display_notifications,
+                     "toggled",
+                     G_CALLBACK(prefs_dialog_display_notifications_toggled),
+                     prefs_dialog);
+#endif
+
+    /* SIZE AND LAYOUT */
+    /* keep all widgets same size */
+    prefs_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+
+    gtk_size_group_add_widget(prefs_dialog->size_group,
+                              GTK_WIDGET(prefs_dialog->display_mode_combo_box));
+
+    gtk_size_group_add_widget(prefs_dialog->size_group,
+                              GTK_WIDGET(prefs_dialog->layout_mode_combo_box));
+
+    gtk_size_group_add_widget(prefs_dialog->size_group,
+                              GTK_WIDGET(prefs_dialog->temperature_scale_combo_box));
+
+    gtk_size_group_add_widget(prefs_dialog->size_group,
+                              GTK_WIDGET(prefs_dialog->timeout_spinbutton));
+
+    g_object_unref(prefs_dialog->size_group);
+
+    prefs_dialog->globals_grid = g_object_new(GTK_TYPE_GRID,
+                                               "row-homogeneous", FALSE,
+                                               "column-homogeneous", FALSE,
+                                               "row-spacing", 6,
+                                               "column-spacing", 12,
+                                               NULL);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->display_header),
+                     0, 0, 2, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->display_mode_label),
+                     1, 1, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->display_mode_combo_box),
+                     2, 1, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->layout_mode_label),
+                     1, 2, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->layout_mode_combo_box),
+                     2, 2, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->graph_size_label),
+                     1, 3, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->graph_size_spinbutton),
+                     2, 3, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->temperature_scale_label),
+                     1, 4, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->temperature_scale_combo_box),
+                     2, 4, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->show_units),
+                     1, 5, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->update_header),
+                     0, 6, 2, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->timeout_label),
+                     1, 7, 1, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->timeout_spinbutton),
+                     2, 7, 1, 1);
+
+#ifdef HAVE_LIBNOTIFY
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->notifications_header),
+                     0, 8, 2, 1);
+
+    gtk_grid_attach(prefs_dialog->globals_grid,
+                     GTK_WIDGET(prefs_dialog->display_notifications),
+                     1, 9, 1, 1);
+#endif
+
+    gtk_widget_set_valign(GTK_WIDGET(prefs_dialog->globals_grid), GTK_ALIGN_START);
+    gtk_widget_set_margin_start(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+    gtk_widget_set_margin_end(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+    gtk_widget_set_margin_top(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+    gtk_widget_set_margin_bottom(GTK_WIDGET(prefs_dialog->globals_grid), 12);
+
+    prefs_dialog->view = g_object_new(GTK_TYPE_TREE_VIEW,
+                                      "model", GTK_TREE_MODEL(sensors_applet->sensors),
+                                      "rules-hint", TRUE,
+                                      "reorderable", FALSE,
+                                      "enable-search", TRUE,
+                                      "search-column", LABEL_COLUMN,
+                                      NULL);
+
+    /* get double clicks on rows - do same as configure sensor
+     * button clicks */
+    g_signal_connect(prefs_dialog->view, "row-activated",
+                     G_CALLBACK(prefs_dialog_row_activated),
+                     prefs_dialog);
+
+    prefs_dialog->id_renderer = gtk_cell_renderer_text_new();
+    prefs_dialog->label_renderer = gtk_cell_renderer_text_new();
+    g_object_set(prefs_dialog->label_renderer,
+                 "editable", TRUE,
+                 NULL);
+
+    g_signal_connect(prefs_dialog->label_renderer, "edited",
+                     G_CALLBACK(prefs_dialog_sensor_name_changed),
+                     prefs_dialog);
+
+    prefs_dialog->enable_renderer = gtk_cell_renderer_toggle_new();
+    g_signal_connect(prefs_dialog->enable_renderer, "toggled",
+                     G_CALLBACK(prefs_dialog_sensor_toggled),
+                     prefs_dialog);
+    prefs_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
+
+    prefs_dialog->id_column = gtk_tree_view_column_new_with_attributes(_("Sensor"),
+                                                                       prefs_dialog->id_renderer,
+                                                                       "text", ID_COLUMN,
+                                                                       NULL);
+
+    gtk_tree_view_column_set_min_width(prefs_dialog->id_column, 90);
+
+    prefs_dialog->label_column = gtk_tree_view_column_new_with_attributes(_("Label"),
+                                                                          prefs_dialog->label_renderer,
+                                                                          "text", LABEL_COLUMN,
+                                                                          "visible", VISIBLE_COLUMN,
+                                                                          NULL);
+
+    gtk_tree_view_column_set_min_width(prefs_dialog->label_column, 100);
+
+    /* create the tooltip */
+    gtk_widget_set_tooltip_text(GTK_WIDGET(prefs_dialog->view),
+                                _("Labels can be edited directly by clicking on them."));
+    prefs_dialog->enable_column = gtk_tree_view_column_new_with_attributes(_("Enabled"),
+                                                                           prefs_dialog->enable_renderer,
+                                                                           "active", ENABLE_COLUMN,
+                                                                           "visible", VISIBLE_COLUMN,
+                                                                           NULL);
+
+    gtk_tree_view_column_set_min_width(prefs_dialog->enable_column, 90);
+
+    prefs_dialog->icon_column = gtk_tree_view_column_new_with_attributes(_("Icon"),
+                                                                         prefs_dialog->icon_renderer,
+                                                                         "pixbuf", ICON_PIXBUF_COLUMN,
+                                                                         "visible", VISIBLE_COLUMN,
+                                                                         NULL);
+
+    gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->id_column);
+    gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->icon_column);
+    gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->label_column);
+    gtk_tree_view_append_column(prefs_dialog->view, prefs_dialog->enable_column);
+
+    gtk_tree_view_columns_autosize(prefs_dialog->view);
+
+    prefs_dialog->scrolled_window = g_object_new(GTK_TYPE_SCROLLED_WINDOW,
+                                                 "hadjustment", NULL,
+                                                 "height-request", 200,
+                                                 "hscrollbar-policy", GTK_POLICY_NEVER,
+                                                 "vadjustment",NULL,
+                                                 "vscrollbar-policy", GTK_POLICY_AUTOMATIC,
+                                                 NULL);
+
+    gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(prefs_dialog->scrolled_window), GTK_SHADOW_IN);
+
+    gtk_container_add(GTK_CONTAINER(prefs_dialog->scrolled_window), GTK_WIDGET(prefs_dialog->view));
+
+    /* GtkTree Selection */
+    sensors_applet->selection = gtk_tree_view_get_selection(prefs_dialog->view);
+    /* allow user to only select one row at a time at most */
+    gtk_tree_selection_set_mode(sensors_applet->selection, GTK_SELECTION_SINGLE);
+    /* when selection is changed, make sure sensor_config button is activated */
+
+    /* Create buttons for user to interact with sensors tree */
+    prefs_dialog->sensor_up_button = GTK_BUTTON(gtk_button_new_with_mnemonic(_("_Up")));
+    gtk_button_set_image(prefs_dialog->sensor_up_button, gtk_image_new_from_icon_name("go-up", GTK_ICON_SIZE_BUTTON));
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE);
+
+    g_signal_connect(prefs_dialog->sensor_up_button, "clicked",
+                     G_CALLBACK(prefs_dialog_sensor_up_button_clicked),
+                     prefs_dialog);
+
+    prefs_dialog->sensor_down_button = GTK_BUTTON(gtk_button_new_with_mnemonic(_("_Down")));
+    gtk_button_set_image(prefs_dialog->sensor_down_button, gtk_image_new_from_icon_name("go-down", GTK_ICON_SIZE_BUTTON));
+    gtk_widget_set_sensitive(GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE);
+
+    g_signal_connect(prefs_dialog->sensor_down_button, "clicked",
+                     G_CALLBACK(prefs_dialog_sensor_down_button_clicked),
+                     prefs_dialog);
+
+    prefs_dialog->buttons_box = GTK_BUTTON_BOX(gtk_button_box_new(GTK_ORIENTATION_VERTICAL));
+
+    gtk_button_box_set_layout(GTK_BUTTON_BOX(prefs_dialog->buttons_box), GTK_BUTTONBOX_SPREAD);
+
+    gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_up_button), FALSE, FALSE, 0);
+
+    gtk_box_pack_start(GTK_BOX(prefs_dialog->buttons_box), GTK_WIDGET(prefs_dialog->sensor_down_button), FALSE, FALSE, 0);
+
+    prefs_dialog->sensors_hbox = g_object_new(GTK_TYPE_BOX,
+                                              "orientation", GTK_ORIENTATION_HORIZONTAL,
+                                              "border-width", 5,
+                                              "homogeneous", FALSE,
+                                              "spacing", 5,
+                                              NULL);
+
+    gtk_box_pack_start(prefs_dialog->sensors_hbox,
+                       GTK_WIDGET(prefs_dialog->scrolled_window),
+                       TRUE, TRUE, 0); /* make sure window takes up most of room */
+
+    gtk_box_pack_start(prefs_dialog->sensors_hbox,
+                       GTK_WIDGET(prefs_dialog->buttons_box),
+                       FALSE, FALSE, 0);
+
+    /* Sensor Config button */
+    /* initially make button insensitive until user selects a row
+       from the sensors tree */
+    prefs_dialog->sensor_config_button = GTK_BUTTON(gtk_button_new_with_mnemonic(_("_Properties")));
+    gtk_button_set_image(prefs_dialog->sensor_config_button, gtk_image_new_from_icon_name("document-properties", GTK_ICON_SIZE_BUTTON));
+    g_object_set(prefs_dialog->sensor_config_button,
+                 "sensitive", FALSE,
+                 NULL);
+
+    g_signal_connect(sensors_applet->selection,
+                     "changed",
+                     G_CALLBACK(prefs_dialog_selection_changed),
+                     prefs_dialog);
+
+    /* pass selection to signal handler so we can give user a
+       sensors_applet->prefs_dialog with the selected rows alarm
+       value and enable */
+    g_signal_connect(prefs_dialog->sensor_config_button, "clicked",
+                     G_CALLBACK(prefs_dialog_sensor_config_button_clicked),
+                     prefs_dialog);
+
+    prefs_dialog->sensor_config_hbox = g_object_new(GTK_TYPE_BOX,
+                                                    "orientation", GTK_ORIENTATION_HORIZONTAL,
+                                                    "border-width", 5,
+                                                    "homogeneous", FALSE,
+                                                    "spacing", 0,
+                                                    NULL);
+    gtk_box_pack_end(prefs_dialog->sensor_config_hbox,
+                     GTK_WIDGET(prefs_dialog->sensor_config_button),
+                     FALSE, FALSE, 0);
+
+    /* pack sensors_vbox */
+    prefs_dialog->sensors_vbox = g_object_new(GTK_TYPE_BOX,
+                                              "orientation", GTK_ORIENTATION_VERTICAL,
+                                              "border-width", 5,
+                                              "homogeneous", FALSE,
+                                              "spacing", 0,
+                                              NULL);
+
+    gtk_box_pack_start(prefs_dialog->sensors_vbox,
+                       GTK_WIDGET(prefs_dialog->sensors_hbox),
+                       TRUE, TRUE, 0);
+    gtk_box_pack_start(prefs_dialog->sensors_vbox,
+                       GTK_WIDGET(prefs_dialog->sensor_config_hbox),
+                       FALSE, FALSE, 0);
+
+    prefs_dialog->notebook = g_object_new(GTK_TYPE_NOTEBOOK, NULL);
+
+    gtk_notebook_append_page(prefs_dialog->notebook,
+                             GTK_WIDGET(prefs_dialog->globals_grid),
+                             gtk_label_new(_("General Options")));
+
+    gtk_notebook_append_page(prefs_dialog->notebook,
+                             GTK_WIDGET(prefs_dialog->sensors_vbox),
+                             gtk_label_new(_("Sensors")));
+
+    /* pack notebook into prefs_dialog */
+    content_area = gtk_dialog_get_content_area (prefs_dialog->dialog);
+    gtk_box_pack_start (GTK_BOX(content_area), GTK_WIDGET(prefs_dialog->notebook), TRUE, TRUE, 0);
+
+    gtk_widget_show_all(GTK_WIDGET(prefs_dialog->dialog));
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/42.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/42.html new file mode 100644 index 0000000..6d7324a --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/42.html @@ -0,0 +1,1905 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
+651
+652
+653
+654
+655
+656
+657
+658
+659
+660
+661
+662
+663
+664
+665
+666
+667
+668
+669
+670
+671
+672
+673
+674
+675
+676
+677
+678
+679
+680
+681
+682
+683
+684
+685
+686
+687
+688
+689
+690
+691
+692
+693
+694
+695
+696
+697
+698
+699
+700
+701
+702
+703
+704
+705
+706
+707
+708
+709
+710
+711
+712
+713
+714
+715
+716
+717
+718
+719
+720
+721
+722
+723
+724
+725
+726
+727
+728
+729
+730
+731
+732
+733
+734
+735
+736
+737
+738
+739
+740
+741
+742
+743
+744
+745
+746
+747
+748
+749
+750
+751
+752
+753
+754
+755
+756
+757
+758
+759
+760
+761
+762
+763
+764
+765
+766
+767
+768
+769
+770
+771
+772
+773
+774
+775
+776
+777
+778
+779
+780
+781
+782
+783
+784
+785
+786
+787
+788
+789
+790
+791
+792
+793
+794
+795
+796
+797
+798
+799
+800
+801
+802
+803
+804
+805
+806
+807
+808
+809
+810
+811
+812
+813
+814
+815
+816
+817
+818
+819
+820
+821
+822
+823
+824
+825
+826
+827
+828
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensor-config-dialog.h"
+#include "sensors-applet.h"
+
+#define SPINBUTTON_WIDTH_CHARS 8
+#define VALUE_DECIMAL_PLACES 3
+
+typedef struct {
+    SensorsApplet *sensors_applet;
+
+    GtkDialog *dialog;
+    /* icon widgets */
+    GtkLabel *icon_header, *icon_type_label;
+    GtkComboBox *icon_type_combo_box;
+    GtkAlignment *icon_type_combo_box_aligner;<--- struct member 'SensorConfigDialog::icon_type_combo_box_aligner' is never used.
+    GtkCellRenderer *icon_renderer;
+
+    /* Graph Color chooser */
+    GtkColorButton *graph_color_button;
+    GtkAlignment *graph_color_button_aligner;<--- struct member 'SensorConfigDialog::graph_color_button_aligner' is never used.
+    GtkLabel *graph_color_label, *graph_header;
+
+    /* multiplier and offset widgets */
+    GtkLabel *scale_header, *multiplier_label, *offset_label;
+    GtkAlignment *multiplier_spinbutton_aligner, *offset_spinbutton_aligner;<--- struct member 'SensorConfigDialog::multiplier_spinbutton_aligner' is never used.<--- struct member 'SensorConfigDialog::offset_spinbutton_aligner' is never used.
+    GtkAdjustment *multiplier_adjust, *offset_adjust;
+    GtkSpinButton *multiplier_spinbutton, *offset_spinbutton;
+
+    GtkLabel *limits_header;
+    GtkLabel *low_value_label, *high_value_label;
+    GtkAlignment *low_value_spinbutton_aligner, *high_value_spinbutton_aligner;<--- struct member 'SensorConfigDialog::low_value_spinbutton_aligner' is never used.<--- struct member 'SensorConfigDialog::high_value_spinbutton_aligner' is never used.
+    GtkAdjustment *low_value_adjust, *high_value_adjust;
+    GtkSpinButton *low_value_spinbutton, *high_value_spinbutton;
+
+    /* alarm widgets */
+    GtkLabel *alarm_header;
+    GtkLabel *low_alarm_command_label, *high_alarm_command_label, *alarm_timeout_label;
+    GtkAlignment *alarm_timeout_spinbutton_aligner;<--- struct member 'SensorConfigDialog::alarm_timeout_spinbutton_aligner' is never used.
+    GtkAdjustment *alarm_timeout_adjust;
+    GtkSpinButton *alarm_timeout_spinbutton;
+    GtkGrid *grid;
+    GtkAlignment *alarm_enable_aligner;<--- struct member 'SensorConfigDialog::alarm_enable_aligner' is never used.
+    GtkCheckButton *alarm_enable_checkbutton;
+    GtkEntry *low_alarm_command_entry, *high_alarm_command_entry;
+
+    GtkSizeGroup *size_group;
+} SensorConfigDialog;
+
+static void sensor_config_dialog_response(GtkDialog *dialog,
+                                          gint response,
+                                          gpointer data) {
+
+    GError *error = NULL;
+
+    switch (response) {
+        case GTK_RESPONSE_HELP:
+            g_debug("loading help in config dialog");
+            gtk_show_uri_on_window(NULL,
+                         "help:mate-sensors-applet/sensors-applet-sensors#sensors-applet-sensor-config-dialog",
+                         gtk_get_current_event_time(),
+                         &error);
+
+            if (error) {
+                    g_debug("Could not open help document: %s ",error->message);
+                    g_error_free (error);
+            }
+            break;
+
+        default:
+            g_debug("destroying config dialog");
+            gtk_widget_destroy(GTK_WIDGET(dialog));
+    }
+}
+
+static void sensor_config_dialog_multiplier_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        MULTIPLIER_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_offset_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        OFFSET_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_low_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        LOW_VALUE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_high_value_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gdouble value;
+
+    value = gtk_spin_button_get_value(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        HIGH_VALUE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_toggled(GtkToggleButton *button, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    gboolean value;
+    value = gtk_toggle_button_get_active(button);
+
+    /* update state of alarm widgets */
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->low_alarm_command_entry), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_label), value);
+    gtk_widget_set_sensitive(GTK_WIDGET(config_dialog->high_alarm_command_entry), value);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        ALARM_ENABLE_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_timeout_changed(GtkSpinButton *spinbutton, SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gint value;
+
+    value = gtk_spin_button_get_value_as_int(spinbutton);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    sensors_applet_all_alarms_off(config_dialog->sensors_applet, path);
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                        &iter,
+                        ALARM_TIMEOUT_COLUMN, value,
+                       -1);
+
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog, NotifType notif_type) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+
+    gchar *value;
+    g_object_get(command_entry, "text", &value, NULL);
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+
+    sensors_applet_alarm_off(config_dialog->sensors_applet, path, notif_type);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                       &iter,
+                       (notif_type == LOW_ALARM ? LOW_ALARM_COMMAND_COLUMN : HIGH_ALARM_COMMAND_COLUMN),
+                       value,
+                       -1);
+    g_free(value);
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+static void sensor_config_dialog_low_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
+    sensor_config_dialog_alarm_command_edited(command_entry,
+                                              config_dialog,
+                                              LOW_ALARM);
+}
+
+static void sensor_config_dialog_high_alarm_command_edited(GtkEntry *command_entry, SensorConfigDialog *config_dialog) {
+    sensor_config_dialog_alarm_command_edited(command_entry,
+                                              config_dialog,
+                                              HIGH_ALARM);
+}
+
+static void sensor_config_dialog_icon_type_changed(GtkComboBox *icon_type_combo_box,
+                                                   SensorConfigDialog *config_dialog) {
+    GtkTreeModel *icons_model;
+    GtkTreeIter icons_iter;
+
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+
+    GdkPixbuf *new_icon;
+    IconType icon_type;
+
+    icons_model = gtk_combo_box_get_model(icon_type_combo_box);
+    if (gtk_combo_box_get_active_iter(icon_type_combo_box, &icons_iter)) {
+        GtkTreePath *path;
+
+        gtk_tree_model_get(icons_model, &icons_iter,
+                           0, &new_icon,
+                           -1);
+
+        icon_type = gtk_combo_box_get_active(icon_type_combo_box);
+        gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                        &model,
+                                        &iter);
+
+        path = gtk_tree_model_get_path(model, &iter);
+        gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                           &iter,
+                           ICON_TYPE_COLUMN, icon_type,
+                           ICON_PIXBUF_COLUMN, new_icon,
+                           -1);
+        g_object_unref(new_icon);
+        sensors_applet_icon_changed(config_dialog->sensors_applet, path);
+        gtk_tree_path_free(path);
+    }
+}
+
+static void sensor_config_dialog_graph_color_set(GtkColorChooser *color_chooser,
+                                                 SensorConfigDialog *config_dialog) {
+    GtkTreeModel *model;
+    GtkTreePath *path;
+    GtkTreeIter iter;
+    gchar *color_string;
+    GdkRGBA color;
+
+    gtk_color_chooser_get_rgba(color_chooser, &color);
+
+    color_string = g_strdup_printf ("#%02X%02X%02X", (int)(0.5 + CLAMP (color.red, 0., 1.) * 255.),
+                                    (int)(0.5 + CLAMP (color.green, 0., 1.) * 255.),
+                                    (int)(0.5 + CLAMP (color.blue, 0., 1.) * 255.));
+
+    gtk_tree_selection_get_selected(config_dialog->sensors_applet->selection,
+                                    &model,
+                                    &iter);
+
+    gtk_tree_store_set(config_dialog->sensors_applet->sensors,
+                       &iter,
+                       GRAPH_COLOR_COLUMN, color_string,
+                       -1);
+
+    g_free(color_string);
+
+    path = gtk_tree_model_get_path(GTK_TREE_MODEL(config_dialog->sensors_applet->sensors), &iter);
+    sensors_applet_update_sensor(config_dialog->sensors_applet, path);
+    gtk_tree_path_free(path);
+}
+
+void sensor_config_dialog_create(SensorsApplet *sensors_applet) {
+    GtkTreeModel *model;
+    GtkTreeIter iter;
+    GtkWidget *content_area;
+
+    SensorConfigDialog *config_dialog;
+
+    GtkListStore *icon_store;
+    IconType count;
+    GdkRGBA graph_color;
+    gchar *sensor_label;
+    gchar *header_text;
+
+    /* instance variables for data */
+    gdouble low_value, high_value, multiplier, offset;
+    gboolean alarm_enable;
+    gchar *low_alarm_command, *high_alarm_command;
+    gint alarm_timeout;
+    IconType icon_type;
+    gchar *graph_color_string;
+
+    config_dialog = g_new0(SensorConfigDialog, 1);
+    config_dialog->sensors_applet = sensors_applet;
+
+    gtk_tree_selection_get_selected(sensors_applet->selection,
+                                    &model,
+                                    &iter);
+    /* get current values of alarm and its enable */
+    gtk_tree_model_get(model, &iter,
+                       LOW_VALUE_COLUMN, &low_value,
+                       HIGH_VALUE_COLUMN, &high_value,
+                       ALARM_ENABLE_COLUMN, &alarm_enable,
+                       LOW_ALARM_COMMAND_COLUMN, &low_alarm_command,
+                       HIGH_ALARM_COMMAND_COLUMN, &high_alarm_command,
+                       ALARM_TIMEOUT_COLUMN, &alarm_timeout,
+                       MULTIPLIER_COLUMN, &multiplier,
+                       OFFSET_COLUMN, &offset,
+                       ICON_TYPE_COLUMN, &icon_type,
+                       GRAPH_COLOR_COLUMN, &graph_color_string,
+                       LABEL_COLUMN, &sensor_label,
+                       -1);
+    header_text = g_strdup_printf("%s - %s", _("Sensor Properties"), sensor_label);
+
+    config_dialog->dialog = GTK_DIALOG(gtk_dialog_new_with_buttons(header_text,
+                                                        GTK_WINDOW(sensors_applet->prefs_dialog->dialog),
+                                                        GTK_DIALOG_DESTROY_WITH_PARENT,
+                                                        "gtk-help",
+                                                        GTK_RESPONSE_HELP,
+                                                        "gtk-close",
+                                                        GTK_RESPONSE_CLOSE,
+                                                        NULL));
+
+    gtk_window_set_icon_name(GTK_WINDOW(config_dialog->dialog), "sensors-applet");
+
+    g_free(header_text);
+    g_free(sensor_label);
+
+    g_object_set(config_dialog->dialog,
+                 "border-width", 12,
+                 NULL);
+
+    g_signal_connect(config_dialog->dialog,
+                     "response",
+                     G_CALLBACK(sensor_config_dialog_response),
+                     config_dialog);
+
+    /* graph stuff */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Graph"));
+    config_dialog->graph_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    gdk_rgba_parse(&graph_color, graph_color_string);
+    config_dialog->graph_color_button = GTK_COLOR_BUTTON(gtk_color_button_new_with_rgba(&graph_color));
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->graph_color_button), GTK_ALIGN_START);
+
+    gtk_color_button_set_title(config_dialog->graph_color_button, _("Graph Color"));
+
+    config_dialog->graph_color_label = g_object_new(GTK_TYPE_LABEL,
+                                     "label", _("Graph _color"),
+                                    "mnemonic-widget", config_dialog->graph_color_button,
+                                    "use-underline", TRUE,
+                                    "xalign", 0.0,
+                                    NULL);
+
+    g_signal_connect(config_dialog->graph_color_button, "color-set",
+                     G_CALLBACK(sensor_config_dialog_graph_color_set),
+                     config_dialog);
+
+    /* icon stuff */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Icon"));
+    config_dialog->icon_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    /* icon type */
+    icon_store = gtk_list_store_new(1, GDK_TYPE_PIXBUF);
+
+    /* populate list with icons */
+    for (count = CPU_ICON; count < NUM_ICONS; count++) {
+        GdkPixbuf *pixbuf;
+
+        pixbuf = sensors_applet_load_icon(count);
+        if (pixbuf) {
+            gtk_list_store_insert(icon_store, &iter, count);
+            gtk_list_store_set(icon_store, &iter, 0, pixbuf, -1);
+            /* let list hold icons */
+            g_object_unref(pixbuf);
+        }
+    }
+
+    config_dialog->icon_type_combo_box = GTK_COMBO_BOX(gtk_combo_box_new_with_model(GTK_TREE_MODEL(icon_store)));
+
+        gtk_widget_set_halign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
+        gtk_widget_set_valign (GTK_WIDGET(config_dialog->icon_type_combo_box), GTK_ALIGN_START);
+
+    config_dialog->icon_renderer = gtk_cell_renderer_pixbuf_new();
+    gtk_cell_layout_pack_start(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+                               GTK_CELL_RENDERER(config_dialog->icon_renderer),
+                               FALSE);
+
+    gtk_cell_layout_add_attribute(GTK_CELL_LAYOUT(config_dialog->icon_type_combo_box),
+                                  GTK_CELL_RENDERER(config_dialog->icon_renderer),
+                                  "pixbuf", 0);
+
+    gtk_combo_box_set_active(config_dialog->icon_type_combo_box, icon_type);
+
+    g_signal_connect(config_dialog->icon_type_combo_box, "changed",
+                     G_CALLBACK(sensor_config_dialog_icon_type_changed),
+                     config_dialog);
+
+    config_dialog->icon_type_label = g_object_new(GTK_TYPE_LABEL,
+                                     "label", _("Sensor _icon"),
+                                    "mnemonic-widget", config_dialog->icon_type_combo_box,
+                                    "use-underline", TRUE,
+                                    "xalign", 0.0,
+                                    NULL);
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Scaling Parameters"));
+    config_dialog->scale_header = g_object_new(GTK_TYPE_LABEL,
+                               "use-markup", TRUE,
+                               "label", header_text,
+                               "xalign", 0.0,
+                               NULL);
+    g_free(header_text);
+
+    /* do multiplier and offset widgets */
+    config_dialog->multiplier_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                          "value", 1.0,
+                          "lower", 0.001,
+                          "upper", 1000.0,
+                          "step-increment", 0.1,
+                          "page-increment", 1.0,
+                          "page-size", 1.0,
+                          NULL);
+
+    config_dialog->multiplier_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                         "adjustment", config_dialog->multiplier_adjust,
+                                         "digits", VALUE_DECIMAL_PLACES,
+                                         "value", multiplier,
+                                         "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                         NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->multiplier_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->multiplier_label = g_object_new(GTK_TYPE_LABEL,
+                                                   "label", _("Sensor value _multiplier"),
+                                                   "mnemonic-widget", config_dialog->multiplier_spinbutton,
+                                                   "use-underline", TRUE,
+                                                   "xalign", 0.0,
+                                                   NULL);
+
+    g_signal_connect(config_dialog->multiplier_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_multiplier_changed), config_dialog);
+
+    config_dialog->offset_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                 "value", 0.0,
+                                 "lower", -1000.000,
+                                 "upper", 1000.000,
+                                 "step-increment", 0.01,
+                                 "page-increment", 1.0,
+                                 "page-size", 1.0,
+                                 NULL);
+
+    config_dialog->offset_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                     "adjustment", config_dialog->offset_adjust,
+                                     "digits", VALUE_DECIMAL_PLACES,
+                                     "value", (gdouble)offset,
+                                     "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                     NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->offset_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->offset_label = g_object_new(GTK_TYPE_LABEL,
+                                "label", _("Sensor value _offset"),
+                                "mnemonic-widget", config_dialog->offset_spinbutton,
+                                "use-underline", TRUE,
+                                "xalign", 0.0,
+                                NULL);
+
+    g_signal_connect(config_dialog->offset_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_offset_changed), config_dialog);
+
+    /* now do alarm widgets */
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Sensor Limits"));
+    config_dialog->limits_header = g_object_new(GTK_TYPE_LABEL,
+                                                "use-markup", TRUE,
+                                                "label", header_text,
+                                                "xalign", 0.0,
+                                                NULL);
+    g_free(header_text);
+
+    config_dialog->low_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                    "value", 0.0,
+                                    "lower", -100000.0,
+                                    "upper", 100000.0,
+                                    "step-increment", 1.0,
+                                    "page-increment", 10.0,
+                                    "page-size", 100.0,
+                                    NULL);
+
+    config_dialog->low_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                       "adjustment", config_dialog->low_value_adjust,
+                                                       "digits", VALUE_DECIMAL_PLACES,
+                                                       "value", low_value,
+                                                       "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                       NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->low_value_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->low_value_label = g_object_new(GTK_TYPE_LABEL,
+                                                  "label", _("Sensor _low value"),
+                                                  "mnemonic-widget", config_dialog->low_value_spinbutton,
+                                                  "use-underline", TRUE,
+                                                  "xalign", 0.0,
+                                                  NULL);
+
+    g_signal_connect(config_dialog->low_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_low_value_changed), config_dialog);
+
+    config_dialog->high_value_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                                  "value", 0.0,
+                                                  "lower", -100000.0,
+                                                  "upper", 100000.0,
+                                                  "step-increment", 1.0,
+                                                  "page-increment", 10.0,
+                                                  "page-size", 100.0,
+                                                  NULL);
+
+    config_dialog->high_value_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                        "adjustment", config_dialog->high_value_adjust,
+                                                        "digits", VALUE_DECIMAL_PLACES,
+                                                        "value", high_value,
+                                                        "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                        NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->high_value_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->high_value_label = g_object_new(GTK_TYPE_LABEL,
+                                                   "label", _("Sensor _high value"),
+                                                   "mnemonic-widget", config_dialog->high_value_spinbutton,
+                                                   "use-underline", TRUE,
+                                                   "xalign", 0.0,
+                                                   NULL);
+
+    g_signal_connect(config_dialog->high_value_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_high_value_changed), config_dialog);
+
+    header_text = g_markup_printf_escaped("<b>%s</b>", _("Alarm"));
+    config_dialog->alarm_header = g_object_new(GTK_TYPE_LABEL,
+                                               "use-markup", TRUE,
+                                               "label", header_text,
+                                               "xalign", 0.0,
+                                               NULL);
+    g_free(header_text);
+
+    config_dialog->alarm_timeout_adjust = g_object_new(GTK_TYPE_ADJUSTMENT,
+                                        "value", 0.0,
+                                        "lower", 0.0,
+                                        "upper", 10000.0,
+                                        "step-increment", 1.0,
+                                        "page-increment", 10.0,
+                                        "page-size", 100.0,
+                                        NULL);
+
+    config_dialog->alarm_timeout_spinbutton = g_object_new(GTK_TYPE_SPIN_BUTTON,
+                                                           "adjustment", config_dialog->alarm_timeout_adjust,
+                                                           "digits", 0,
+                                                           "value", (gdouble)alarm_timeout,
+                                                           "width-chars", SPINBUTTON_WIDTH_CHARS,
+                                                           "sensitive", alarm_enable,
+                                                           NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_timeout_spinbutton), GTK_ALIGN_START);
+
+    config_dialog->alarm_timeout_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "label", _("Alarm _repeat interval (secs)"),
+                                                      "mnemonic-widget", config_dialog->alarm_timeout_spinbutton,
+                                                      "use-underline", TRUE,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->alarm_timeout_spinbutton, "value-changed", G_CALLBACK(sensor_config_dialog_alarm_timeout_changed), config_dialog);
+
+    config_dialog->low_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+                                                          "text", low_alarm_command,
+                                                          "width-chars", 25,
+                                                          "sensitive", alarm_enable,
+                                                          NULL);
+
+    g_free(low_alarm_command);
+
+    config_dialog->low_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "use-underline", TRUE,
+                                                      "label", _("Lo_w alarm command"),
+                                                      "mnemonic-widget", config_dialog->low_alarm_command_entry,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->low_alarm_command_entry,
+                     "changed",
+                     G_CALLBACK(sensor_config_dialog_low_alarm_command_edited),
+                     config_dialog);
+
+    config_dialog->high_alarm_command_entry = g_object_new(GTK_TYPE_ENTRY,
+                                                          "text", high_alarm_command,
+                                                          "width-chars", 25,
+                                                          "sensitive", alarm_enable,
+                                                          NULL);
+
+    g_free(high_alarm_command);
+
+    config_dialog->high_alarm_command_label = g_object_new(GTK_TYPE_LABEL,
+                                                      "use-underline", TRUE,
+                                                      "label", _("Hi_gh alarm command"),
+                                                      "mnemonic-widget", config_dialog->high_alarm_command_entry,
+                                                      "xalign", 0.0,
+                                                      "sensitive", alarm_enable,
+                                                      NULL);
+
+    g_signal_connect(config_dialog->high_alarm_command_entry,
+                     "changed",
+                     G_CALLBACK(sensor_config_dialog_high_alarm_command_edited),
+                     config_dialog);
+
+    config_dialog->alarm_enable_checkbutton = g_object_new(GTK_TYPE_CHECK_BUTTON,
+                                            "use-underline", TRUE,
+                                            "label", _("_Enable alarm"),
+                                            "active", alarm_enable,
+                                            "xalign", 0.0,
+                                            NULL);
+
+    gtk_widget_set_halign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
+    gtk_widget_set_valign (GTK_WIDGET(config_dialog->alarm_enable_checkbutton), GTK_ALIGN_START);
+
+    g_signal_connect(config_dialog->alarm_enable_checkbutton, "toggled", G_CALLBACK(sensor_config_dialog_alarm_toggled), config_dialog);
+
+    config_dialog->size_group = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL);
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->multiplier_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->offset_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->low_value_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->high_value_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->alarm_timeout_spinbutton));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->icon_type_combo_box));
+    gtk_size_group_add_widget(config_dialog->size_group, GTK_WIDGET(config_dialog->graph_color_button));
+    g_object_unref(config_dialog->size_group);
+
+    config_dialog->grid = g_object_new(GTK_TYPE_GRID,
+                                         "column-spacing", 5,
+                                         "row-homogeneous", FALSE,
+                                         "column-homogeneous", FALSE,
+                                         "row-spacing", 6,
+                                         "column-spacing", 12,
+                                         NULL);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->scale_header),
+                    0, 0, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->multiplier_label),
+                    1, 1, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->multiplier_spinbutton),
+                    2, 1, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->offset_label),
+                    1, 2, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->offset_spinbutton),
+                    2, 2, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->limits_header),
+                    0, 3, 2, 1);
+
+    /* now pack alarm widgets */
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_value_label),
+                    1, 4, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_value_spinbutton),
+                    2, 4, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_value_label),
+                    1, 5, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_value_spinbutton),
+                    2, 5, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_header),
+                    0, 6, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_enable_checkbutton),
+                    1, 7, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_timeout_label),
+                    1, 8, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->alarm_timeout_spinbutton),
+                    2, 8, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_alarm_command_label),
+                    1, 9, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->low_alarm_command_entry),
+                    2, 9, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_alarm_command_label),
+                    1, 10, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->high_alarm_command_entry),
+                    2, 10, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_header),
+                    0, 11, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_type_label),
+                    1, 12, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->icon_type_combo_box),
+                    2, 12, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_header),
+                    0, 13, 2, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_color_label),
+                    1, 14, 1, 1);
+
+    gtk_grid_attach(config_dialog->grid,
+                    GTK_WIDGET(config_dialog->graph_color_button),
+                    2, 14, 1, 1);
+
+    content_area = gtk_dialog_get_content_area (config_dialog->dialog);
+    gtk_box_pack_start(GTK_BOX(content_area), GTK_WIDGET(config_dialog->grid), FALSE, FALSE, 0);
+    gtk_widget_show_all(GTK_WIDGET(config_dialog->dialog));
+
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/43.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/43.html new file mode 100644 index 0000000..4397ca5 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/43.html @@ -0,0 +1,521 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_DLFCN_H */
+
+#include "sensors-applet-plugins.h"
+#include "sensors-applet-sensor.h"
+
+#define SENSORS_APPLET_USER_PLUGIN_DIR ".mate2/sensors-applet/plugins"
+
+static void load_all_plugins(SensorsApplet *sensors_applet, const gchar *path) {
+
+    if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+        GDir *dir;
+        if ((dir = g_dir_open(path, 0, NULL)) != NULL) {
+            const gchar *file;
+            while ((file = g_dir_read_name(dir)) != NULL) {
+                /* try and open plugin */
+                gchar *plugin_file;
+                void *handle;
+                SensorsAppletPluginInit init_fn;
+
+                plugin_file = g_strdup_printf("%s/%s", path, file);
+                g_debug("found %s in plugin directory", plugin_file);
+                if ((handle = dlopen(plugin_file, RTLD_NOW)) != NULL) {
+                    SensorsAppletPluginName name_fn;
+                    SensorsAppletPluginGetSensorValue get_value_fn;
+
+                    if ((name_fn = dlsym(handle, "sensors_applet_plugin_name")) != NULL &&
+                        (init_fn = dlsym(handle, "sensors_applet_plugin_init")) != NULL &&
+                        (get_value_fn = dlsym(handle, "sensors_applet_plugin_get_sensor_value")) != NULL) {
+
+                        GList *sensors;
+                        g_debug("calling init function for plugin file %s", plugin_file);
+
+                        if ((sensors = init_fn()) != NULL) {
+                            GList *sensor;
+
+                            g_debug("registering plugin %s", name_fn());
+                            g_hash_table_insert(sensors_applet->plugins, g_strdup(name_fn()), get_value_fn);
+
+                            for (sensor = g_list_first(sensors); sensor != NULL; sensor = g_list_next(sensor)) {
+
+                                SensorsAppletSensorInfo *sensor_info = (SensorsAppletSensorInfo *)sensor->data;
+                                sensors_applet_add_sensor(sensors_applet,
+                                                          sensor_info->path,
+                                                          sensor_info->id,
+                                                          sensor_info->label,
+                                                          name_fn(),
+                                                          sensor_info->type,
+                                                          sensor_info->enable,
+                                                          sensor_info->low_value,
+                                                          sensor_info->high_value,
+                                                          FALSE, /* ALARM OFF */
+                                                          "", /* no alarm commands */
+                                                          "", /* no alarm commands */
+                                                          0, /* alarm_timeout */
+                                                          sensor_info->multiplier,
+                                                          sensor_info->offset,
+                                                          sensor_info->icon,
+                                                          sensor_info->graph_color);
+
+                                // sensors_applet_add_sensor() doesn't free strings, so free them here
+                                g_free(sensor_info->path);
+                                g_free(sensor_info->id);
+                                g_free(sensor_info->label);
+                                g_free(sensor_info->graph_color);
+                                g_free(sensor_info);
+                            }
+                            g_list_free(sensors);
+                        } else {
+                            g_debug("plugin could not find any sensors");
+                            if (g_hash_table_lookup(sensors_applet->required_plugins, name_fn())) {
+                                g_debug("plugin is required - registering even though no sensors detected");
+                                g_debug("registering plugin %s", name_fn());
+                                g_hash_table_insert(sensors_applet->plugins, g_strdup(name_fn()), get_value_fn);
+                            } else {
+                                g_debug("unloading plugin");
+                            }
+                        }
+
+                    } else {
+                        g_debug("plugin file %s does not contain the required interface", plugin_file);
+                        if (dlclose(handle) != 0) {
+                            g_debug("error closing plugin file %s", plugin_file);
+                        }
+                    }
+                } else {
+                    g_debug("Could not dlopen: %s: %s", plugin_file, dlerror());
+                }
+                g_free(plugin_file);
+            }
+            g_dir_close(dir);
+        } else {
+            g_debug("error opening plugin dir %s", path);
+        }
+    } else {
+        g_debug("path %s is not a valid directory", path);
+    }
+}
+
+void sensors_applet_plugins_load_all(SensorsApplet *sensors_applet) {
+    const gchar *home;
+
+    if ((home = g_get_home_dir()) != NULL) {
+        gchar *path;
+        path = g_build_filename(home, SENSORS_APPLET_USER_PLUGIN_DIR, NULL);
+        load_all_plugins(sensors_applet, path);
+        g_free(path);
+    } else {
+        g_warning("could not get home dir of user");
+    }
+
+    load_all_plugins(sensors_applet, SENSORS_APPLET_PLUGIN_DIR);
+}
+
+SensorsAppletPluginGetSensorValue sensors_applet_plugins_get_sensor_value_func(SensorsApplet *sensors_applet, const gchar *plugin) {
+    return g_hash_table_lookup(sensors_applet->plugins, plugin);
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/44.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/44.html new file mode 100644 index 0000000..771c736 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/44.html @@ -0,0 +1,1537 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
+517
+518
+519
+520
+521
+522
+523
+524
+525
+526
+527
+528
+529
+530
+531
+532
+533
+534
+535
+536
+537
+538
+539
+540
+541
+542
+543
+544
+545
+546
+547
+548
+549
+550
+551
+552
+553
+554
+555
+556
+557
+558
+559
+560
+561
+562
+563
+564
+565
+566
+567
+568
+569
+570
+571
+572
+573
+574
+575
+576
+577
+578
+579
+580
+581
+582
+583
+584
+585
+586
+587
+588
+589
+590
+591
+592
+593
+594
+595
+596
+597
+598
+599
+600
+601
+602
+603
+604
+605
+606
+607
+608
+609
+610
+611
+612
+613
+614
+615
+616
+617
+618
+619
+620
+621
+622
+623
+624
+625
+626
+627
+628
+629
+630
+631
+632
+633
+634
+635
+636
+637
+638
+639
+640
+641
+642
+643
+644
+645
+646
+647
+648
+649
+650
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ *               2013 Stefano Karapetsas <stefano@karapetsas.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensors-applet.h"
+#include "sensors-applet-settings.h"
+
+/* #define SORT_DEBUG */
+#ifdef SORT_DEBUG
+#include <syslog.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+/* these must be as the gsettings schema in file org.mate.sensors-applet.gschema.xml.in
+ * gsettings gvariant type string */
+#define GSGVTS "s"
+/* gsettings gvariant type string for the array */
+#define GSGVTSA "as"
+
+gchar* sensors_applet_settings_get_unique_id (const gchar *interface, const gchar *id, const gchar *path) {
+    gchar *unique_id = NULL;
+    gchar *unique_id_hash = NULL;
+    GChecksum *checksum = NULL;
+    guint8 digest[16];
+    gsize digest_len = sizeof (digest);
+
+    unique_id = g_strdup_printf ("%s/%s/%s", interface, id, path);
+
+    checksum = g_checksum_new (G_CHECKSUM_MD5);
+    g_checksum_update (checksum, (const guchar *) unique_id, strlen (unique_id));
+    g_checksum_get_digest (checksum, digest, &digest_len);
+    g_assert (digest_len == 16);
+
+    unique_id_hash = g_strdup (g_checksum_get_string (checksum));
+
+    g_checksum_free (checksum);
+    g_free (unique_id);
+
+    return unique_id_hash;
+}
+
+/* load sensors from gsettings with sorting */
+gboolean sensors_applet_settings_load_sensors (SensorsApplet *sensors_applet) {
+    /* everything gets stored except alarm timeout indexes, which
+    we set to -1, and visible which we set to false for all
+    parent nodes and true for all child nodes */
+
+    gchar *applet_path = NULL;
+    /* not sure about pointer, it is unclear if it is freed by loop, probably yes */
+    GVariantIter *iter = NULL;
+    gchar *gsuid = NULL;
+
+    /* string variables, to help free up memory in loop */
+    gchar *current_path = NULL;
+    gchar *current_id = NULL;
+    gchar *current_label = NULL;
+    gchar *current_interface = NULL;
+    gchar *current_low_alarm_command = NULL;
+    gchar *current_high_alarm_command = NULL;
+    gchar *current_graph_color = NULL;
+
+    /* get gsettings path for applet */
+    applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+
+    /* get sensors-list array from gsettings */
+    g_settings_get (sensors_applet->settings, "sensors-list", GSGVTSA, &iter);
+
+    /* load sensor data into applet one by one
+     * first get unique id for the sensor
+     * then load sensor data from gsettings
+     * then add sensor
+     * gsuid is freed by g_variant_iter_loop() */
+    while (g_variant_iter_loop (iter, GSGVTS, &gsuid)) {
+
+        /* load sensor data from gsettings individually
+         * g_strdup_printf doesn't free args!
+         * applet_path is freed at the end */
+        gchar *path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+        /*g_free (gsuid);   // freed by loop */
+
+        /* make a schema which points to one sensor data */
+        GSettings *settings;
+        settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", path);
+        g_free (path);
+
+        /* laod sensor data to temp variables
+         * g_settings_get_string allocates memory!
+         * sensors_applet_add_sensor() gtk_tree_store_set() copies strings, so free them */
+        sensors_applet_add_sensor(sensors_applet,
+            current_path = g_settings_get_string (settings, PATH),
+            current_id = g_settings_get_string (settings, ID),
+            current_label = g_settings_get_string (settings, LABEL),
+            current_interface = g_settings_get_string (settings, INTERFACE),
+            g_settings_get_int (settings, SENSOR_TYPE),
+            g_settings_get_boolean (settings, ENABLED),
+            g_settings_get_double (settings, LOW_VALUE),
+            g_settings_get_double (settings, HIGH_VALUE),
+            g_settings_get_boolean (settings, ALARM_ENABLED),
+            current_low_alarm_command = g_settings_get_string (settings, LOW_ALARM_COMMAND),
+            current_high_alarm_command = g_settings_get_string (settings, HIGH_ALARM_COMMAND),
+            g_settings_get_int (settings, ALARM_TIMEOUT),
+            g_settings_get_double (settings, MULTIPLIER),
+            g_settings_get_double (settings, OFFSET),
+            g_settings_get_int (settings, ICON_TYPE),
+            current_graph_color = g_settings_get_string (settings, GRAPH_COLOR));
+
+        g_free (current_path);
+        g_free (current_id);
+        g_free (current_label);
+        g_free (current_interface);
+        g_free (current_low_alarm_command);
+        g_free (current_high_alarm_command);
+        g_free (current_graph_color);
+
+        g_object_unref (settings);
+
+    }
+
+    g_free (applet_path);
+
+    return TRUE;
+}
+
+#ifdef SORT_DEBUG
+/* print a gtk_tree_store (for debug) */
+static void sensors_applet_settings_print_sensors_tree (SensorsApplet *sensors_applet) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->sensors);
+
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gint interfaces_counter = 0;
+    gint sensors_counter = 0;
+
+    gchar *interface_name = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_path = NULL;
+    gchar *sensor_hash = NULL;
+
+    /* iterate through the sensor tree
+     * code from sensors-applet.c sensors_applet_add_sensor()
+     * first go through the interfaces */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter), interfaces_counter++) {
+
+        /* get interface name */
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &interface_name, -1);
+
+        /* print interface name */
+        syslog(LOG_ERR, "#%d interface name: %s\n", interfaces_counter, interface_name);
+
+        /* then go through the individual sensors under one interface */
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter), sensors_counter++) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                       PATH_COLUMN, &sensor_path,
+                       ID_COLUMN, &sensor_id,
+                       -1);
+
+            sensor_hash = sensors_applet_settings_get_unique_id (interface_name, sensor_id, sensor_path);
+
+            /* print sensor data */
+            syslog(LOG_ERR, "\t#%d sensor id: %s\n", sensors_counter, sensor_id);
+            syslog(LOG_ERR, "\t#%d sensor path: %s\n", sensors_counter, sensor_path);
+            syslog(LOG_ERR, "\t#%d sensor hash: %s\n\n", sensors_counter, sensor_hash);
+
+            g_free(sensor_id);
+            g_free(sensor_path);
+            g_free(sensor_hash);
+
+        }
+
+        g_free(interface_name);
+
+    }
+
+}
+#endif
+
+/* compare two iters using their paths
+ * kinda same as active_sensor_compare () */
+static gint sensors_applet_settings_sort_sensors_iter_compare (SensorsApplet *sensors_applet, GtkTreeIter ti_a, GtkTreeIter ti_b) {
+
+    GtkTreePath *tp_a;
+    GtkTreePath *tp_b;
+    gint ret_val;
+
+    tp_a = gtk_tree_model_get_path (GTK_TREE_MODEL(sensors_applet->sensors), &ti_a);
+    tp_b = gtk_tree_model_get_path (GTK_TREE_MODEL(sensors_applet->sensors), &ti_b);
+
+    ret_val = gtk_tree_path_compare(tp_a, tp_b);
+
+    gtk_tree_path_free(tp_a);
+    gtk_tree_path_free(tp_b);
+
+    return ret_val;
+}
+
+/* find two sensors in the sensors tree based on their hash and sort them
+ * Return codes:
+ * 0: something went very wrong...
+ * 1: normal run, a and b are in place
+ * 2: hash_b has already been removed from the system
+ * 3: hash_a is not found */
+static gint sensors_applet_settings_sort_sensors_sort (SensorsApplet *sensors_applet,
+                                                           const gchar *hash_a,
+                                                           const gchar *hash_b,
+                                                           gboolean a_is_first) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->sensors);
+
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+
+    gchar *interface_name = NULL;
+    gchar *sensor_id = NULL;
+    gchar *sensor_path = NULL;
+    gchar *sensor_hash = NULL;
+
+    GtkTreeIter interface_iter_a;
+    GtkTreeIter interface_iter_b;
+    GtkTreeIter sensor_iter_a;
+    GtkTreeIter sensor_iter_b;
+    gboolean found_a = FALSE;
+    gboolean found_b = FALSE;
+
+    /* iterate through the sensor tree
+     * code from sensors-applet.c sensors_applet_add_sensor()
+     * first go through the interfaces */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        /* get interface name */
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &interface_name, -1);
+
+        /* then go through the individual sensors under one interface */
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                       PATH_COLUMN, &sensor_path,
+                       ID_COLUMN, &sensor_id,
+                       -1);
+
+            sensor_hash = sensors_applet_settings_get_unique_id (interface_name, sensor_id, sensor_path);
+
+            /* save interface_name and iters for swap */
+            if (g_ascii_strcasecmp(sensor_hash, hash_a) == 0) {
+                /* can copy by value, don't free */
+                interface_iter_a = interfaces_iter;
+                sensor_iter_a = sensors_iter;
+                found_a = TRUE;
+            }
+
+            if (g_ascii_strcasecmp(sensor_hash, hash_b) == 0) {
+                interface_iter_b = interfaces_iter;
+                sensor_iter_b = sensors_iter;
+                found_b = TRUE;
+            }
+
+            g_free(sensor_id);
+            g_free(sensor_path);
+            g_free(sensor_hash);
+
+            /* break after freeing loop variables */
+            if (found_a && found_b) {
+                break;
+            }
+        }
+
+        g_free(interface_name);
+
+        /* break after freeing loop variables */
+        if (found_a && found_b) {
+            break;
+        }
+    }
+
+    /* make the switch */
+    if (found_a && found_b) {
+
+        GtkTreeIter first_iter;
+        GtkTreeIter iter_next;
+
+        gint ret_val;
+
+        /* set a's interface to be the first interface in the sensors tree */
+        if (a_is_first) {
+
+            /* this 'fails' if the tree is empty, but this is already checked with the first loop */
+            gtk_tree_model_get_iter_first (GTK_TREE_MODEL(sensors_applet->sensors), &first_iter);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the a's interface is not the first interface */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, interface_iter_a)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &interface_iter_a, NULL);
+            }
+
+        }
+
+        /* check b's interface position
+         * (1) if it is before a's if. - not possible, bc I have just set a's if. as first
+         * afterwards every new if. will be set right after (one) a's if.
+         * (0) if it is the same as a's, noop
+         * (-1) if it is after a, check if it is right after a, if not move it there */
+        ret_val = sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, interface_iter_a, interface_iter_b);
+        if (-1 == ret_val) {
+
+            /* set iter_next to the iter after a's if. iter, can copy like this */
+            iter_next = interface_iter_a;
+            /* this 'fails' if there is no node after a's if. iter, but we already know, that at least b's if. iter is */
+            gtk_tree_model_iter_next (GTK_TREE_MODEL(sensors_applet->sensors), &iter_next);
+
+            /* the node right after a's if. iter is not b's if. iter, so move b's if. iter */
+            if (0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, iter_next, interface_iter_b)) {
+
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &interface_iter_b, &interface_iter_a);
+            }
+        }
+
+        /* at this point the interfaces are sorted, the sensors are next */
+        /* set a to be the first sensor in the sensors tree, under the first if. iter */
+        if (a_is_first) {
+
+            /* this 'fails' if the tree is empty, but at least a is in it */
+            gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &first_iter,  &interface_iter_a);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the a is not the first sensor */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, sensor_iter_a)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_a, NULL);
+            }
+
+        }
+
+        /* check b's position
+         * if a's if. and b's if is the same
+         * (1) if it is before a's if. - not possible, bc I have just set a as first
+         * afterwards every new sensor will be set right after (one) a
+         * (0) if it is the same as a's, not possible, a and b would be equal
+         * (-1) if it is after a, check if it is right after a, if not move it there */
+        if (0 == ret_val && -1 == sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, sensor_iter_a, sensor_iter_b)) {
+
+            /* set iter_next to the iter after a's iter, can copy like this */
+            iter_next = sensor_iter_a;
+            /* this 'fails' if there is no node after a's iter, but we already know, that at least b's iter is */
+            gtk_tree_model_iter_next (GTK_TREE_MODEL(sensors_applet->sensors), &iter_next);
+
+            /* the node right after a's iter is not b's iter, so move b's iter */
+            if (0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, iter_next, sensor_iter_b)) {
+
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_b, &sensor_iter_a);
+            }
+        }
+
+        /* if a's if. and b's if is not the same
+         * as b comes after a, b must be under a new if.
+         * and so b must be the first node under that if. */
+        /* set b to be the first sensor in the sensors tree, under the b's if. iter */
+        if (-1 == ret_val) {
+
+            /* this 'fails' if the tree is empty, but at least b is in it */
+            gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &first_iter,  &interface_iter_b);
+
+            /* we are only interested in the case, where the two are not equal
+             * that means the b is not the first sensor */
+            if ( 0 != sensors_applet_settings_sort_sensors_iter_compare (sensors_applet, first_iter, sensor_iter_b)) {
+
+                /* it should be, so it needs to be moved to the first position */
+                gtk_tree_store_move_after (GTK_TREE_STORE(sensors_applet->sensors), &sensor_iter_b, NULL);
+            }
+
+        }
+
+        return 1;
+
+    }
+
+    /* hash_b has already been removed from the system */
+    if (found_a && !found_b) {
+        return 2;
+    }
+
+    /* this is the least likely case
+     * if hash_a is not found, then the sensors-list starts with a sensor
+     * that has already been removed from the system */
+    if (!found_a) {
+        return 3;
+    }
+
+    /* we should never get here */
+    return 0;
+}
+
+/* sort sensors based on sensors-list array in gsettings */
+gboolean sensors_applet_settings_sort_sensors (SensorsApplet *sensors_applet) {
+
+    gchar **sensors_list = NULL;
+
+    gchar *hash_a = NULL;
+    gchar *hash_b = NULL;
+
+    gint ret_val = -1;
+    /* marks the first iteration */
+    gint first_counter = 1;
+
+    /* get sensors-list array from gsettings
+     * newly allocated, has to be freed fully
+     * for an empty array a pointer to a NULL pointer will be returned (g_variant_dup_strv ()) */
+    sensors_list = g_settings_get_strv (sensors_applet->settings, "sensors-list");
+
+    /* list is empty (on the first run) */
+    if (NULL == *sensors_list) {
+        /* still need to free the array, even if it is empty */
+        g_strfreev (sensors_list);
+        return FALSE;
+    }
+
+    gint i;
+    /* hash lists are equal */
+    gboolean hle = TRUE;
+    /* compare saved sorted list to newly loaded sensors' list */
+    for (i = 0; (NULL != sensors_applet->sensors_hash_array[i]) && (NULL != sensors_list[i]); i++) {
+
+        if (g_ascii_strcasecmp(sensors_applet->sensors_hash_array[i], sensors_list[i]) != 0) {
+            hle = FALSE;
+            break;
+        }
+    }
+
+    /* lists are the same -> nothing to do */
+    if (hle) {
+#ifdef SORT_DEBUG
+        syslog(LOG_ERR, "sensor sort: saved list is the same as the new one, returning");
+#endif
+
+        /* still need to free the array */
+        g_strfreev (sensors_list);
+        return TRUE;
+    }
+
+#ifdef SORT_DEBUG
+    sensors_applet_settings_print_sensors_tree (sensors_applet);
+#endif
+
+    for (i = 0; NULL != sensors_list[i]; i++) {
+
+        /* first pass */
+        if (i == 0) {
+            /* make a copy */
+            hash_a = g_strdup (sensors_list[i]);
+            continue;
+        }
+
+        hash_b = g_strdup (sensors_list[i]);
+
+        /* now that we have two hashes, find the two corresponding sensors and sort them
+         * if i == 1, we have both a and b set, this is the first time calling this function */
+        ret_val = sensors_applet_settings_sort_sensors_sort (sensors_applet, hash_a, hash_b, (i == first_counter));
+
+        /* hash_b has already been removed from the system
+         * don't free hash_a, don't reassign hash_b
+         * as we already know that b is no longer in the system */
+        if (2 == ret_val) {
+            continue;
+        }
+
+        /* after sorting free hash_a (it should be in place) and reassign hash_b to hash_a */
+        g_free (hash_a);
+        hash_a = hash_b;
+
+        /* hash_a not found
+         * set hash_b as hash_a and set the first element counter
+         * (essentially skip the first element in the sensors-list array) */
+        if (3 == ret_val) {
+            first_counter++;
+        }
+    }
+
+#ifdef SORT_DEBUG
+    sensors_applet_settings_print_sensors_tree (sensors_applet);
+#endif
+
+    /* hash_a already freed
+     * only in the following case do we need to free it */
+    if (2 == ret_val) {
+        g_free (hash_a);
+    }
+    g_free (hash_b);
+
+    g_strfreev (sensors_list);
+
+    /* reorder active sensors based on reordered sensors tree */
+    sensors_applet_reorder_sensors (sensors_applet);
+
+    return TRUE;
+}
+
+/* save sensor data under a unique hash
+ * save sensor sort in an array, with above hash */
+gboolean sensors_applet_settings_save_sensors (SensorsApplet *sensors_applet) {
+
+    /* write everything to GSettings except VISIBLE and ALARM_TIMEOUT_INDEX
+     * for stepping through GtkTreeStore data structure */
+    GtkTreeIter interfaces_iter;
+    GtkTreeIter sensors_iter;
+    gboolean not_end_of_interfaces = TRUE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gchar *applet_path = NULL;
+
+    gchar *current_path = NULL;
+    gchar *current_id = NULL;
+    gchar *current_label = NULL;
+    gchar *current_interface = NULL;
+    gchar *current_low_alarm_command = NULL;
+    gchar *current_high_alarm_command = NULL;
+    gchar *current_graph_color = NULL;
+    gboolean current_enable,
+             current_alarm_enable;
+    gdouble current_low_value,
+            current_high_value,
+            current_multiplier,
+            current_offset;
+    guint current_alarm_timeout,
+          current_sensor_type,
+          current_icon_type;
+
+    /* data structure (array) to be able to save sensors list to gsettings */
+    GVariantBuilder builder;
+    g_variant_builder_init (&builder, G_VARIANT_TYPE (GSGVTSA));
+
+    applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+
+    /* now step through the GtkTreeStore sensors to find which sensors are available / loaded */
+    for (not_end_of_interfaces = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+        not_end_of_interfaces;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter);
+            not_end_of_sensors;
+            not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+            gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                               &sensors_iter,
+                               PATH_COLUMN, &current_path,
+                               ID_COLUMN, &current_id,
+                               LABEL_COLUMN, &current_label,
+                               INTERFACE_COLUMN, &current_interface,
+                               SENSOR_TYPE_COLUMN, &current_sensor_type,
+                               ENABLE_COLUMN, &current_enable,
+                               LOW_VALUE_COLUMN, &current_low_value,
+                               HIGH_VALUE_COLUMN, &current_high_value,
+                               ALARM_ENABLE_COLUMN, &current_alarm_enable,
+                               LOW_ALARM_COMMAND_COLUMN, &current_low_alarm_command,
+                               HIGH_ALARM_COMMAND_COLUMN, &current_high_alarm_command,
+                               ALARM_TIMEOUT_COLUMN, &current_alarm_timeout,
+                               MULTIPLIER_COLUMN, &current_multiplier,
+                               OFFSET_COLUMN, &current_offset,
+                               ICON_TYPE_COLUMN, &current_icon_type,
+                               GRAPH_COLOR_COLUMN, &current_graph_color,
+                               -1);
+
+            /* GSettings unique id for one sensor data */
+            gchar *gsuid = sensors_applet_settings_get_unique_id (current_interface, current_id, current_path);
+
+            /* save sensor uid to gvariant array */
+            g_variant_builder_add(&builder,
+                GSGVTS,       /* must be related to the G_VARIANT_TYPE in init and gsettings schema */
+                gsuid);
+
+            /* save sensor data to gsettings individually
+             * g_strdup_printf doesn't free args!
+             * applet_path is freed at the end */
+            gchar *path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+            g_free (gsuid);
+
+            GSettings *settings;
+            settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", path);
+            g_free (path);
+
+            /* wait until g_settings_apply() is called to save all changes at once to gsettings */
+            g_settings_delay (settings);
+            g_settings_set_string (settings, PATH, current_path);
+            g_settings_set_string (settings, ID, current_id);
+            g_settings_set_string (settings, LABEL, current_label);
+            g_settings_set_string (settings, INTERFACE, current_interface);
+            g_settings_set_int (settings, SENSOR_TYPE, current_sensor_type);
+            g_settings_set_boolean (settings, ENABLED, current_enable);
+            g_settings_set_double (settings, LOW_VALUE, current_low_value);
+            g_settings_set_double (settings, HIGH_VALUE, current_high_value);
+            g_settings_set_boolean (settings, ALARM_ENABLED, current_alarm_enable);
+            g_settings_set_string (settings, LOW_ALARM_COMMAND, current_low_alarm_command);
+            g_settings_set_string (settings, HIGH_ALARM_COMMAND, current_high_alarm_command);
+            g_settings_set_int (settings, ALARM_TIMEOUT, current_alarm_timeout);
+            g_settings_set_double (settings, MULTIPLIER, current_multiplier);
+            g_settings_set_double (settings, OFFSET, current_offset);
+            g_settings_set_int (settings, ICON_TYPE, current_icon_type);
+            g_settings_set_string (settings, GRAPH_COLOR, current_graph_color);
+            g_settings_apply (settings);
+            g_object_unref (settings);
+
+        }
+    }
+
+    /* save the sensor-list array to gsettings
+     * builder is freed by g_variant_builder_end()
+     * the gvariant returned from g_variant_builder_end() is floating, so it is freed by g_settings_set_value() */
+    g_settings_set_value (sensors_applet->settings, "sensors-list", g_variant_builder_end (&builder));
+
+    g_free (applet_path);
+
+    return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/45.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/45.html new file mode 100644 index 0000000..56b350f --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/45.html @@ -0,0 +1,2911 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
+1202
+1203
+1204
+1205
+1206
+1207
+1208
+1209
+1210
+1211
+1212
+1213
+1214
+1215
+1216
+1217
+1218
+1219
+1220
+1221
+1222
+1223
+1224
+1225
+1226
+1227
+1228
+1229
+1230
+1231
+1232
+1233
+1234
+1235
+1236
+1237
+1238
+1239
+1240
+1241
+1242
+1243
+1244
+1245
+1246
+1247
+1248
+1249
+1250
+1251
+1252
+1253
+1254
+1255
+1256
+1257
+1258
+1259
+1260
+1261
+1262
+1263
+1264
+1265
+1266
+1267
+1268
+1269
+1270
+1271
+1272
+1273
+1274
+1275
+1276
+1277
+1278
+1279
+1280
+1281
+1282
+1283
+1284
+1285
+1286
+1287
+1288
+1289
+1290
+1291
+1292
+1293
+1294
+1295
+1296
+1297
+1298
+1299
+1300
+1301
+1302
+1303
+1304
+1305
+1306
+1307
+1308
+1309
+1310
+1311
+1312
+1313
+1314
+1315
+1316
+1317
+1318
+1319
+1320
+1321
+1322
+1323
+1324
+1325
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+/** Contain the functions for operating on the SensorsApplet structure
+ *  (represents the applet itself, and its associated variables.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_UNISTD_H */
+
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gprintf.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "sensors-applet.h"
+#include "active-sensor.h"
+#include "sensors-applet-settings.h"
+#include "sensors-applet-plugins.h"
+
+#ifdef HAVE_LIBNOTIFY
+#include "active-sensor-libnotify.h"
+#define DEFAULT_NOTIFY_TIMEOUT 3000
+#endif
+
+#include "prefs-dialog.h"
+#include "about-dialog.h"
+
+#define SENSORS_APPLET_MENU_FILE "SensorsApplet.xml"
+/* initially set as sensors_applet->size to ensure a real value is stored */
+#define DEFAULT_APPLET_SIZE 24
+#define COLUMN_SPACING 2
+#define ROW_SPACING 1
+
+/* builder for sensor sorting verification */
+static GVariantBuilder gvb_sensors_hash_list;
+
+/* callbacks for panel menu */
+static void prefs_cb(GtkAction *action, gpointer *data) {
+
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    if (sensors_applet->prefs_dialog) {
+        gtk_window_present(GTK_WINDOW(sensors_applet->prefs_dialog->dialog));
+        return;
+    }
+    prefs_dialog_open(sensors_applet);
+}
+
+static void about_cb(GtkAction *action, gpointer data) {
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    about_dialog_open(sensors_applet);
+}
+
+static void help_cb(GtkAction *action, gpointer data) {
+
+    GError *error = NULL;
+
+    gtk_show_uri_on_window(NULL, "help:mate-sensors-applet",
+
+        gtk_get_current_event_time(),
+        &error);
+
+    if (error) {
+        g_debug("Could not open help document: %s ",error->message);
+        g_error_free(error);
+    }
+}
+
+static void destroy_cb(GtkWidget *widget, gpointer data) {
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    /* destroy dialogs, remove timeout and clear sensors tree and finally the applet */
+    if (sensors_applet->prefs_dialog != NULL) {
+        /* destroy's dialog too */
+        prefs_dialog_close(sensors_applet);
+    }
+
+    if (sensors_applet->timeout_id) {
+        g_source_remove(sensors_applet->timeout_id);
+    }
+
+    if (sensors_applet->settings) {
+        g_object_unref (sensors_applet->settings);
+        sensors_applet->settings = NULL;
+    }
+
+    /* destroy all active sensors */
+    g_list_foreach(sensors_applet->active_sensors,
+                   (GFunc)active_sensor_destroy,
+                   NULL);
+
+    if (sensors_applet->sensors != NULL) {
+        gtk_tree_store_clear(sensors_applet->sensors);
+    }
+
+    gtk_widget_destroy(GTK_WIDGET(sensors_applet->applet));
+
+    g_free(sensors_applet);
+    return;
+}
+
+static void change_orient_cb (MatePanelApplet *applet,
+                              MatePanelAppletOrient orient,
+                              gpointer data) {
+
+    SensorsApplet *sensors_applet;
+    sensors_applet = (SensorsApplet *)data;
+
+    sensors_applet_display_layout_changed(sensors_applet);
+}
+
+static void size_allocate_cb(MatePanelApplet *applet,
+                             GtkAllocation *allocation,<--- Parameter 'allocation' can be declared as pointer to const
+                             gpointer data) {
+
+    SensorsApplet *sensors_applet;
+    MatePanelAppletOrient orient;
+
+    sensors_applet = (SensorsApplet *)data;
+    orient = mate_panel_applet_get_orient(sensors_applet->applet);
+
+    if ((orient == MATE_PANEL_APPLET_ORIENT_LEFT) ||
+        (orient == MATE_PANEL_APPLET_ORIENT_RIGHT)) {
+
+        if (sensors_applet->size == allocation->width)
+            return;
+        sensors_applet->size = allocation->width;
+    } else {
+        if (sensors_applet->size == allocation->height)
+            return;
+        sensors_applet->size = allocation->height;
+    }
+
+    /* update if new value */
+    sensors_applet_graph_size_changed(sensors_applet);
+    sensors_applet_display_layout_changed(sensors_applet);
+}
+
+static void style_set_cb(GtkWidget *widget, GtkStyle *old_style, gpointer data) {
+
+    /* update all icons in the sensors tree and update all active sensors */
+    GtkTreeIter interfaces_iter, sensors_iter;
+    gboolean not_end_of_interfaces = TRUE, not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    IconType icon_type;
+    gboolean enabled;
+    SensorsApplet *sensors_applet;
+    DisplayMode display_mode;
+
+    sensors_applet = (SensorsApplet *)data;
+
+    display_mode = g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+    if (sensors_applet->sensors) {
+        for (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);
+            not_end_of_interfaces;
+            not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+            /* reset sensors sentinel */
+            not_end_of_sensors = TRUE;
+
+            for (gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter, &interfaces_iter);
+                not_end_of_sensors;
+                not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+                GdkPixbuf *new_icon;
+
+                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors),
+                                   &sensors_iter,
+                                   ENABLE_COLUMN, &enabled,
+                                   ICON_TYPE_COLUMN, &icon_type,
+                                   -1);
+                /* update icons */
+                new_icon = sensors_applet_load_icon(icon_type);
+
+                gtk_tree_store_set(sensors_applet->sensors,
+                                   &sensors_iter,
+                                   ICON_PIXBUF_COLUMN, new_icon,
+                                   -1);
+                g_object_unref(new_icon);
+
+                /* update icons only if currently being displayed */
+                if (enabled &&
+                    (display_mode == DISPLAY_ICON ||
+                     display_mode == DISPLAY_ICON_WITH_VALUE)) {
+
+                    GtkTreePath *path;
+
+                    path = gtk_tree_model_get_path(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter);
+                    sensors_applet_icon_changed(sensors_applet, path);
+                    gtk_tree_path_free(path);
+                }
+            }
+        }
+        /* now update layout as size may have changed */
+        sensors_applet_display_layout_changed(sensors_applet);
+    }
+
+}
+
+static gboolean mouse_enter_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+{
+    SensorsApplet *sensor_applet = data;
+    sensor_applet->show_tooltip = TRUE;
+    sensors_applet_update_active_sensors(sensor_applet);
+    return TRUE;
+}
+
+static gboolean mouse_leave_cb(GtkWidget *widget, GdkEventCrossing *event, gpointer data)
+{
+    SensorsApplet *sensor_applet = data;
+    sensor_applet->show_tooltip = FALSE;
+    return TRUE;
+}
+
+static const GtkActionEntry sensors_applet_menu_actions[] = {
+    { "Preferences", "document-properties", N_("_Preferences"),
+        NULL, NULL,
+        G_CALLBACK(prefs_cb) },
+    { "Help", "help-browser", N_("_Help"),
+        NULL, NULL,
+        G_CALLBACK(help_cb) },
+    { "About", "help-about", N_("_About"),
+        NULL, NULL,
+        G_CALLBACK(about_cb) }
+};
+
+void sensors_applet_notify_active_sensor(ActiveSensor *active_sensor, NotifType notif_type) {
+#ifdef HAVE_LIBNOTIFY
+
+    SensorsApplet *sensors_applet;
+    gchar *summary, *message;
+    gint timeout_msecs;
+    gchar *sensor_label;
+    gchar *sensor_path;
+    SensorType sensor_type;
+    TemperatureScale temp_scale;
+    GtkTreeIter iter;
+    GtkTreePath *path;
+    const gchar *unit_type = NULL;
+    const gchar *unit_type_title = NULL;
+    const gchar *relation = NULL;
+    const gchar *limit_type = NULL;
+    const gchar *units = NULL;
+    gdouble limit_value;
+    gdouble seconds;
+    gboolean show_notification = TRUE;
+
+    sensors_applet = active_sensor->sensors_applet;
+
+    if (!g_settings_get_boolean (sensors_applet->settings, DISPLAY_NOTIFICATIONS)) {
+        g_debug("Wanted to display notification, but user has disabled them");
+        return;
+    }
+
+    path = gtk_tree_row_reference_get_path(active_sensor->sensor_row);
+    if (gtk_tree_model_get_iter(GTK_TREE_MODEL(sensors_applet->sensors), &iter, path)) {
+
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &iter,
+                           LABEL_COLUMN, &sensor_label,
+                           PATH_COLUMN, &sensor_path,
+                           SENSOR_TYPE_COLUMN, &sensor_type,
+                           -1);
+    } else {
+        g_warning("Error getting data from tree for notification...");
+        gtk_tree_path_free(path);
+        return;
+    }
+
+    gtk_tree_path_free(path);
+
+    /* do different stuff for different notif types */
+    switch (notif_type) {
+        case LOW_ALARM: /* fall thru */
+        case HIGH_ALARM:
+            if (active_sensor->sensor_values[0] <= active_sensor->sensor_low_value && notif_type == LOW_ALARM) {
+
+                relation = _("is very low");
+                limit_type = _("lower limit");
+                limit_value = active_sensor->sensor_low_value;
+            } else if (active_sensor->sensor_values[0] >= active_sensor->sensor_high_value && notif_type == HIGH_ALARM) {
+
+                /* assume high alarm condition */
+                relation = _("is very high");
+                limit_type = _("upper limit");
+                limit_value = active_sensor->sensor_high_value;
+            } else {
+                g_warning("Alarm notify called when no alarm condition!");
+                g_free(sensor_path);
+                g_free(sensor_label);
+                return;
+            }
+
+            switch ((SensorType)sensor_type) {
+                case TEMP_SENSOR:
+                    unit_type_title = _("Temperature");
+                    unit_type = _("temperature");
+                    temp_scale = (TemperatureScale) g_settings_get_int (active_sensor->sensors_applet->settings, TEMPERATURE_SCALE);
+
+                    switch (temp_scale) {
+                        case CELSIUS:
+                            units = UNITS_CELSIUS;
+                            break;
+                        case FAHRENHEIT:
+                            units = UNITS_FAHRENHEIT;
+                            break;
+                        case KELVIN:
+                            units = UNITS_KELVIN;
+                            break;
+                        default:
+                            units = NULL;
+                    }
+                    break;
+
+                case VOLTAGE_SENSOR:
+                    unit_type_title = _("Voltage");
+                    unit_type = _("voltage");
+                    units = UNITS_VOLTAGE;
+                    break;
+
+                case FAN_SENSOR:
+                    unit_type_title = _("Fan Speed");
+                    unit_type = _("fan speed");
+                    units = UNITS_RPM;
+                    break;
+
+                case CURRENT_SENSOR:
+                    unit_type_title = _("Current");
+                    unit_type = _("current");
+                    units = UNITS_CURRENT;
+                    break;
+            }
+
+            timeout_msecs = (active_sensor->alarm_timeout ? MIN(DEFAULT_NOTIFY_TIMEOUT, (active_sensor->alarm_timeout * 1000)) : DEFAULT_NOTIFY_TIMEOUT);
+
+            summary = g_strdup_printf("%s %s %s", sensor_label, unit_type_title, _("Alarm"));
+            message = g_strdup_printf("%s %s %s (%s %2.0f%s)", sensor_label, unit_type, relation, limit_type, limit_value, units);
+            break;
+
+        case SENSOR_INTERFACE_ERROR:
+            /* get time since the last error */
+            seconds = difftime(time(NULL), active_sensor->ierror_ts);
+
+            /* if the last error happened less than 10 seconds ago, don't display this one
+             * this should prevent recurring popups for removed sensors, like USB-HDDs */
+            if (seconds < 11.0) {
+                show_notification = FALSE;
+            }
+
+            summary = g_strdup_printf(_("Error updating sensor %s"), sensor_label);
+            message = g_strdup_printf(_("An error occurred while trying to update the value of the sensor %s located at %s."), sensor_label, sensor_path);
+            timeout_msecs = g_settings_get_int (active_sensor->sensors_applet->settings, TIMEOUT);
+
+            /* update timestamp */
+            time(&(active_sensor->ierror_ts));
+            break;
+
+        default:
+            g_assert_not_reached();
+    }
+
+    if (show_notification) {
+        active_sensor_libnotify_notify(active_sensor,
+                                       notif_type,
+                                       summary,
+                                       message,
+                                       "dialog-warning",
+                                       timeout_msecs);
+    }
+
+    g_free(sensor_path);
+    g_free(sensor_label);
+    g_free(summary);
+    g_free(message);
+#endif
+}
+
+void sensors_applet_notify_end(ActiveSensor *active_sensor, NotifType notif_type) {
+#ifdef HAVE_LIBNOTIFY
+    active_sensor_libnotify_notify_end(active_sensor, notif_type);
+#endif
+}
+
+#ifdef HAVE_LIBNOTIFY
+static void sensors_applet_notify_end_all_gfunc(ActiveSensor *active_sensor, gpointer data) {
+    active_sensor_libnotify_notify_end(active_sensor, LOW_ALARM);
+    active_sensor_libnotify_notify_end(active_sensor, HIGH_ALARM);
+}
+#endif
+
+void sensors_applet_notify_end_all(SensorsApplet *sensors_applet) {
+#ifdef HAVE_LIBNOTIFY
+    g_list_foreach(sensors_applet->active_sensors, (GFunc)sensors_applet_notify_end_all_gfunc, NULL);
+#endif
+}
+
+/* internal helper functions for updating display etc */
+
+/* should be called as a g_container_foreach at the start of
+ * pack_display if the grid already exists to remove but keep alive
+ * all children of the grid before repacking it */
+static void sensors_applet_pack_display_empty_grid_cb(GtkWidget *widget, gpointer data)
+{
+    GtkContainer *container;
+
+    container = GTK_CONTAINER(data);
+
+    /* ref then remove widget */
+    g_object_ref(widget);
+    gtk_container_remove(container, widget);
+}
+
+/* should be called as a g_container_foreach at the end of
+ * pack_display to unref any of the old children that we have readdded
+ * to the table to stop reference creep from the g_object_ref called
+ * on each child at the start of pack labels */
+static void sensors_applet_pack_display_cleanup_refs_cb(GtkWidget *widget, gpointer data) {
+
+    GList *old_children;
+
+    old_children = (GList *)data;
+    if (g_list_find(old_children, widget)) {
+        g_object_unref(widget);
+    }
+}
+
+static void sensors_applet_pack_display(SensorsApplet *sensors_applet) {
+    /* note the if () around each widget is to ensure we only
+     * operate on those that actually exist */
+    GtkLabel *no_sensors_enabled_label = NULL;
+    gint num_active_sensors = 0, num_sensors_per_group = 0, rows, cols, i, j;
+    GList *old_grid_children = NULL;
+
+    GList *current_sensor;
+
+    DisplayMode display_mode;
+    LayoutMode layout_mode;
+
+    gboolean horizontal;
+    gint label_width, icon_width, value_width;
+    gint label_height, icon_height, value_height;
+
+    GtkRequisition req;
+
+    ActiveSensor *first_sensor;
+
+    /* it is possible that there could be no active sensors so
+     * handle that case first - make sure we dont do a NULL
+     * pointer access first though */
+    if (sensors_applet->active_sensors == NULL || g_list_length(sensors_applet->active_sensors) == 0) {
+        g_debug("no active sensors to pack in grid");
+        no_sensors_enabled_label = g_object_new(GTK_TYPE_LABEL, "label", _("No sensors enabled!"), NULL);
+
+        if (sensors_applet->grid == NULL) {
+            /* only need 1 row and 1 col */
+            sensors_applet->grid = gtk_grid_new();
+            gtk_grid_set_column_spacing(GTK_GRID(sensors_applet->grid), COLUMN_SPACING);
+            gtk_grid_set_row_spacing(GTK_GRID(sensors_applet->grid), ROW_SPACING);
+            gtk_widget_set_halign(sensors_applet->grid, GTK_ALIGN_CENTER);
+            gtk_widget_set_valign(sensors_applet->grid, GTK_ALIGN_CENTER);
+            /* add grid to applet */
+            gtk_container_add(GTK_CONTAINER(sensors_applet->applet), sensors_applet->grid);
+        } else {
+            /* destroy existing widgets - could be an
+             * existing version of no sensors label - okay
+             * to just add again though if destroy first */
+            g_debug("destroying any existing widgets in container");
+            gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid), (GtkCallback)gtk_widget_destroy, NULL);
+        }
+        g_debug("packing no sensors enabled label");
+        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                 GTK_WIDGET(no_sensors_enabled_label),
+                                 0, 0, 1, 1);
+        gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+        return;
+    }
+    /* otherwise can acess active_sensors without any worries */
+    num_active_sensors = g_list_length(sensors_applet->active_sensors);
+
+    display_mode = (DisplayMode) g_settings_get_int (sensors_applet->settings, DISPLAY_MODE);
+    layout_mode = (LayoutMode) g_settings_get_int (sensors_applet->settings, LAYOUT_MODE);
+
+    horizontal = (((mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_UP) ||
+                  (mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_DOWN)));
+
+    /* figure out num rows / cols by how high / wide sensors
+     * labels / icons are and how much size we have to put them in */
+
+    /* get the first active sensor */
+    first_sensor = (ActiveSensor *)sensors_applet->active_sensors->data;
+
+    switch (display_mode) {
+        case DISPLAY_VALUE:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            /* make sure all widths and heights are non zero,
+             * otherwise will get a divide by zero exception below
+             * - is a non critical error since can happen when
+             * elements first added to list, so simply return - is
+             * not a programming error */
+            if (value_width == 0 && value_height == 0) {
+                return;
+            }
+
+            num_sensors_per_group = (sensors_applet->size / (horizontal ? value_height : value_width));
+            break;
+
+        case DISPLAY_LABEL_WITH_VALUE:
+            /* even though we end up packing the event boxes into the
+             * panel, these dont give back request sizes, so need to ask
+             * widgets directly */
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->label), &req, NULL);
+            label_width = req.width + COLUMN_SPACING;
+            label_height = req.height + ROW_SPACING;
+
+            /* make sure all widths and heights are non zero, otherwise
+             * will get a divide by zero exception below
+             * - is a non critical error since can happen when
+             * elements first added to list, so simply return - is
+             * not a programming error */
+            if (!(label_width && label_height && value_width && value_height)) {
+                return;
+            }
+
+            switch (layout_mode) {
+                case VALUE_BESIDE_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? MAX(label_height, value_height) : (label_width + value_width)));
+                    break;
+                case VALUE_BELOW_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? (label_height + value_height) : MAX(label_width, value_width)));
+                    break;
+            }
+            break;
+
+        case DISPLAY_ICON_WITH_VALUE:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->value), &req, NULL);
+            value_width = req.width + COLUMN_SPACING;
+            value_height = req.height + ROW_SPACING;
+
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->icon), &req, NULL);
+            icon_width = req.width + COLUMN_SPACING;
+            icon_height = req.height + ROW_SPACING;
+
+            if (!(icon_width && icon_height && value_width && value_height)) {
+                return;
+            }
+
+            switch (layout_mode) {
+                case VALUE_BESIDE_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? MAX(icon_height, value_height) : (icon_width + value_width)));
+                    break;
+
+                case VALUE_BELOW_LABEL:
+                    num_sensors_per_group = (sensors_applet->size / (horizontal ? (icon_height + value_height) : MAX(icon_width, value_width)));
+                    break;
+            }
+            break;
+
+        case DISPLAY_ICON:
+            gtk_widget_get_preferred_size(GTK_WIDGET(first_sensor->icon), &req, NULL);
+            icon_width = req.width + COLUMN_SPACING;
+            icon_height = req.height + ROW_SPACING;
+
+            if (!(icon_width && icon_height)) {
+                return;
+            }
+
+            num_sensors_per_group = (sensors_applet->size / (horizontal ? icon_height : icon_width));
+            break;
+
+        case DISPLAY_GRAPH:
+            /* only show graphs in a line like System Monitor applet */
+            num_sensors_per_group = 1;
+            break;
+    }
+
+    /* ensure always atleast 1 sensor per group */
+    if (num_sensors_per_group < 1) {
+        /* force a better layout */
+        if (horizontal && layout_mode == VALUE_BELOW_LABEL) {
+            layout_mode = VALUE_BESIDE_LABEL;
+        } else if (!horizontal && layout_mode == VALUE_BESIDE_LABEL) {
+            layout_mode = VALUE_BELOW_LABEL;
+        }
+        num_sensors_per_group = 1;
+    }
+
+    if (horizontal) {
+        /* if oriented horizontally, want as many
+           sensors per column as user has defined, then
+           enough columns to hold all the widgets */
+        rows = num_sensors_per_group;
+        cols = num_active_sensors / num_sensors_per_group;
+        while (rows * cols < num_active_sensors || cols == 0) {
+            cols++;
+        }
+
+    } else {
+        /* if oriented vertically, want as many
+           sensors per row as user has defined, then
+           enough rows to hold all the widgets*/
+        cols = num_sensors_per_group;
+        rows = num_active_sensors / num_sensors_per_group;
+        while (rows * cols < num_active_sensors || rows == 0) {
+            rows++;
+        }
+
+    }
+
+    /* if displaying labels / icons and values need to modify
+       number of rows / colums to accomodate this */
+     if (display_mode == DISPLAY_LABEL_WITH_VALUE || display_mode == DISPLAY_ICON_WITH_VALUE) {
+         if (layout_mode == VALUE_BESIDE_LABEL) {
+             /* to display labels next to values need twice as many columns */
+             cols *= 2;
+         } else {
+             /* to display labels above values, we need twice as many rows as without */
+             rows *= 2;
+         }
+     }
+
+    if (sensors_applet->grid == NULL) {
+        /* create grid and add to applet */
+        sensors_applet->grid = gtk_grid_new();
+        gtk_grid_set_column_spacing(GTK_GRID(sensors_applet->grid), COLUMN_SPACING);
+        gtk_grid_set_row_spacing(GTK_GRID(sensors_applet->grid), ROW_SPACING);
+        gtk_widget_set_halign(sensors_applet->grid, GTK_ALIGN_CENTER);
+        gtk_widget_set_valign(sensors_applet->grid, GTK_ALIGN_CENTER);
+        gtk_container_add(GTK_CONTAINER(sensors_applet->applet), sensors_applet->grid);
+    } else {
+        /* remove all children if grid already exists so we can start again */
+        /* save a list of the old children for later */
+        old_grid_children = gtk_container_get_children(GTK_CONTAINER(sensors_applet->grid));
+
+        gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid),
+                      sensors_applet_pack_display_empty_grid_cb,
+                      sensors_applet->grid);
+    }
+    /* pack icons / labels and values into grid */
+    current_sensor = sensors_applet->active_sensors;
+
+    /* if showing labels / icons and values, need to pack labels / icons these first */
+    if (display_mode == DISPLAY_ICON_WITH_VALUE || display_mode == DISPLAY_LABEL_WITH_VALUE) {
+        /* loop through columns */
+        for (i = 0; current_sensor != NULL && i < cols; /* increments depends on how we lay them out - see below */) {
+
+            /* loop through rows in a column */
+            for (j = 0; current_sensor && j < rows; /* see bottom of for loop*/) {
+                /* attach label / icon at this point */
+                if (display_mode == DISPLAY_ICON_WITH_VALUE) {
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->icon,
+                                        i, j, 1, 1);
+                    }
+                } else {
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->label,
+                                        i, j, 1, 1);
+                    }
+                }
+                /* now attach sensor value to either row below or column next to */
+                if (layout_mode == VALUE_BESIDE_LABEL) {
+                    /* left align labels */
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_START);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_label_set_xalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0);
+                        gtk_label_set_yalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_START);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                    }
+
+                     /* place value next to label */
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i + 1, j, 1, 1);
+                    }
+                    j++;
+                } else { /* place value below label */
+
+                    /* center align labels */
+                    if (((ActiveSensor *)(current_sensor->data))->icon) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->icon, GTK_ALIGN_CENTER);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->label) {
+                        gtk_label_set_xalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                        gtk_label_set_yalign (GTK_LABEL(((ActiveSensor *)(current_sensor->data))->label), 0.5);
+                    }
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_widget_set_halign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                        gtk_widget_set_valign (((ActiveSensor *)(current_sensor->data))->value, GTK_ALIGN_CENTER);
+                    }
+
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i, j + 1, 1, 1);
+                    }
+                    j += 2;
+                }
+                current_sensor = g_list_next(current_sensor);
+            } /* end row loop */
+
+            /* now increment column index as needed */
+            if (layout_mode == VALUE_BESIDE_LABEL) { /* place value next to label */
+                i += 2;
+            } else {
+                i++;
+            }
+        } /* end column loop    */
+
+    } else { /* not showing labels and icons with values, so just pack either only icons or values */
+        for (i = 0; current_sensor != NULL && i < cols; ++i) {
+            for (j = 0; current_sensor!= NULL && j < rows; ++j) {
+                if (display_mode == DISPLAY_VALUE) {
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->value,
+                                        i, j, 1, 1);
+                    }
+                } else if (display_mode == DISPLAY_ICON) {
+                    if (((ActiveSensor *)(current_sensor->data))->value) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->icon,
+                                        i, j, 1, 1);
+                    }
+                } else if (display_mode == DISPLAY_GRAPH) {
+                    if (((ActiveSensor *)(current_sensor->data))->graph) {
+                        gtk_grid_attach(GTK_GRID(sensors_applet->grid),
+                                        ((ActiveSensor *)(current_sensor->data))->graph_frame,
+                                        i, j, 1, 1);
+                    }
+                }
+
+                current_sensor = g_list_next(current_sensor);
+            }
+        }
+    }
+
+    if (old_grid_children != NULL) {
+        gtk_container_foreach(GTK_CONTAINER(sensors_applet->grid),
+                      sensors_applet_pack_display_cleanup_refs_cb,
+                      old_grid_children);
+        g_list_free(old_grid_children);
+    }
+    gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+
+}
+
+/* must unref when done with returned pixbuf */
+GdkPixbuf *sensors_applet_load_icon(IconType icon_type) {
+    GtkIconTheme *icon_theme;
+    GdkPixbuf *icon = NULL;
+    GError *error = NULL;
+
+    /* try to load the icon */
+
+    /* not allowed to unref or ref icon_theme once we have it */
+    icon_theme = gtk_icon_theme_get_default();
+    icon = gtk_icon_theme_load_icon(icon_theme,
+                                    stock_icons[icon_type],
+                                    DEFAULT_ICON_SIZE,
+                                    GTK_ICON_LOOKUP_USE_BUILTIN,
+                                    &error);
+
+    if (error) {
+        g_warning ("Could not load icon: %s", error->message);
+        g_error_free(error);
+        error = NULL;
+
+        /* try again with default icon */
+        icon = gtk_icon_theme_load_icon(icon_theme,
+                                        "image-missing",
+                                        DEFAULT_ICON_SIZE,
+                                        GTK_ICON_LOOKUP_USE_BUILTIN,
+                                        &error);
+
+        if (error) {
+            /* this will quit sensors-applet but it is a pretty major error so may as well */
+            g_error("Could not load GTK_STOCK_MISSING_IMAGE - major error!!!: %s", error->message);
+            g_error_free(error);
+            error = NULL;
+        }
+
+    }
+    return icon;
+}
+
+// MUST FREE STRINGS AFTER CALLING THIS FUNCTION!!
+gboolean sensors_applet_add_sensor(SensorsApplet *sensors_applet,
+                                   const gchar *path,
+                                   const gchar *id,
+                                   const gchar *label,
+                                   const gchar *interface,
+                                   SensorType type,
+                                   gboolean enable,
+                                   gdouble low_value,
+                                   gdouble high_value,
+                                   gboolean alarm_enable,
+                                   const gchar *low_alarm_command,
+                                   const gchar *high_alarm_command,
+                                   gint alarm_timeout,
+                                   gdouble multiplier,
+                                   gdouble offset,
+                                   IconType icon_type,
+                                   const gchar *graph_color) {
+
+    GtkTreeIter interfaces_iter, sensors_iter;
+    gboolean not_empty_tree;
+
+    gchar *node_interface;
+    gboolean not_end_of_interfaces = TRUE, interface_exists = FALSE;
+    gboolean not_end_of_sensors = TRUE;<--- Variable 'not_end_of_sensors' is assigned a value that is never used.
+    gchar *sensor_id;
+    gchar *sensor_path;
+    SensorType sensor_type;
+    GdkPixbuf *icon;
+    GtkTreePath *tree_path;
+
+    g_assert(sensors_applet);
+
+    /* assume tree is not empty */
+    not_empty_tree = TRUE;<--- not_empty_tree is assigned
+
+    if (NULL == sensors_applet->sensors) {
+
+        sensors_applet->sensors = gtk_tree_store_new(N_COLUMNS,
+                                 G_TYPE_STRING, /* path */
+                                 G_TYPE_STRING, /* id */
+                                 G_TYPE_STRING, /* label */
+                                 G_TYPE_STRING, /* interface */
+                                 G_TYPE_UINT, /* sensor type */
+                                 G_TYPE_BOOLEAN, /* enable */
+                                 G_TYPE_BOOLEAN, /* visible */
+                                 G_TYPE_DOUBLE, /* low value */
+                                 G_TYPE_DOUBLE, /* high type */
+                                 G_TYPE_BOOLEAN, /* alarm enable */
+                                 G_TYPE_STRING, /* low alarm command */
+                                 G_TYPE_STRING, /* high alarm command */
+                                 G_TYPE_UINT, /* alarm timeout */
+                                 G_TYPE_DOUBLE, /* multiplier */
+                                 G_TYPE_DOUBLE, /* offset */
+                                 G_TYPE_UINT, /* icon type */
+                                 GDK_TYPE_PIXBUF, /* icon pixbuf */
+                                 G_TYPE_STRING); /* graph color */
+
+        g_debug("Sensor tree created.");
+
+        /* we know tree is actually empty since we just created it */
+        not_empty_tree = FALSE;<--- not_empty_tree is assigned
+    }
+
+    /* search sensor tree for the parent interface to place this sensor under */
+    for (not_empty_tree = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter);<--- not_empty_tree is overwritten<--- not_empty_tree is overwritten
+        not_empty_tree && not_end_of_interfaces && !interface_exists;
+        not_end_of_interfaces = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter)) {
+
+        gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &interfaces_iter, INTERFACE_COLUMN, &node_interface, -1);
+        if (g_ascii_strcasecmp(interface, node_interface) == 0) {
+            /* found interface in tree */
+            interface_exists = TRUE;
+
+            /* now see if this actual sensor already exists within this interface - don't want to add duplicates */
+            /* see if have children */
+            for (not_end_of_sensors = gtk_tree_model_iter_children(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,  &interfaces_iter);
+                not_end_of_sensors;
+                not_end_of_sensors = gtk_tree_model_iter_next(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter)) {
+
+                gtk_tree_model_get(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter,
+                           PATH_COLUMN, &sensor_path,
+                           ID_COLUMN, &sensor_id,
+                           SENSOR_TYPE_COLUMN, &sensor_type,
+                           -1);
+                if (g_ascii_strcasecmp(sensor_id, id) == 0 && g_ascii_strcasecmp(sensor_path, path) == 0  && sensor_type == type) {
+                    /* sensor already exists so dont add a second time */
+                    g_debug("sensor with path: %s, id: %s already exists in tree, not adding a second time", sensor_path, sensor_id);
+                    g_free(sensor_id);
+                    g_free(sensor_path);
+                    g_free(node_interface);
+                    return FALSE;
+                }
+                g_free(sensor_id);
+                g_free(sensor_path);
+            }
+            g_free(node_interface);
+            break;
+        }
+        g_free(node_interface);
+    }
+
+    if (!interface_exists) {
+        /* add to required plugins hash table so we ensure this
+           plugin stays loaded to make sure we have a get sensor
+           value function if possible */
+        g_hash_table_insert(sensors_applet->required_plugins,
+                            g_strdup(interface),
+                            GINT_TO_POINTER(TRUE));
+        g_debug("added interface %s to required plugins", interface);
+
+        /* wasn't able to find interface root node so create it */
+        gtk_tree_store_append(sensors_applet->sensors,
+                      &interfaces_iter,
+                      NULL);
+
+        gtk_tree_store_set(sensors_applet->sensors,
+                   &interfaces_iter,
+                   ID_COLUMN, interface,
+                   INTERFACE_COLUMN, interface,
+                   VISIBLE_COLUMN, FALSE,
+                   -1);
+        g_debug("Added sensor interface %s to tree", interface);
+    }
+
+    /* then add sensor as a child under interface node - ie assume
+     * we either found it or created it - the inteface node that is */
+
+    /* for now just add sensors all in a single list */
+    gtk_tree_store_append(sensors_applet->sensors, &sensors_iter, &interfaces_iter);
+
+    /* if sensor is already in settings, load values from there */
+    gchar *applet_path = mate_panel_applet_get_preferences_path (sensors_applet->applet);
+    gchar *gsuid = sensors_applet_settings_get_unique_id (interface, id, path);
+    gchar *settings_path = g_strdup_printf ("%s%s/", applet_path, gsuid);
+    GSettings *settings = g_settings_new_with_path ("org.mate.sensors-applet.sensor", settings_path);
+
+    /* add hash to temp sorting list */
+    g_variant_builder_add (&gvb_sensors_hash_list, "s", gsuid);
+
+    g_free (applet_path);
+    g_free (gsuid);
+    g_free (settings_path);
+
+    gchar *settings_id = g_settings_get_string (settings, ID);
+
+    if (settings_id != NULL && settings_id[0] != '\0') {
+        enable = g_settings_get_boolean (settings, ENABLED);
+        icon = sensors_applet_load_icon(g_settings_get_int (settings, ICON_TYPE));
+        gtk_tree_store_set(sensors_applet->sensors,
+                           &sensors_iter,
+                           PATH_COLUMN, g_settings_get_string (settings, PATH),
+                           ID_COLUMN, settings_id,
+                           LABEL_COLUMN, g_settings_get_string (settings, LABEL),
+                           INTERFACE_COLUMN, g_settings_get_string (settings, INTERFACE),
+                           SENSOR_TYPE_COLUMN, g_settings_get_int (settings, SENSOR_TYPE),
+                           ENABLE_COLUMN, enable,
+                           VISIBLE_COLUMN, TRUE,
+                           LOW_VALUE_COLUMN, g_settings_get_double (settings, LOW_VALUE),
+                           HIGH_VALUE_COLUMN, g_settings_get_double (settings, HIGH_VALUE),
+                           ALARM_ENABLE_COLUMN, g_settings_get_boolean (settings, ALARM_ENABLED),
+                           ALARM_TIMEOUT_COLUMN, g_settings_get_int (settings, ALARM_TIMEOUT),
+                           LOW_ALARM_COMMAND_COLUMN, g_settings_get_string (settings, LOW_ALARM_COMMAND),
+                           HIGH_ALARM_COMMAND_COLUMN, g_settings_get_string (settings, HIGH_ALARM_COMMAND),
+                           MULTIPLIER_COLUMN, g_settings_get_double (settings, MULTIPLIER),
+                           OFFSET_COLUMN, g_settings_get_double (settings, OFFSET),
+                           ICON_TYPE_COLUMN, g_settings_get_int (settings, ICON_TYPE),
+                           ICON_PIXBUF_COLUMN, icon,
+                           GRAPH_COLOR_COLUMN, g_settings_get_string (settings, GRAPH_COLOR),
+                           -1);
+        g_free (settings_id);
+    } else {
+        icon = sensors_applet_load_icon(icon_type);
+        gtk_tree_store_set(sensors_applet->sensors,
+                           &sensors_iter,
+                           PATH_COLUMN, path,
+                           ID_COLUMN, id,
+                           LABEL_COLUMN, label,
+                           INTERFACE_COLUMN, interface,
+                           SENSOR_TYPE_COLUMN, type,
+                           ENABLE_COLUMN, enable,
+                           VISIBLE_COLUMN, TRUE,
+                           LOW_VALUE_COLUMN, low_value,
+                           HIGH_VALUE_COLUMN, high_value,
+                           ALARM_ENABLE_COLUMN, alarm_enable,
+                           ALARM_TIMEOUT_COLUMN, alarm_timeout,
+                           LOW_ALARM_COMMAND_COLUMN, low_alarm_command,
+                           HIGH_ALARM_COMMAND_COLUMN, high_alarm_command,
+                           MULTIPLIER_COLUMN, multiplier,
+                           OFFSET_COLUMN, offset,
+                           ICON_TYPE_COLUMN, icon_type,
+                           ICON_PIXBUF_COLUMN, icon,
+                           GRAPH_COLOR_COLUMN, graph_color,
+                           -1);
+    }
+    g_object_unref (settings);
+    g_debug("added sensor %s to tree", path);
+
+    /* remove reference to icon as tree now has ref */
+    g_object_unref(icon);
+
+    /* create the active sensor */
+    if (enable) {
+        tree_path = gtk_tree_model_get_path(GTK_TREE_MODEL(sensors_applet->sensors), &sensors_iter);
+        sensors_applet_sensor_enabled(sensors_applet, tree_path);
+        gtk_tree_path_free(tree_path);
+    }
+    return TRUE;
+}
+
+static ActiveSensor *sensors_applet_find_active_sensor(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    GtkTreePath *sensor_tree_path;
+    GList *current_sensor;
+
+    for (current_sensor = sensors_applet->active_sensors; current_sensor != NULL; current_sensor = g_list_next(current_sensor)) {
+        sensor_tree_path = gtk_tree_row_reference_get_path(((ActiveSensor *)(current_sensor->data))->sensor_row);
+
+        if (gtk_tree_path_compare(path, sensor_tree_path) == 0) {
+            gtk_tree_path_free(sensor_tree_path);
+            return ((ActiveSensor *)(current_sensor->data));
+        }
+        gtk_tree_path_free(sensor_tree_path);
+    }
+    return NULL;
+}
+
+/* path should be the full path to a file representing the sensor (eg
+ * /dev/hda or /sys/devices/platform/i2c-0/0-0290/temp1_input) */
+void sensors_applet_display_layout_changed(SensorsApplet *sensors_applet) {
+    /* update sensors since will need to update icons / graphs etc
+     * if weren't displayed before */
+    GList *list = NULL;
+    for (list = sensors_applet->active_sensors; list != NULL; list = list->next) {
+        ActiveSensor *as = (ActiveSensor *)list->data;
+        as->updated = FALSE;
+    }
+    sensors_applet_update_active_sensors(sensors_applet);
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_alarm_off(SensorsApplet *sensors_applet,
+                              GtkTreePath *path,
+                              NotifType notif_type) {
+    ActiveSensor *active_sensor;
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_alarm_off(active_sensor, notif_type);
+    }
+}
+
+void sensors_applet_all_alarms_off(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    sensors_applet_alarm_off(sensors_applet, path, LOW_ALARM);
+    sensors_applet_alarm_off(sensors_applet, path, HIGH_ALARM);
+}
+
+void sensors_applet_sensor_enabled(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    active_sensor = active_sensor_new(sensors_applet, gtk_tree_row_reference_new(GTK_TREE_MODEL(sensors_applet->sensors), path));
+    active_sensor_update(active_sensor, sensors_applet);
+
+    /* keep list sorted */
+    sensors_applet->active_sensors = g_list_insert_sorted(sensors_applet->active_sensors,
+                                                              active_sensor,
+                                                              (GCompareFunc)active_sensor_compare);
+
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_reorder_sensors(SensorsApplet *sensors_applet) {
+    sensors_applet->active_sensors = g_list_sort(sensors_applet->active_sensors, (GCompareFunc)active_sensor_compare);
+
+    sensors_applet_pack_display(sensors_applet);
+}
+
+void sensors_applet_sensor_disabled(SensorsApplet *sensors_applet, GtkTreePath *path) {
+
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        g_debug("Destroying active sensor...");
+
+        g_debug("-- removing from list...");
+        sensors_applet->active_sensors = g_list_remove(sensors_applet->active_sensors, active_sensor);
+        g_debug("-- repacking display....");
+        sensors_applet_pack_display(sensors_applet);
+
+        active_sensor_destroy(active_sensor);
+    }
+}
+
+void sensors_applet_update_sensor(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_update(active_sensor, sensors_applet);
+    }
+}
+
+void sensors_applet_icon_changed(SensorsApplet *sensors_applet, GtkTreePath *path) {
+    ActiveSensor *active_sensor;
+
+    g_assert(sensors_applet);
+    g_assert(path);
+
+    if ((active_sensor = sensors_applet_find_active_sensor(sensors_applet, path)) != NULL) {
+        active_sensor_icon_changed(active_sensor, sensors_applet);
+    }
+}
+
+/* Cycle thru ActiveSensors and update them all */
+gboolean sensors_applet_update_active_sensors(SensorsApplet *sensors_applet) {
+    g_assert(sensors_applet);
+
+    if (sensors_applet->active_sensors) {
+        g_list_foreach(sensors_applet->active_sensors,
+                       (GFunc)active_sensor_update,
+                       sensors_applet);
+        return TRUE;
+    }
+    return FALSE;
+}
+
+/* Cycle thru ActiveSensors and set new graph dimensions */
+void sensors_applet_graph_size_changed(SensorsApplet *sensors_applet) {
+    gint dimensions[2];
+    gint graph_size;
+    g_assert(sensors_applet);
+
+    if (sensors_applet->active_sensors) {
+
+        graph_size = g_settings_get_int (sensors_applet->settings, GRAPH_SIZE);
+        if (mate_panel_applet_get_orient(sensors_applet->applet) ==  MATE_PANEL_APPLET_ORIENT_UP ||
+            mate_panel_applet_get_orient(sensors_applet->applet) == MATE_PANEL_APPLET_ORIENT_DOWN) {
+
+            /* is horizontal so set graph_size as width */
+            dimensions[0] = graph_size;
+            dimensions[1] = sensors_applet->size;
+        } else {
+            dimensions[0] = sensors_applet->size;
+            dimensions[1] = graph_size;
+        }
+
+        g_list_foreach(sensors_applet->active_sensors,
+                       (GFunc)active_sensor_update_graph_dimensions,
+                       &dimensions);
+    }
+
+}
+
+gdouble sensors_applet_convert_temperature(gdouble value, TemperatureScale old, TemperatureScale new) {
+
+    switch (old) {
+        case KELVIN:
+            switch (new) {
+                case CELSIUS:
+                    value = value - 273.0;
+                    break;
+                case FAHRENHEIT:
+                    value = (9.0 * (value - 273) / 5.0) + 32.0;
+                    break;
+                case KELVIN:
+                    break;
+            }
+            break;
+
+        case CELSIUS:
+            switch (new) {
+                case FAHRENHEIT:
+                    value = (9.0 * value / 5.0) + 32.0;
+                    break;
+                case KELVIN:
+                    value = value + 273.0;
+                    break;
+                case CELSIUS:
+                    break;
+            }
+            break;
+
+        case FAHRENHEIT:
+            switch (new) {
+            case CELSIUS:
+                value = (5.0 * (value - 32.0) / 9.0);
+                break;
+            case KELVIN:
+                value = (5.0 * (value - 32.0) / 9.0) + 273.0;
+                break;
+            case FAHRENHEIT:
+                break;
+            }
+            break;
+    }
+    return value;
+}
+
+void sensors_applet_init(SensorsApplet *sensors_applet) {
+
+    g_assert(sensors_applet);
+    g_assert(sensors_applet->applet);
+
+    GtkActionGroup *action_group;
+    gchar *ui_path;
+
+    /* Have our background automatically painted. */
+    mate_panel_applet_set_background_widget(MATE_PANEL_APPLET(sensors_applet->applet), GTK_WIDGET(sensors_applet->applet));
+
+    /* plugin functions are stored as name -> get_value_function pairs so
+     * use standard string functions on hash table */
+    sensors_applet->plugins = g_hash_table_new(g_str_hash, g_str_equal);
+
+    sensors_applet->required_plugins = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, NULL);
+
+    /* initialise size */
+    sensors_applet->size = DEFAULT_APPLET_SIZE;
+
+    mate_panel_applet_set_flags(sensors_applet->applet, MATE_PANEL_APPLET_EXPAND_MINOR);
+
+    g_signal_connect(sensors_applet->applet, "destroy",
+             G_CALLBACK(destroy_cb),
+             sensors_applet);
+
+    /* init gsettings */
+    sensors_applet->settings = mate_panel_applet_settings_new (sensors_applet->applet, "org.mate.sensors-applet");
+
+    /* set up builder for sorting verification */
+    g_variant_builder_init (&gvb_sensors_hash_list, G_VARIANT_TYPE ("as"));
+
+    /* set up / load sensors from the plugins */
+    sensors_applet_plugins_load_all(sensors_applet);
+
+    /* set sorting hash array */
+    GVariant *gv_temp = g_variant_builder_end (&gvb_sensors_hash_list);
+    sensors_applet->sensors_hash_array = g_variant_dup_strv (gv_temp, NULL);
+    g_variant_unref (gv_temp);
+
+    /* sort sensors based on saved sorting */
+    sensors_applet_settings_sort_sensors(sensors_applet);
+
+    /* free hash array */
+    g_strfreev (sensors_applet->sensors_hash_array);
+
+    /* should have created sensors tree above, but if have not was because we couldn't find any sensors */
+    if (NULL == sensors_applet->sensors) {
+        GtkWidget *label;
+        label = gtk_label_new(_("No sensors found!"));
+        gtk_container_add(GTK_CONTAINER(sensors_applet->applet), label);
+        gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+        return;
+    }
+
+    /* only do menu and signal connections if sensors are found */
+    action_group = gtk_action_group_new ("Sensors Applet Actions");
+    gtk_action_group_set_translation_domain (action_group, GETTEXT_PACKAGE);
+    gtk_action_group_add_actions (action_group,
+                                sensors_applet_menu_actions,
+                                G_N_ELEMENTS (sensors_applet_menu_actions),
+                                sensors_applet);
+    ui_path = g_build_filename (UIDIR, SENSORS_APPLET_MENU_FILE, NULL);
+    mate_panel_applet_setup_menu_from_file (sensors_applet->applet, ui_path, action_group);
+    g_free (ui_path);
+    g_object_unref (action_group);
+
+    g_signal_connect(sensors_applet->applet, "style-set",
+                     G_CALLBACK(style_set_cb),
+                     sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "change_orient",
+                      G_CALLBACK(change_orient_cb),
+                      sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "size_allocate",
+                      G_CALLBACK(size_allocate_cb),<--- You might need to cast the function pointer here
+                      sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "leave_notify_event",
+                     G_CALLBACK(mouse_leave_cb),
+                     (gpointer)sensors_applet);
+
+    g_signal_connect(G_OBJECT(sensors_applet->applet), "enter_notify_event",
+                     G_CALLBACK(mouse_enter_cb),
+                     (gpointer)sensors_applet);
+
+    sensors_applet_update_active_sensors(sensors_applet);
+    sensors_applet_pack_display(sensors_applet);
+
+    sensors_applet->timeout_id = g_timeout_add_seconds(g_settings_get_int(sensors_applet->settings, TIMEOUT) / 1000,
+                                                           (GSourceFunc)sensors_applet_update_active_sensors,
+                                                           sensors_applet);
+    gtk_widget_show_all(GTK_WIDGET(sensors_applet->applet));
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/5.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/5.html new file mode 100644 index 0000000..24ba1b4 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/5.html @@ -0,0 +1,731 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif /* HAVE_CONFIG_H */
+
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_ARPA_INET_H
+#include <arpa/inet.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#ifdef HAVE_STRING_H
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "hddtemp-plugin.h"
+
+const gchar *plugin_name = "hddtemp";
+
+#define HDDTEMP_SERVER_IP_ADDRESS "127.0.0.1"
+#define HDDTEMP_PORT_NUMBER 7634
+#define HDDTEMP_OUTPUT_BUFFER_LENGTH 1024
+
+enum {
+    HDDTEMP_SOCKET_OPEN_ERROR,
+    HDDTEMP_SOCKET_CONNECT_ERROR,
+    HDDTEMP_GIOCHANNEL_ERROR,
+    HDDTEMP_GIOCHANNEL_READ_ERROR
+};
+
+static gchar buffer[HDDTEMP_OUTPUT_BUFFER_LENGTH];
+
+static const gchar *hddtemp_plugin_query_hddtemp_daemon(GError **error) {
+    guint output_length = 0;
+    static gboolean first_run = TRUE;
+
+    struct sockaddr_in address;
+    static gint64 previous_query_time;
+    gint64 current_query_time;
+
+    if (first_run) {
+        // initialise previous time
+        previous_query_time = g_get_monotonic_time ();
+    }
+    current_query_time = g_get_monotonic_time ();
+
+    /* only actually query if more than 60 seconds has elapsed as
+    hddtemp daemon will only actually send a new value if is > 60
+    seconds */
+    if (first_run || current_query_time - previous_query_time > G_TIME_SPAN_MINUTE) {
+        int sockfd;
+        ssize_t n;
+        gchar *pc;
+
+        previous_query_time = current_query_time;
+
+        if ((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {
+            // couldn't open socket
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, HDDTEMP_SOCKET_OPEN_ERROR, "Error opening socket for hddtemp");
+            return NULL;
+        }
+
+        address.sin_family = AF_INET;
+        address.sin_addr.s_addr = inet_addr(HDDTEMP_SERVER_IP_ADDRESS);
+        address.sin_port = htons(HDDTEMP_PORT_NUMBER);
+
+        if (connect(sockfd, (struct sockaddr *)&address, (socklen_t)sizeof(address)) == -1) {
+            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, HDDTEMP_SOCKET_CONNECT_ERROR, "Error connecting to hddtemp daemon on port %i on %s", htons(HDDTEMP_PORT_NUMBER), HDDTEMP_SERVER_IP_ADDRESS);
+            close(sockfd);
+            return NULL;
+        }
+        memset(buffer, 0, sizeof(buffer));
+        pc = buffer;
+        while ((n = read(sockfd, pc, sizeof(buffer) - output_length)) > 0) {
+            output_length += n;
+            pc += n;
+        }
+        /* always null terminate the end of the buffer */
+        buffer[MIN(output_length, sizeof(buffer) - 1)] = '\0';
+        close(sockfd);
+        first_run = FALSE;
+    }
+
+    return buffer;
+}
+
+static void hddtemp_plugin_get_sensors(GList **sensors) {
+    GError *error = NULL;
+    const gchar *hddtemp_output;
+    gchar **output_vector = NULL, **pv;
+
+    hddtemp_output = hddtemp_plugin_query_hddtemp_daemon(&error);
+
+    if (error) {
+        g_error_free(error);
+        return;
+    }
+
+    if (hddtemp_output[0] != '|') {
+        g_debug("Error in format of string returned from hddtemp daemon: char at [0] should be \"|\", instead whole output is: \"%s\"", hddtemp_output);
+        return;
+    }
+
+    /* for each sensor the output will contain four strings ie
+       |/dev/hda|WDC WD800JB-00ETA0|32|C||/dev/hdb|???|ERR|*|
+       note the repetition -----^ */
+
+    /*
+      pv[0 + 5*n] empty
+      pv[1 + 5*n] device name
+      pv[2 + 5*n] disk label
+      pv[3 + 5*n] temperature
+      pv[4 + 5*n] unit
+      pv[5 + 5*n] empty
+    */
+
+    pv = output_vector = g_strsplit(hddtemp_output, "|", -1);
+
+    while(pv[1] != NULL) {
+        if (g_strcmp0(pv[2], "") != 0 &&
+            g_strcmp0(pv[3], "") != 0 &&
+            g_strcmp0(pv[4], "") != 0 &&
+            (!(g_ascii_strcasecmp(pv[2], "???") == 0 ||
+               g_ascii_strcasecmp(pv[3], "ERR") == 0 ||
+               g_ascii_strcasecmp(pv[4], "*") == 0))) {
+
+            sensors_applet_plugin_add_sensor(sensors,
+                                            pv[1], // must be dynamically allocated
+                                            pv[1], // must be dynamically allocated
+                                            pv[2], // must be dynamically allocated
+                                            TEMP_SENSOR,
+                                            FALSE,
+                                            HDD_ICON,
+                                            DEFAULT_GRAPH_COLOR);
+        }
+        pv += 5;
+    }
+    g_strfreev(output_vector);
+}
+
+/* to be called to setup for hddtemp sensors */
+static GList *hddtemp_plugin_init(void) {
+    GList *sensors = NULL;
+    hddtemp_plugin_get_sensors(&sensors);
+    return sensors;
+}
+
+/* returns the value of the sensor_list at the given iter, or if an
+   error occurs, instatiates error with an error message */
+static gdouble hddtemp_plugin_get_sensor_value(const gchar *path,
+                                              const gchar *id,
+                                              SensorType type,
+                                              GError **error) {
+
+    const gchar *hddtemp_output;
+    gchar **output_vector = NULL, **pv;
+
+    gfloat sensor_value = -1.0f;
+
+    hddtemp_output = hddtemp_plugin_query_hddtemp_daemon(error);
+
+    if (*error) {
+        return sensor_value;
+    }
+
+    if (hddtemp_output[0] != '|') {
+        g_debug("Error in format of string returned from hddtemp daemon: char at [0] should be \"|\", instead whole output is: \"%s\"", hddtemp_output);
+        return sensor_value;
+    }
+
+    /* for each sensor the output will contain four strings ie
+       |/dev/hda|WDC WD800JB-00ETA0|32|C||/dev/hdb|???|ERR|*|
+                note the repetition -----^
+
+      pv[0 + 5*n] empty
+      pv[1 + 5*n] device name
+      pv[2 + 5*n] disk label
+      pv[3 + 5*n] temperature
+      pv[4 + 5*n] unit
+      pv[5 + 5*n] empty
+    */
+
+    pv = output_vector = g_strsplit(hddtemp_output, "|", -1);
+
+    while(pv[1] != NULL) {
+        if (g_ascii_strcasecmp(pv[1], path) == 0) {
+            sensor_value = (gfloat)(g_ascii_strtod(pv[3], NULL));
+
+            /* always return sensor values in celsius */
+            if (pv[4][0] == 'F') {
+                sensor_value = (sensor_value - 32.0) * 5.0 / 9.0;
+            }
+            break;
+        }
+        pv += 5;
+    }
+    g_strfreev(output_vector);
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return hddtemp_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+    return hddtemp_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/6.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/6.html new file mode 100644 index 0000000..85db32a --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/6.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef HDDTEMP_PLUGIN_H
+#define HDDTEMP_PLUGIN_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* HDDTEMP_PLUGIN_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/7.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/7.html new file mode 100644 index 0000000..df97246 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/7.html @@ -0,0 +1,685 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <locale.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "i2c-proc-plugin.h"
+
+const gchar *plugin_name = "i2c-proc";
+
+#define I2C_PROC_BASE_DIR "/proc/sys/dev/sensors"
+
+enum {
+    I2C_PROC_DEVICE_FILE_OPEN_ERROR,
+    I2C_PROC_DEVICE_FILE_READ_ERROR
+};
+
+static void i2c_proc_plugin_add_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    gchar *label;
+    gboolean enable;
+    SensorType sensor_type;
+    IconType icon_type = GENERIC_ICON;
+
+    filename = g_path_get_basename(path);
+
+    /* setup temp2 as CPU sensor and enable it */
+    if (g_ascii_strcasecmp(filename, "temp2") == 0) {
+        sensor_type = TEMP_SENSOR;
+        label = g_strdup(_("CPU"));
+        enable = TRUE;
+        icon_type = CPU_ICON;
+    } else {
+        label = g_strdup(filename);
+
+        switch(filename[0]) {
+        case 'c':     /* currents are "curr?" */
+            sensor_type = CURRENT_SENSOR;
+            break;
+        case 'f':     /* fans are "fan?" */
+            sensor_type = FAN_SENSOR;
+            icon_type = FAN_ICON;
+            break;
+        case 'i':     /* voltages are "in?" */
+            sensor_type = VOLTAGE_SENSOR;
+            break;
+        case 't':     /* temps are "temp?" */
+            sensor_type = TEMP_SENSOR;
+            break;
+        case 'v':     /* vids are just vid */
+            sensor_type = VOLTAGE_SENSOR;
+            break;
+        default:
+            /* SHOULDN'T BE ABLE TO GET HERE!! */
+            g_debug("error in i2c-proc sensor detection code - unhandled sensor filename %s", filename);
+            g_free(filename);
+            g_free(label);
+            return;
+        }
+        /* disable all other sensors */
+        enable = FALSE;
+    }
+
+    sensors_applet_plugin_add_sensor(sensors,
+                                         path,
+                                         filename,
+                                         label,
+                                         sensor_type,
+                                         enable,
+                                         icon_type,
+                                         DEFAULT_GRAPH_COLOR);
+
+    g_free(filename);
+    g_free(label);
+}
+
+static void i2c_proc_plugin_test_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+
+    filename = g_path_get_basename(path);
+    /* see if filename starts with any of the sensor prefixes */
+    if (g_str_has_prefix(filename, "curr") ||
+        (g_str_has_prefix(filename, "fan") &&
+        !g_str_has_prefix(filename, "fan_div")) ||
+        g_str_has_prefix(filename, "in") ||
+        g_str_has_prefix(filename, "temp") ||
+        g_str_has_prefix(filename, "vid")) {
+
+        i2c_proc_plugin_add_sensor(sensors, path);
+    }
+    g_free(filename);
+
+}
+
+/* to be called to setup for proc sensors */
+static GList *i2c_proc_plugin_init(void) {
+    GList *sensors = NULL;
+
+    /* call function to recursively look for sensors
+    starting at the defined base directory */
+    sensors_applet_plugin_find_sensors(&sensors, I2C_PROC_BASE_DIR, i2c_proc_plugin_test_sensor);
+    return sensors;
+}
+
+static gdouble i2c_proc_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat float1, float2, float3;
+    gint int1, int2;
+
+    gfloat sensor_value = -1.0;
+
+    gchar *old_locale = NULL;<--- Variable 'old_locale' can be declared as pointer to const
+
+        /* always use C locale */
+    if (NULL == (old_locale = setlocale(LC_NUMERIC, "C"))) {
+        g_warning("Could not change locale to C locale for reading i2c-proc device files.. will try regardless");
+    }
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+    } else {
+        switch (type) {
+            case CURRENT_SENSOR:
+                if (fscanf(fp, "%f %f %f", &float1, &float2, &float3) != 3) {
+                    g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                } else {
+                    sensor_value = float3;
+                }
+                break;
+
+            case FAN_SENSOR:
+                if (fscanf(fp, "%d %d", &int1, &int2) != 2) {
+                    g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                } else {
+                    sensor_value = (gfloat)int2;
+                }
+                break;
+
+            case VOLTAGE_SENSOR:
+                /* is it CPU_VID or IN */
+                switch(id[0]) {
+                    case 'i':
+                        if (fscanf(fp, "%f %f %f", &float1, &float2, &float3) != 3) {
+                            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                        } else {
+                            sensor_value = float3;
+                        }
+                        break;
+
+                    case 'v':
+                        /* want first value in file as float */
+                        if (fscanf(fp, "%f", &float1) != 1) {
+                            g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                        } else {
+                            sensor_value = float1;
+                        }
+                        break;
+                    default:
+                        g_debug("error in i2c-proc sensor read value function code - unhandled sensor id %s", id);
+                        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                }
+                break;
+
+            case TEMP_SENSOR:
+                if (fscanf(fp, "%f %f %f", &float1, &float2, &float3) != 3) {
+                    g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_PROC_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+                } else {
+                    sensor_value = float3;
+                }
+                break;
+        } /* end switch */
+        fclose(fp);
+    }
+
+    if (NULL != old_locale) {
+        setlocale(LC_NUMERIC, old_locale);
+    }
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return i2c_proc_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return i2c_proc_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/8.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/8.html new file mode 100644 index 0000000..2328fd8 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/8.html @@ -0,0 +1,287 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifndef SENSORS_LIST_I2C_PROC_H
+#define SENSORS_LIST_I2C_PROC_H
+
+#include <sensors-applet/sensors-applet-plugin.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#endif /* SENSORS_LIST_I2C_PROC_H */
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/9.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/9.html new file mode 100644 index 0000000..2292626 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/9.html @@ -0,0 +1,615 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
/*
+ * Copyright (C) 2005-2009 Alex Murray <murray.alex@gmail.com>
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif /* HAVE_CONFIG_H */
+
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include "i2c-sys-plugin.h"
+
+const gchar *plugin_name = "i2c-sys";
+
+#define I2C_SYS_BASE_DIR "/sys"
+
+enum {
+    I2C_SYS_DEVICE_FILE_OPEN_ERROR,
+    I2C_SYS_DEVICE_FILE_READ_ERROR
+};
+
+static void i2c_sys_plugin_add_sensor(GList **sensors, const gchar *path) {
+    gchar *filename;
+    gchar *id;
+    gchar *label;
+    gboolean enable;
+    guint sensor_type;
+    IconType icon_type = GENERIC_ICON;
+
+    filename = g_path_get_basename(path);
+
+    /* setup temp2 as CPU sensor and enable it */
+    if (g_ascii_strcasecmp(filename, "temp2_input") == 0) {
+        id = g_strndup(filename, 5);
+        label = g_strdup(_("CPU"));
+        sensor_type = TEMP_SENSOR;
+        enable = TRUE;
+        icon_type = CPU_ICON;
+    } else {
+        switch(filename[0]) {
+            case 'c':    /* either current or cpu?_vid sensor */
+                if (filename[1] == 'u') { /* currents are curr?_input */
+                    id = g_strndup(filename, 5);
+                    label = g_strndup(filename, 5);
+                    sensor_type = CURRENT_SENSOR;
+                } else { /* cpu_vid is cpu?_vid */
+                    id = g_strdup(filename);
+                    label = g_strdup(filename);
+                    sensor_type = VOLTAGE_SENSOR;
+                }
+                break;
+
+            case 'f':    /* fans are "fan?_input" */
+                id = g_strndup(filename, 4);
+                label = g_strndup(filename, 4);
+                sensor_type = FAN_SENSOR;
+                icon_type = FAN_ICON;
+                break;
+
+            case 't':    /* temps are "temp?_input" */
+                id = g_strndup(filename, 5);
+                label = g_strndup(filename, 5);
+                sensor_type = TEMP_SENSOR;
+                break;
+
+            case 'i':    /* voltages are "in?_input" */
+                id = g_strndup(filename, 3);
+                label = g_strndup(filename, 3);
+                sensor_type = VOLTAGE_SENSOR;
+                break;
+
+            default:
+                /* SHOULDN'T BE ABLE * TO GET HERE!! */
+                g_warning("filename:\"%s\" begins with a charater that is not covered by this switch statement... not adding sensor", filename);
+                g_free(filename);
+
+                return;
+        }
+
+        /* disable all other sensors */
+        enable = FALSE;
+    }
+
+    sensors_applet_plugin_add_sensor(sensors,
+                                         path,
+                                         id,
+                                         label,
+                                         sensor_type,
+                                         enable,
+                                         icon_type,
+                                         DEFAULT_GRAPH_COLOR);
+
+    g_free(filename);
+    g_free(id);
+    g_free(label);
+}
+
+static void i2c_sys_plugin_test_sensor(GList **sensors, const gchar *path) {
+gchar *filename;
+
+filename = g_path_get_basename(path);
+
+if ((g_str_has_suffix(filename, "_input") &&
+    (g_str_has_prefix(filename, "temp") ||
+    g_str_has_prefix(filename, "fan") ||
+    g_str_has_prefix(filename, "curr") ||
+    g_str_has_prefix(filename, "in"))) ||
+    (g_str_has_prefix(filename, "cpu") &&
+    (g_str_has_suffix(filename, "_vid")))) {
+
+    i2c_sys_plugin_add_sensor(sensors, path);
+}
+
+    g_free(filename);
+}
+
+/* to be called to setup for sys sensors */
+static GList *i2c_sys_plugin_init(void) {
+    GList *sensors = NULL;
+
+    /* call function to recursively look for sensors
+       starting at the defined base directory */
+    sensors_applet_plugin_find_sensors(&sensors,
+                                       I2C_SYS_BASE_DIR,
+                                       i2c_sys_plugin_test_sensor);
+    return sensors;
+}
+
+static gdouble i2c_sys_plugin_get_sensor_value(const gchar *path,
+                                               const gchar *id,
+                                               SensorType type,
+                                               GError **error) {
+
+    /* to open and access the value of each sensor */
+    FILE *fp;
+    gfloat sensor_value;
+
+    if (NULL == (fp = fopen(path, "r"))) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_SYS_DEVICE_FILE_OPEN_ERROR, "Error opening sensor device file %s", path);
+        return -1.0;
+    }
+
+    if (fscanf(fp, "%f", &sensor_value) != 1) {
+        g_set_error(error, SENSORS_APPLET_PLUGIN_ERROR, I2C_SYS_DEVICE_FILE_READ_ERROR, "Error reading from sensor device file %s", path);
+        fclose(fp);
+        return -1.0;
+    }
+    fclose(fp);
+
+    if (type != FAN_SENSOR) {
+        sensor_value /= 1000.0;
+    }
+
+    return (gdouble)sensor_value;
+}
+
+const gchar *sensors_applet_plugin_name(void)
+{
+    return plugin_name;
+}
+
+GList *sensors_applet_plugin_init(void)
+{
+    return i2c_sys_plugin_init();
+}
+
+gdouble sensors_applet_plugin_get_sensor_value(const gchar *path,
+                                                const gchar *id,
+                                                SensorType type,
+                                                GError **error) {
+
+    return i2c_sys_plugin_get_sensor_value(path, id, type, error);
+}
+
+ +
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/index.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/index.html new file mode 100644 index 0000000..b80be85 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/index.html @@ -0,0 +1,445 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
lib/sensors-applet-plugin.c
20missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
23missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/acpi/acpi-plugin.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/acpi/acpi-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/dummy/dummy-plugin.c
24missingIncludeinformationInclude file: "config.h" not found.
27missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <syslog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/dummy/dummy-plugin.h
24missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/hddtemp/hddtemp-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
44missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
45missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/hddtemp/hddtemp-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/i2c-proc/i2c-proc-plugin.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <locale.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
138constVariablePointer398styleVariable 'old_locale' can be declared as pointer to const
plugins/i2c-proc/i2c-proc-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/i2c-sys/i2c-sys-plugin.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/i2c-sys/i2c-sys-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/i8k/i8k-plugin.c
21missingIncludeSysteminformationInclude file: <config.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/i8k/i8k-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/ibm-acpi/ibm-acpi-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/ibm-acpi/ibm-acpi-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/libsensors/libsensors-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <sensors/sensors.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
176constVariablePointer398styleVariable 'sensor_info' can be declared as pointer to const
176unreadVariable563styleVariable 'sensor_info' is assigned a value that is never used.
plugins/libsensors/libsensors-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/mbmon/mbmon-plugin.c
22missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/socket.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <netinet/in.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <arpa/inet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
41missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/mbmon/mbmon-plugin.h
24missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/netbsd/netbsd-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <prop/proplib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <sys/envsys.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/netbsd/netbsd-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/nvidia/nvidia-plugin.c
22missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <X11/Xlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <NVCtrl/NVCtrl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <NVCtrl/NVCtrlLib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/nvidia/nvidia-plugin.h
24missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/omnibook/omnibook-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/omnibook/omnibook-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/pmu-sys/pmu-sys-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/pmu-sys/pmu-sys-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/smu-sys/smu-sys-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
24missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/smu-sys/smu-sys-plugin.h
23missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/sonypi/sonypi-plugin.c
21missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/ioctl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
37missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
40missingIncludeSysteminformationInclude file: <stdint.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/sonypi/sonypi-plugin.h
24missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/udisks2/udisks2-plugin.c
35missingIncludeinformationInclude file: "config.h" not found.
38missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
46missingIncludeSysteminformationInclude file: <syslog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
plugins/udisks2/udisks2-plugin.h
24missingIncludeSysteminformationInclude file: <sensors-applet/sensors-applet-plugin.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/about-dialog.c
24missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/active-sensor-libnotify.c
25missingIncludeSysteminformationInclude file: <libnotify/notify.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30constParameterCallback398styleParameter 'notification' can be declared as pointer to const. However it seems that 'notif_closed_cb' is a callback function, if 'notification' is declared with const you might also need to cast function pointer(s).
sensors-applet/active-sensor.c
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
511variableScope398styleThe scope of the variable 'scale' can be reduced.
512variableScope398styleThe scope of the variable 'display_mode' can be reduced.
sensors-applet/active-sensor.h
24missingIncludeSysteminformationInclude file: <time.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <libnotify/notify.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/main.c
24missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/prefs-dialog.c
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
25missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/sensor-config-dialog.c
24missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38unusedStructMember563stylestruct member 'SensorConfigDialog::icon_type_combo_box_aligner' is never used.
43unusedStructMember563stylestruct member 'SensorConfigDialog::graph_color_button_aligner' is never used.
48unusedStructMember563stylestruct member 'SensorConfigDialog::multiplier_spinbutton_aligner' is never used.
48unusedStructMember563stylestruct member 'SensorConfigDialog::offset_spinbutton_aligner' is never used.
54unusedStructMember563stylestruct member 'SensorConfigDialog::low_value_spinbutton_aligner' is never used.
54unusedStructMember563stylestruct member 'SensorConfigDialog::high_value_spinbutton_aligner' is never used.
61unusedStructMember563stylestruct member 'SensorConfigDialog::alarm_timeout_spinbutton_aligner' is never used.
65unusedStructMember563stylestruct member 'SensorConfigDialog::alarm_enable_aligner' is never used.
285variableScope398styleThe scope of the variable 'icon_type' can be reduced.
sensors-applet/sensors-applet-plugins.c
25missingIncludeSysteminformationInclude file: <dlfcn.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/sensors-applet-sensor.h
23missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/sensors-applet-settings.c
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <syslog.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
155unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
243unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
544unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
sensors-applet/sensors-applet-settings.h
25missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <mate-panel-applet-gsettings.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
sensors-applet/sensors-applet.c
29missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <glib/gprintf.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
137constParameterCallback398styleParameter 'allocation' can be declared as pointer to const. However it seems that 'size_allocate_cb' is a callback function, if 'allocation' is declared with const you might also need to cast function pointer(s).
167unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
850unreadVariable563styleVariable 'not_end_of_sensors' is assigned a value that is never used.
855variableScope398styleThe scope of the variable 'tree_path' can be reduced.
891redundantAssignment563styleVariable 'not_empty_tree' is reassigned a value before the old one has been used.
891redundantAssignment563styleVariable 'not_empty_tree' is reassigned a value before the old one has been used.
1037variableScope398styleThe scope of the variable 'sensor_tree_path' can be reduced.
sensors-applet/sensors-applet.h
23missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
24missingIncludeSysteminformationInclude file: <mate-panel-applet.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <libnotify/notify.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/stats.html b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/stats.html new file mode 100644 index 0000000..0144741 --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/stats.html @@ -0,0 +1,185 @@ + + + + + + Cppcheck - HTML report - mate-sensors-applet + + + + + +
+ + + + + +
+ + diff --git a/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/style.css b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-22-000940-2729-cppcheck@a0f0a74ebe9a_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} -- cgit v1.2.1