summaryrefslogtreecommitdiff
path: root/plugins/mbmon/mbmon-plugin.c
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 /plugins/mbmon/mbmon-plugin.c
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 'plugins/mbmon/mbmon-plugin.c')
-rw-r--r--plugins/mbmon/mbmon-plugin.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/plugins/mbmon/mbmon-plugin.c b/plugins/mbmon/mbmon-plugin.c
index 5caa51b..754b0f6 100644
--- a/plugins/mbmon/mbmon-plugin.c
+++ b/plugins/mbmon/mbmon-plugin.c
@@ -54,9 +54,7 @@ enum {
};
static const gchar *mbmon_plugin_query_mbmon_daemon(GError **error) {
- int sockfd;
- ssize_t n = 1;
- gboolean first_run = FALSE;
+ static gboolean first_run = FALSE;
gint output_length = 0;
gchar *pc;
@@ -76,6 +74,9 @@ static const gchar *mbmon_plugin_query_mbmon_daemon(GError **error) {
/* 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) {
@@ -135,7 +136,7 @@ static void mbmon_plugin_get_sensors(GList **sensors) {
GError *error = NULL;
const gchar *mbmon_output;
- gchar **output_vector = NULL, **pv, **pv2;
+ gchar **output_vector = NULL, **pv;
mbmon_output = mbmon_plugin_query_mbmon_daemon(&error);
@@ -147,6 +148,8 @@ static void mbmon_plugin_get_sensors(GList **sensors) {
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;