From bada6849cd505b237f4f7fd14de151fade8008dc Mon Sep 17 00:00:00 2001 From: Patrick Winnertz Date: Tue, 30 Jun 2009 13:10:42 +0200 Subject: [PATCH] Remove unneeded vars in edit/edit.c to avoid compiler warnings Signed-off-by: Patrick Winnertz edit: cleanup: moved variable declaration to begin of block edit: have_charset: added explicit variable declarations Signed-off-by: Sergei Trofimovich fix not initialized variable 'cw' fix variables 'cw', 'utf_ch', make more safety algorithm. --- edit/edit.c | 14 +++++++++----- edit/editcmd.c | 2 +- edit/editdraw.c | 5 +++-- src/widget.c | 4 ++-- vfs/vfs.c | 6 +++--- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/edit/edit.c b/edit/edit.c index dde78b4ae..0dd2b52ef 100644 --- a/edit/edit.c +++ b/edit/edit.c @@ -1470,16 +1470,21 @@ long edit_move_forward3 (WEdit * edit, long current, int cols, long upto) { long p, q; int col = 0; - int cw = 1; - gunichar utf_ch = 0; +#ifdef HAVE_CHARSET + int cw = 1; + int utf_ch = 0; +#endif if (upto) { q = upto; cols = -10; } else q = edit->last_byte + 2; - for (col = 0, p = current; p < q; p++) { int c; +#ifdef HAVE_CHARSET + cw = 1; + utf_ch = 0; +#endif if (cols != -10) { if (col == cols) return p; @@ -2416,8 +2421,6 @@ static const char * const shell_cmd[] = SHELL_COMMANDS_i; void edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) { - int i = 0; - edit->force |= REDRAW_LINE; /* The next key press will unhighlight the found string, so update @@ -2457,6 +2460,7 @@ edit_execute_cmd (WEdit *edit, int command, int char_for_insertion) #ifdef HAVE_CHARSET if ( char_for_insertion > 255 && utf8_display == 0 ) { unsigned char str[6 + 1]; + size_t i = 0; int res = g_unichar_to_utf8 (char_for_insertion, (char *)str); if ( res == 0 ) { str[0] = '.'; diff --git a/edit/editcmd.c b/edit/editcmd.c index ce30b4d0a..9316ca6e0 100644 --- a/edit/editcmd.c +++ b/edit/editcmd.c @@ -1437,7 +1437,7 @@ edit_replace_cmd (WEdit *edit, int again) /*returns negative on not found or error in pattern */ if (edit->search_start >= 0) { - int i; + guint i; edit->found_start = edit->search_start; i = edit->found_len = len; diff --git a/edit/editdraw.c b/edit/editdraw.c index 9aaa6a6cc..3f861da0a 100644 --- a/edit/editdraw.c +++ b/edit/editdraw.c @@ -283,8 +283,9 @@ print_to_widget (WEdit *edit, long row, int start_col, int start_col_real, edit_move (x1, y); hline (' ', end_col + 1 - EDIT_TEXT_HORIZONTAL_OFFSET - x1); - if ( option_line_state ) { - for (int i = 0; i < LINE_STATE_WIDTH; i++) { + if (option_line_state) { + int i; + for (i = 0; i < LINE_STATE_WIDTH; i++) { if ( status[i] == '\0' ) { status[i] = ' '; } diff --git a/src/widget.c b/src/widget.c index bc2fda6a0..65ee7fa7d 100644 --- a/src/widget.c +++ b/src/widget.c @@ -890,7 +890,7 @@ int num_history_items_recorded = 60; GList * history_get (const char *input_name) { - int i; + size_t i; GList *hist = NULL; char *profile; mc_config_t *cfg; @@ -912,7 +912,7 @@ history_get (const char *input_name) for (i = 0; i < keys_num; i++) { char key_name[BUF_TINY]; - g_snprintf (key_name, sizeof (key_name), "%d", i); + g_snprintf (key_name, sizeof (key_name), "%lu", (unsigned long)i); this_entry = mc_config_get_string (cfg, input_name, key_name, ""); if (this_entry && *this_entry) diff --git a/vfs/vfs.c b/vfs/vfs.c index 184cf0c6e..d624347cb 100644 --- a/vfs/vfs.c +++ b/vfs/vfs.c @@ -137,7 +137,7 @@ vfs_op (int handle) struct vfs_openfile *h; if (handle < VFS_FIRST_HANDLE || - handle - VFS_FIRST_HANDLE >= vfs_openfiles->len) + (guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len) return NULL; h = (struct vfs_openfile *) g_ptr_array_index ( @@ -157,7 +157,7 @@ vfs_info (int handle) struct vfs_openfile *h; if (handle < VFS_FIRST_HANDLE || - handle - VFS_FIRST_HANDLE >= vfs_openfiles->len) + (guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len) return NULL; h = (struct vfs_openfile *) g_ptr_array_index ( @@ -175,7 +175,7 @@ static inline void vfs_free_handle (int handle) { if (handle < VFS_FIRST_HANDLE || - handle - VFS_FIRST_HANDLE >= vfs_openfiles->len) + (guint)(handle - VFS_FIRST_HANDLE) >= vfs_openfiles->len) return; g_ptr_array_index (vfs_openfiles, handle - VFS_FIRST_HANDLE) =