summaryrefslogtreecommitdiff
path: root/applets
diff options
context:
space:
mode:
authorrbuj <[email protected]>2020-08-04 13:11:42 +0200
committerraveit65 <[email protected]>2020-09-07 09:11:05 +0200
commit8f8b7316cc7504a4618705c562ead1ae65dabbdc (patch)
treec536e6c8079781851f2456528042e19497ee5315 /applets
parent59da25f28bc2678cc38bc1def53ca1c4dbf9cc0b (diff)
downloadmate-panel-8f8b7316cc7504a4618705c562ead1ae65dabbdc.tar.bz2
mate-panel-8f8b7316cc7504a4618705c562ead1ae65dabbdc.tar.xz
Remove variableScope warnings reported by cppcheck
cppcheck --enable=all . 2> err.txt grep variableScope err.txt
Diffstat (limited to 'applets')
-rw-r--r--applets/clock/calendar-window.c4
-rw-r--r--applets/clock/clock-location-tile.c12
-rw-r--r--applets/clock/clock-location.c5
-rw-r--r--applets/clock/clock-map.c5
-rw-r--r--applets/clock/clock.c21
-rw-r--r--applets/clock/system-timezone.c5
-rw-r--r--applets/fish/fish.c11
-rw-r--r--applets/wncklet/window-list.c3
-rw-r--r--applets/wncklet/workspace-switcher.c16
9 files changed, 32 insertions, 50 deletions
diff --git a/applets/clock/calendar-window.c b/applets/clock/calendar-window.c
index d69e0010..8fe2c77c 100644
--- a/applets/clock/calendar-window.c
+++ b/applets/clock/calendar-window.c
@@ -181,7 +181,6 @@ create_hig_frame (CalendarWindow *calwin,
GCallback callback)
{
GtkWidget *vbox;
- GtkWidget *label;
GtkWidget *hbox;
char *bold_title;
GtkWidget *expander;
@@ -211,9 +210,10 @@ create_hig_frame (CalendarWindow *calwin,
g_signal_connect (hbox, "add", G_CALLBACK (add_child), expander);
if (button_label) {
+ GtkWidget *label;
GtkWidget *button_box;
GtkWidget *button;
- gchar *text;
+ gchar *text;
button_box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_show (button_box);
diff --git a/applets/clock/clock-location-tile.c b/applets/clock/clock-location-tile.c
index 4e0d71a2..55bc749a 100644
--- a/applets/clock/clock-location-tile.c
+++ b/applets/clock/clock-location-tile.c
@@ -173,14 +173,12 @@ press_on_tile (GtkWidget *widget,
static void
make_current_cb (gpointer data, GError *error)
{
- GtkWidget *dialog;
-
if (error) {
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Failed to set the system timezone"));
+ GtkWidget *dialog = gtk_message_dialog_new (NULL,
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Failed to set the system timezone"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
g_signal_connect (dialog, "response",
G_CALLBACK (gtk_widget_destroy), NULL);
diff --git a/applets/clock/clock-location.c b/applets/clock/clock-location.c
index 1808c0dd..9dc25e4b 100644
--- a/applets/clock/clock-location.c
+++ b/applets/clock/clock-location.c
@@ -76,10 +76,11 @@ clock_location_find_and_ref (GSList *locations,
const gchar *code)
{
GSList *l;
- ClockLocationPrivate *priv;
for (l = locations; l != NULL; l = l->next) {
- priv = clock_location_get_instance_private (l->data);
+
+ ClockLocationPrivate *priv =
+ clock_location_get_instance_private (l->data);
if (priv->latitude == latitude &&
priv->longitude == longitude &&
diff --git a/applets/clock/clock-map.c b/applets/clock/clock-map.c
index 1aa2202e..fc096c60 100644
--- a/applets/clock/clock-map.c
+++ b/applets/clock/clock-map.c
@@ -430,7 +430,6 @@ clock_map_place_locations (ClockMap *this)
{
ClockMapPrivate *priv = clock_map_get_instance_private (this);
GSList *locs;
- ClockLocation *loc;
if (priv->location_map_pixbuf) {
g_object_unref (priv->location_map_pixbuf);
@@ -443,10 +442,8 @@ clock_map_place_locations (ClockMap *this)
g_signal_emit (this, signals[NEED_LOCATIONS], 0, &locs);
while (locs) {
- loc = CLOCK_LOCATION (locs->data);
-
+ ClockLocation *loc = CLOCK_LOCATION (locs->data);
clock_map_place_location (this, loc, FALSE);
-
locs = locs->next;
}
diff --git a/applets/clock/clock.c b/applets/clock/clock.c
index 63c74cac..28b28ac7 100644
--- a/applets/clock/clock.c
+++ b/applets/clock/clock.c
@@ -424,7 +424,6 @@ get_updated_timeformat (ClockData *cd)
*/
char *result;
const char *time_format;
- const char *date_format;
char *clock_format;
const gchar *env_language;
const gchar *env_lc_time;
@@ -462,7 +461,7 @@ get_updated_timeformat (ClockData *cd)
* the day of the month as a decimal number is a single digit,
* it should begin with a 0 in your locale (e.g. "May 01"
* instead of "May 1"). */
- date_format = _("%a %b %e");
+ const char *date_format = _("%a %b %e");
if (use_two_line_format (cd))
/* translators: reverse the order of these arguments
@@ -1152,7 +1151,6 @@ static void
create_cities_section (ClockData *cd)
{
GSList *node;
- ClockLocationTile *city;
GSList *cities;
GSList *l;
@@ -1182,8 +1180,7 @@ create_cities_section (ClockData *cd)
for (l = node; l; l = g_slist_next (l)) {
ClockLocation *loc = l->data;
-
- city = clock_location_tile_new (loc, CLOCK_FACE_SMALL);
+ ClockLocationTile *city = clock_location_tile_new (loc, CLOCK_FACE_SMALL);
g_signal_connect (city, "tile-pressed",
G_CALLBACK (location_tile_pressed_cb), cd);
g_signal_connect (city, "need-clock-format",
@@ -1700,14 +1697,13 @@ static void
set_time_callback (ClockData *cd, GError *error)
{
GtkWidget *window;
- GtkWidget *dialog;
if (error) {
- dialog = gtk_message_dialog_new (NULL,
- 0,
- GTK_MESSAGE_ERROR,
- GTK_BUTTONS_CLOSE,
- _("Failed to set the system time"));
+ GtkWidget *dialog = gtk_message_dialog_new (NULL,
+ 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_CLOSE,
+ _("Failed to set the system time"));
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog), "%s", error->message);
g_signal_connect (dialog, "response",
@@ -2132,7 +2128,6 @@ static void
locations_changed (ClockData *cd)
{
GSList *l;
- ClockLocation *loc;
glong id;
if (!cd->locations) {
@@ -2150,7 +2145,7 @@ locations_changed (ClockData *cd)
}
for (l = cd->locations; l; l = l->next) {
- loc = l->data;
+ ClockLocation *loc = l->data;
id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (loc), "weather-updated"));
if (id == 0) {
diff --git a/applets/clock/system-timezone.c b/applets/clock/system-timezone.c
index bed4aaaf..b1755aa9 100644
--- a/applets/clock/system-timezone.c
+++ b/applets/clock/system-timezone.c
@@ -854,11 +854,10 @@ system_timezone_is_valid (const char *tz)
static char *
system_timezone_find (void)
{
- char *tz;
- int i;
+ int i;
for (i = 0; get_system_timezone_methods[i] != NULL; i++) {
- tz = get_system_timezone_methods[i] ();
+ char *tz = get_system_timezone_methods[i] ();
if (system_timezone_is_valid (tz))
return tz;
diff --git a/applets/fish/fish.c b/applets/fish/fish.c
index afa8c429..d77db1d9 100644
--- a/applets/fish/fish.c
+++ b/applets/fish/fish.c
@@ -261,7 +261,6 @@ static void command_value_changed(GtkEntry* entry, FishApplet *fish)
!strcmp (text, "uptime") ||
!strncmp (text, "tail ", 5)) {
static gboolean message_given = FALSE;
- char *message;
const char *warning_format =
_("Warning: The command "
"appears to be something actually useful.\n"
@@ -272,13 +271,10 @@ static void command_value_changed(GtkEntry* entry, FishApplet *fish)
"which would make the applet "
"\"practical\" or useful.");
- if ( ! message_given) {
- message = g_strdup_printf (warning_format, fish->name);
-
+ if (!message_given) {
+ char *message = g_strdup_printf (warning_format, fish->name);
something_fishy_going_on (fish, message);
-
g_free (message);
-
message_given = TRUE;
}
}
@@ -729,7 +725,6 @@ static void clear_fortune_text(FishApplet* fish)
static gboolean fish_read_output(GIOChannel* source, GIOCondition condition, gpointer data)
{
char output[4096];
- char *utf8_output;
gsize bytes_read;
GError *error = NULL;
GIOStatus status;
@@ -763,6 +758,8 @@ static gboolean fish_read_output(GIOChannel* source, GIOCondition condition, gpo
return TRUE;
if (bytes_read > 0) {
+ char *utf8_output;
+
/* The output is not guarantied to be in UTF-8 format, most
* likely it's just in ASCII-7 or in the user locale
*/
diff --git a/applets/wncklet/window-list.c b/applets/wncklet/window-list.c
index 170692ea..bd4a9603 100644
--- a/applets/wncklet/window-list.c
+++ b/applets/wncklet/window-list.c
@@ -745,12 +745,11 @@ gboolean window_list_applet_fill(MatePanelApplet* applet)
static void call_system_monitor(GtkAction* action, TasklistData* tasklist)
{
- char *programpath;
int i;
for (i = 0; i < G_N_ELEMENTS(system_monitors); i += 1)
{
- programpath = g_find_program_in_path(system_monitors[i]);
+ char *programpath = g_find_program_in_path(system_monitors[i]);
if (programpath != NULL)
{
diff --git a/applets/wncklet/workspace-switcher.c b/applets/wncklet/workspace-switcher.c
index 4d74856b..9d5a210e 100644
--- a/applets/wncklet/workspace-switcher.c
+++ b/applets/wncklet/workspace-switcher.c
@@ -673,14 +673,13 @@ static void num_rows_value_changed(GtkSpinButton* button, PagerData* pager)
static void update_workspaces_model(PagerData* pager)
{
- int nr_ws, i;
- WnckWorkspace* workspace;
- GtkTreeIter iter;
-
- nr_ws = wnck_screen_get_workspace_count(pager->screen);
+ int nr_ws = wnck_screen_get_workspace_count (pager->screen);
if (pager->properties_dialog)
{
+ int i;
+ GtkTreeIter iter;
+
if (nr_ws != gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(pager->num_workspaces_spin)))
gtk_spin_button_set_value(GTK_SPIN_BUTTON(pager->num_workspaces_spin), nr_ws);
@@ -688,7 +687,7 @@ static void update_workspaces_model(PagerData* pager)
for (i = 0; i < nr_ws; i++)
{
- workspace = wnck_screen_get_workspace(pager->screen, i);
+ WnckWorkspace *workspace = wnck_screen_get_workspace(pager->screen, i);
gtk_list_store_append(pager->workspaces_store, &iter);
gtk_list_store_set(pager->workspaces_store, &iter, 0, wnck_workspace_get_name(workspace), -1);
}
@@ -697,12 +696,9 @@ static void update_workspaces_model(PagerData* pager)
static void workspace_renamed(WnckWorkspace* space, PagerData* pager)
{
- int i;
GtkTreeIter iter;
- i = wnck_workspace_get_number(space);
-
- if (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(pager->workspaces_store), &iter, NULL, i))
+ if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (pager->workspaces_store), &iter, NULL, wnck_workspace_get_number (space)))
gtk_list_store_set(pager->workspaces_store, &iter, 0, wnck_workspace_get_name(space), -1);
}