summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-12-21 15:39:17 +0100
committerraveit65 <[email protected]>2020-12-28 17:22:27 +0100
commit9bc69fd715b8bb45c0c45a27c71ce2cc49b0c7d3 (patch)
tree09b866afe25a5010e01b5f13b8d353f0d1a27bb0 /lib
parent80dffdc6078fd319c5f31248f3896b192d773a60 (diff)
downloadmate-sensors-applet-9bc69fd715b8bb45c0c45a27c71ce2cc49b0c7d3.tar.bz2
mate-sensors-applet-9bc69fd715b8bb45c0c45a27c71ce2cc49b0c7d3.tar.xz
Remove cppcheck warnings about the variable scope can be reduced
Diffstat (limited to 'lib')
-rw-r--r--lib/sensors-applet-plugin.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/sensors-applet-plugin.c b/lib/sensors-applet-plugin.c
index acef5ef..f1476d1 100644
--- a/lib/sensors-applet-plugin.c
+++ b/lib/sensors-applet-plugin.c
@@ -32,10 +32,6 @@ extern const gchar *plugin_name;
void sensors_applet_plugin_find_sensors(GList **sensors,
const gchar *path,
SensorsAppletPluginTestSensorFunc test_sensor) {
- GDir *dir;
- const gchar* new_file;
- gchar *new_path;
-
if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
/* also test can actually open file for reading */
if (access(path, R_OK) == 0) {
@@ -48,9 +44,14 @@ void sensors_applet_plugin_find_sensors(GList **sensors,
for a sensor dir
*/
if (g_file_test(path, G_FILE_TEST_IS_DIR) && !g_file_test(path, G_FILE_TEST_IS_SYMLINK)) {
- dir = g_dir_open(path, 0, NULL);
- if (dir != NULL) {
+ 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);
@@ -63,9 +64,10 @@ void sensors_applet_plugin_find_sensors(GList **sensors,
/* for error handling */
GQuark sensors_applet_plugin_error_quark(void) {
static GQuark quark = 0;
- gchar *string;
if (quark == 0) {
+ gchar *string;
+
string = g_strdup_printf("%s-plugin-error", plugin_name);
quark = g_quark_from_string(string);
g_free(string);