[gnome-commander] Reduce the scope of some variables, remove other unused ones



commit a367e945154104133d31eff4dd1d1e74c52c3e1b
Author: Uwe Scholz <uwescholz src gnome org>
Date:   Fri Oct 7 22:21:14 2016 +0200

    Reduce the scope of some variables, remove other unused ones

 src/dialogs/gnome-cmd-file-props-dialog.cc |    3 ++-
 src/dialogs/gnome-cmd-make-copy-dialog.cc  |    1 -
 src/dialogs/gnome-cmd-remote-dialog.cc     |    7 ++-----
 src/dialogs/gnome-cmd-rename-dialog.cc     |    1 -
 src/gnome-cmd-about-plugin.cc              |    3 ++-
 src/gnome-cmd-data.cc                      |    8 +++++---
 src/gnome-cmd-dir.cc                       |    2 +-
 src/gnome-cmd-main-menu.cc                 |    2 +-
 src/gnome-cmd-smb-path.cc                  |    7 ++++---
 src/gnome-cmd-user-actions.cc              |    4 ++--
 src/gnome-cmd-xfer.cc                      |    2 +-
 src/intviewer/searcher.cc                  |    8 ++++++--
 src/intviewer/text-render.cc               |   11 ++---------
 src/intviewer/viewer-window.cc             |    7 ++++---
 tests/iv_fileops_test.cc                   |    3 +--
 15 files changed, 33 insertions(+), 36 deletions(-)
---
diff --git a/src/dialogs/gnome-cmd-file-props-dialog.cc b/src/dialogs/gnome-cmd-file-props-dialog.cc
index c22e7f6..4599736 100644
--- a/src/dialogs/gnome-cmd-file-props-dialog.cc
+++ b/src/dialogs/gnome-cmd-file-props-dialog.cc
@@ -338,7 +338,6 @@ inline GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
     GtkWidget *dialog = data->dialog;
     GtkWidget *table;
     GtkWidget *label;
-    GtkWidget *hbox;
     gchar *fname;
 
     GtkWidget *space_frame = create_space_frame (dialog, 6);
@@ -438,6 +437,8 @@ inline GtkWidget *create_properties_tab (GnomeCmdFilePropsDialogPrivate *data)
 
     if (data->f->info->type != GNOME_VFS_FILE_TYPE_DIRECTORY)
     {
+        GtkWidget *hbox;
+
         label = create_bold_label (dialog, _("Opens with:"));
         table_add (table, label, 0, y, GTK_FILL);
 
diff --git a/src/dialogs/gnome-cmd-make-copy-dialog.cc b/src/dialogs/gnome-cmd-make-copy-dialog.cc
index 68cc81e..8bde87c 100644
--- a/src/dialogs/gnome-cmd-make-copy-dialog.cc
+++ b/src/dialogs/gnome-cmd-make-copy-dialog.cc
@@ -33,7 +33,6 @@ struct GnomeCmdMakeCopyDialogPrivate
 {
     GnomeCmdFile *f;
     GnomeCmdDir *dir;
-    GnomeCmdMainWin *mw;
 };
 
 
diff --git a/src/dialogs/gnome-cmd-remote-dialog.cc b/src/dialogs/gnome-cmd-remote-dialog.cc
index faa3492..5cd12e2 100644
--- a/src/dialogs/gnome-cmd-remote-dialog.cc
+++ b/src/dialogs/gnome-cmd-remote-dialog.cc
@@ -168,7 +168,6 @@ static void on_new_btn_clicked (GtkButton *button, GnomeCmdRemoteDialog *remote_
     if (!server)
         return;
 
-    GnomeCmdCon *con = GNOME_CMD_CON (server);
     GtkListStore *store = GTK_LIST_STORE (gtk_tree_view_get_model (GTK_TREE_VIEW 
(remote_dialog->priv->connection_list)));
     GtkTreeIter iter;
 
@@ -323,8 +322,6 @@ inline GtkTreeModel *create_and_fill_model (GList *list)
 
     for (GtkTreeIter iter; list; list=list->next)
     {
-        GnomeCmdCon *con = GNOME_CMD_CON (list->data);
-
         gtk_list_store_append (store, &iter);
         set_server (store, &iter, GNOME_CMD_CON_REMOTE (list->data));
     }
@@ -466,8 +463,8 @@ static void gnome_cmd_remote_dialog_init (GnomeCmdRemoteDialog *dialog)
     dialog->priv->anonymous_pw_entry = create_entry (*dialog, "anonymous_pw_entry", 
gnome_cmd_data_get_ftp_anonymous_password ());
     table_add (table, dialog->priv->anonymous_pw_entry, 1, 0, GTK_FILL);
 
-    button = gnome_cmd_dialog_add_button (*dialog, GTK_STOCK_HELP, GTK_SIGNAL_FUNC (on_help_btn_clicked), 
dialog);
-    button = gnome_cmd_dialog_add_button (*dialog, GTK_STOCK_CLOSE, GTK_SIGNAL_FUNC (on_close_btn_clicked), 
dialog);
+    gnome_cmd_dialog_add_button (*dialog, GTK_STOCK_HELP, GTK_SIGNAL_FUNC (on_help_btn_clicked), dialog);
+    gnome_cmd_dialog_add_button (*dialog, GTK_STOCK_CLOSE, GTK_SIGNAL_FUNC (on_close_btn_clicked), dialog);
     button = gnome_cmd_dialog_add_button (*dialog, GTK_STOCK_CONNECT, GTK_SIGNAL_FUNC 
(on_connect_btn_clicked), dialog);
 
     dialog->priv->connect_button = button;
diff --git a/src/dialogs/gnome-cmd-rename-dialog.cc b/src/dialogs/gnome-cmd-rename-dialog.cc
index d8360dd..1865ddb 100644
--- a/src/dialogs/gnome-cmd-rename-dialog.cc
+++ b/src/dialogs/gnome-cmd-rename-dialog.cc
@@ -34,7 +34,6 @@ using namespace std;
 struct GnomeCmdRenameDialogPrivate
 {
     GnomeCmdFile *f;
-    GnomeCmdMainWin *mw;
     GtkEntry *textbox;
 };
 
diff --git a/src/gnome-cmd-about-plugin.cc b/src/gnome-cmd-about-plugin.cc
index 77d2ea9..5bc329e 100644
--- a/src/gnome-cmd-about-plugin.cc
+++ b/src/gnome-cmd-about-plugin.cc
@@ -493,7 +493,7 @@ static void gnome_cmd_about_plugin_set_name (GnomeCmdAboutPlugin *about, const g
 {
     gchar *title_string;
     gchar *name_string;
-    gchar *tmp_name, *tmp_version;
+    gchar *tmp_name;
 
     g_free (about->priv->name);
     about->priv->name = g_strdup (name ? name : "");
@@ -506,6 +506,7 @@ static void gnome_cmd_about_plugin_set_name (GnomeCmdAboutPlugin *about, const g
 
     if (about->priv->version)
     {
+        gchar *tmp_version;
         tmp_version = g_markup_escape_text (about->priv->version, -1);
         name_string = g_strdup_printf ("<span size=\"xx-large\" weight=\"bold\">%s %s</span>", tmp_name, 
tmp_version);
         g_free (tmp_version);
diff --git a/src/gnome-cmd-data.cc b/src/gnome-cmd-data.cc
index 7f10524..4031364 100644
--- a/src/gnome-cmd-data.cc
+++ b/src/gnome-cmd-data.cc
@@ -1721,11 +1721,11 @@ static void save_fav_apps (const gchar *fname)
                 if (app2)
                 {
                     gchar *group_name = g_strdup(gnome_cmd_app_get_name(app2));
-                    int name_occurence = 2;
 
                     /* Are the names equal? -> Change the name */
                     if (!strcmp(group_name_to_test, group_name))
                     {
+                        int name_occurence = 2;
                         gchar *new_name = g_strdup_printf("%s_%d",
                                             gnome_cmd_app_get_name(app2),
                                             name_occurence);
@@ -3976,13 +3976,14 @@ void GnomeCmdData::save_xml ()
 gboolean GnomeCmdData::migrate_data_string_value_into_gsettings(const char* user_value, GSettings *settings, 
const char *key)
 {
     GVariant *variant;
-    gchar *default_value;
     gint rv = true;
 
     variant = g_settings_get_default_value (settings, key);
 
     if (g_variant_classify(variant) == G_VARIANT_CLASS_STRING)
     {
+        gchar *default_value;
+
         // In the following it is assumed that the value behind 'default_value' is the actual
         // default value, i.e. nobody changed the given key before gcmd data migration was started.
         default_value = g_settings_get_string (settings, key);
@@ -4281,11 +4282,12 @@ gboolean GnomeCmdData::set_color_if_valid_key_value(GdkColor *color, GSettings *
 {
     gboolean return_value;
     gchar *colorstring_new;
-    gchar *colorstring_old;
 
     colorstring_new = g_settings_get_string (settings, key);
     if (!gnome_cmd_data.is_valid_color_string(colorstring_new))
     {
+        gchar *colorstring_old;
+
         colorstring_old = gdk_color_to_string (color);
         g_settings_set_string (settings, key, colorstring_old);
         g_warning("Illegal color string \'%s\'. Resetting to old value \'%s\'", colorstring_new, 
colorstring_old);
diff --git a/src/gnome-cmd-dir.cc b/src/gnome-cmd-dir.cc
index 1ba3c82..cc8c2ce 100644
--- a/src/gnome-cmd-dir.cc
+++ b/src/gnome-cmd-dir.cc
@@ -401,7 +401,6 @@ static GList *create_file_list (GnomeCmdDir *dir, GList *info_list)
 
         if (info && info->name)
         {
-            GnomeCmdCon *con = gnome_cmd_dir_get_connection (dir);
 
             if (strcmp (info->name, ".") == 0 || strcmp (info->name, "..") == 0)
             {
@@ -410,6 +409,7 @@ static GList *create_file_list (GnomeCmdDir *dir, GList *info_list)
             }
 
 #ifdef HAVE_SAMBA
+            GnomeCmdCon *con = gnome_cmd_dir_get_connection (dir);
             if (GNOME_CMD_IS_CON_SMB (con)
                 && info->mime_type
                 && (strcmp (info->mime_type, "application/x-gnome-app-info") == 0 ||
diff --git a/src/gnome-cmd-main-menu.cc b/src/gnome-cmd-main-menu.cc
index 1565b96..a32acb2 100644
--- a/src/gnome-cmd-main-menu.cc
+++ b/src/gnome-cmd-main-menu.cc
@@ -148,7 +148,6 @@ static GtkWidget *create_menu_item (GnomeCmdMainMenu *main_menu, GtkMenu *parent
     GtkWidget *desc=NULL;
     GtkWidget *shortcut=NULL;
     GtkWidget *content = NULL;
-    GtkWidget *pixmap = NULL;
 
     switch (spec->type)
     {
@@ -176,6 +175,7 @@ static GtkWidget *create_menu_item (GnomeCmdMainMenu *main_menu, GtkMenu *parent
 
             if (spec->pixmap_type != 0 && spec->pixmap_info)
             {
+                GtkWidget *pixmap = NULL;
                 pixmap = create_ui_pixmap (*main_win, spec->pixmap_type, spec->pixmap_info, 
GTK_ICON_SIZE_MENU);
 
                 if (pixmap)
diff --git a/src/gnome-cmd-smb-path.cc b/src/gnome-cmd-smb-path.cc
index c4c5ac4..81cd94d 100644
--- a/src/gnome-cmd-smb-path.cc
+++ b/src/gnome-cmd-smb-path.cc
@@ -154,9 +154,7 @@ GnomeCmdSmbPath::GnomeCmdSmbPath(const gchar *path_str): workgroup(0), resource(
     g_return_if_fail (path_str != NULL);
 
     gchar *s, *t;
-    gchar *a = NULL,
-          *b = NULL,
-          *c = NULL;
+    gchar *c = NULL;
 
     DEBUG('s', "Creating smb-path for %s\n", path_str);
 
@@ -179,6 +177,9 @@ GnomeCmdSmbPath::GnomeCmdSmbPath(const gchar *path_str): workgroup(0), resource(
 
     if (v[0] != NULL)
     {
+        gchar *a = NULL;
+        gchar *b = NULL;
+
         a = g_strdup (v[0]);
         if (v[1] != NULL)
         {
diff --git a/src/gnome-cmd-user-actions.cc b/src/gnome-cmd-user-actions.cc
index be09ce5..f8dbf8f 100644
--- a/src/gnome-cmd-user-actions.cc
+++ b/src/gnome-cmd-user-actions.cc
@@ -786,7 +786,6 @@ void file_edit (GtkMenuItem *menuitem, gpointer not_used)
         gnome_cmd_file_selector_show_new_textfile_dialog (get_fs (ACTIVE));
     else
     {
-       GnomeCmdDir *dir = NULL;
        gchar       *command;
 
        command = g_strdup (gnome_cmd_data.options.editor);
@@ -804,6 +803,7 @@ void file_edit (GtkMenuItem *menuitem, gpointer not_used)
        }
        else
        {
+        GnomeCmdDir *dir = NULL;
            gint     argc;
            gchar  **argv  = NULL;
            GError  *error = NULL;
@@ -931,7 +931,6 @@ void file_advrename (GtkMenuItem *menuitem, gpointer not_used)
 
 void file_sendto (GtkMenuItem *menuitem, gpointer not_used)
 {
-    GnomeCmdDir  *dir     = NULL;
     gchar        *command = NULL;
     string        dir_path;
     string        cmd;
@@ -949,6 +948,7 @@ void file_sendto (GtkMenuItem *menuitem, gpointer not_used)
     }
     else
     {
+    GnomeCmdDir *dir = NULL;
        gint     argc;
        gchar  **argv  = NULL;
        GError  *error = NULL;
diff --git a/src/gnome-cmd-xfer.cc b/src/gnome-cmd-xfer.cc
index ce590ca..5b54ed9 100644
--- a/src/gnome-cmd-xfer.cc
+++ b/src/gnome-cmd-xfer.cc
@@ -128,10 +128,10 @@ create_xfer_data (GnomeVFSXferOptions xferOptions, GList *src_uri_list, GList *d
     // The async_xfer_callback-results for file and byte totals are not reliable
     if (xferOptions == GNOME_VFS_XFER_REMOVESOURCE) {
         GList *uris;
-        GnomeVFSURI *uri;
         data->bytes_total = 0;
         data->files_total = 0;
         for (uris = data->src_uri_list; uris != NULL; uris = uris->next) {
+            GnomeVFSURI *uri;
             uri = (GnomeVFSURI*)uris->data;
             data->bytes_total += calc_tree_size(uri,&(data->files_total));
         }
diff --git a/src/intviewer/searcher.cc b/src/intviewer/searcher.cc
index 8da038b..17691f6 100644
--- a/src/intviewer/searcher.cc
+++ b/src/intviewer/searcher.cc
@@ -424,7 +424,7 @@ gboolean search_hex_backward (GViewerSearcher *src)
 
 gboolean search_text_forward (GViewerSearcher *src)
 {
-    offset_type m, n, j, t, delta;
+    offset_type m, n, j;
     int i;
     gboolean found = FALSE;
     char_type value;
@@ -437,6 +437,8 @@ gboolean search_text_forward (GViewerSearcher *src)
 
     while (j <= n - m)
     {
+        offset_type t, delta;
+
         delta = m - 1;
         t = j;
         while (delta--)
@@ -486,7 +488,7 @@ gboolean search_text_forward (GViewerSearcher *src)
 
 gboolean search_text_backward (GViewerSearcher *src)
 {
-    offset_type m, n, j, t, delta;
+    offset_type m, n, j;
     int i;
     gboolean found = FALSE;
     int update_counter;
@@ -504,6 +506,8 @@ gboolean search_text_backward (GViewerSearcher *src)
     j = gv_input_get_previous_char_offset(src->priv->imd, j);
     while (j >= m)
     {
+        offset_type t, delta;
+
         delta = m - 1;
         t = j;
         while (delta--)
diff --git a/src/intviewer/text-render.cc b/src/intviewer/text-render.cc
index a303a18..59441d3 100644
--- a/src/intviewer/text-render.cc
+++ b/src/intviewer/text-render.cc
@@ -665,10 +665,11 @@ static gboolean text_render_motion_notify(GtkWidget *widget, GdkEventMotion *eve
 
     GdkModifierType mods;
     gint x, y;
-    offset_type new_marker;
 
     if (w->priv->button != 0)
     {
+        offset_type new_marker;
+
         x = event->x;
         y = event->y;
 
@@ -1596,7 +1597,6 @@ static int text_mode_display_line(TextRender *w, int y, int column, offset_type
 
     offset_type current;
     char_type value;
-    int rc=0;
     int char_count = 0;
     offset_type marker_start;
     offset_type marker_end;
@@ -1629,10 +1629,7 @@ static int text_mode_display_line(TextRender *w, int y, int column, offset_type
         // Read a UTF8 character from the input file. The "inputmode" module is responsible for converting 
the file into UTF8
         value = gv_input_mode_get_utf8_char(w->priv->im, current);
         if (value==INVALID_CHAR)
-        {
-            rc = -1;
             break;
-        }
 
         // move to the next character's offset
         current = gv_input_get_next_char_offset(w->priv->im, current);
@@ -1678,7 +1675,6 @@ static int binary_mode_display_line(TextRender *w, int y, int column, offset_typ
 
     offset_type current;
     char_type value;
-    int rc=0;
     offset_type marker_start;
     offset_type marker_end;
     gboolean show_marker;
@@ -1708,10 +1704,7 @@ static int binary_mode_display_line(TextRender *w, int y, int column, offset_typ
            The "inputmode" module is responsible for converting the file into UTF8 */
         value = gv_input_mode_get_utf8_char(w->priv->im, current);
         if (value==INVALID_CHAR)
-        {
-            rc = -1;
             break;
-        }
 
         // move to the next character's offset
         current = gv_input_get_next_char_offset(w->priv->im, current);
diff --git a/src/intviewer/viewer-window.cc b/src/intviewer/viewer-window.cc
index e6a87cd..77aeefc 100644
--- a/src/intviewer/viewer-window.cc
+++ b/src/intviewer/viewer-window.cc
@@ -1145,9 +1145,6 @@ static void menu_edit_copy(GtkMenuItem *item, GViewerWindow *obj)
 
 static void start_find_thread(GViewerWindow *obj, gboolean forward)
 {
-    offset_type result;
-    GtkWidget *w;
-
     g_viewer_searcher_start_search(obj->priv->srchr, forward);
     gviewer_show_search_progress_dlg(GTK_WINDOW (obj),
                                      obj->priv->search_pattern,
@@ -1159,12 +1156,16 @@ static void start_find_thread(GViewerWindow *obj, gboolean forward)
 
     if (g_viewer_searcher_get_end_of_search(obj->priv->srchr))
     {
+        GtkWidget *w;
+
         w = gtk_message_dialog_new(GTK_WINDOW (obj), GTK_DIALOG_MODAL, GTK_MESSAGE_INFO, GTK_BUTTONS_OK, 
_("Pattern \"%s\" was not found"), obj->priv->search_pattern);
         gtk_dialog_run (GTK_DIALOG (w));
         gtk_widget_destroy (w);
     }
     else
     {
+        offset_type result;
+
         result = g_viewer_searcher_get_search_result(obj->priv->srchr);
         text_render_set_marker(gviewer_get_text_render(obj->priv->viewer),
                 result,
diff --git a/tests/iv_fileops_test.cc b/tests/iv_fileops_test.cc
index 18e6242..5e9a5b0 100644
--- a/tests/iv_fileops_test.cc
+++ b/tests/iv_fileops_test.cc
@@ -34,7 +34,6 @@ TEST_F(FileOpsTest, gv_file_get_byte_does_read) {
     ViewerFileOps *fops;
     offset_type end;
     offset_type current;
-    int value;
 
     fops = gv_fileops_new();
 
@@ -44,7 +43,7 @@ TEST_F(FileOpsTest, gv_file_get_byte_does_read) {
 
     for (current = 0; current < end; current++)
     {
-        value = gv_file_get_byte(fops, current);
+        int value = gv_file_get_byte(fops, current);
         ASSERT_TRUE (0 <= value && value <= 255 );
     }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]