From f1b73ffe6e695d7477d45b0b103474b689a04474 Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Sun, 10 May 2015 17:55:54 +0300 Subject: [PATCH] Ticket #3465: add -Wmissing-variable-declarations option... ...and fix relative warnings. Signed-off-by: Andrew Borodin --- lib/tty/color-internal.c | 4 ++-- lib/vfs/interface.c | 2 ++ lib/vfs/vfs.c | 7 +++++-- m4.include/mc-cflags.m4 | 1 + src/args.c | 10 +++++----- src/editor/spell.c | 2 +- src/filemanager/boxes.c | 6 +++--- src/filemanager/filegui.c | 2 +- src/filemanager/find.c | 2 +- src/filemanager/layout.h | 2 ++ src/filemanager/midnight.c | 3 --- src/filemanager/panel.c | 2 -- src/setup.h | 2 ++ src/vfs/extfs/extfs.c | 4 ++-- src/vfs/sftpfs/config_parser.c | 2 +- 15 files changed, 28 insertions(+), 23 deletions(-) diff --git a/lib/tty/color-internal.c b/lib/tty/color-internal.c index 84bf2c1a9..5359943e4 100644 --- a/lib/tty/color-internal.c +++ b/lib/tty/color-internal.c @@ -54,7 +54,7 @@ typedef struct mc_tty_color_table_struct /*** file scope variables ************************************************************************/ -mc_tty_color_table_t const color_table[] = { +static mc_tty_color_table_t const color_table[] = { {"black", COLOR_BLACK}, {"gray", COLOR_BLACK + COLOR_INTENSITY}, {"red", COLOR_RED}, @@ -81,7 +81,7 @@ mc_tty_color_table_t const color_table[] = { {NULL, 0} }; -mc_tty_color_table_t const attributes_table[] = { +static mc_tty_color_table_t const attributes_table[] = { {"bold", A_BOLD}, #ifdef A_ITALIC /* available since ncurses-5.9-20130831 / slang-pre2.3.0-107 */ {"italic", A_ITALIC}, diff --git a/lib/vfs/interface.c b/lib/vfs/interface.c index 8c54a93a0..550fbef97 100644 --- a/lib/vfs/interface.c +++ b/lib/vfs/interface.c @@ -59,8 +59,10 @@ #include "gc.h" #include "xdirentry.h" +/* TODO: move it to separate private .h */ extern GString *vfs_str_buffer; extern struct vfs_class *current_vfs; +extern struct dirent *mc_readdir_result; /*** global variables ****************************************************************************/ diff --git a/lib/vfs/vfs.c b/lib/vfs/vfs.c index 288671d57..01278e988 100644 --- a/lib/vfs/vfs.c +++ b/lib/vfs/vfs.c @@ -59,15 +59,18 @@ #include "utilvfs.h" #include "gc.h" +/* TODO: move it to the separate .h */ extern struct dirent *mc_readdir_result; +extern GPtrArray *vfs__classes_list; +extern GString *vfs_str_buffer; +extern struct vfs_class *current_vfs; + /*** global variables ****************************************************************************/ GPtrArray *vfs__classes_list = NULL; - GString *vfs_str_buffer = NULL; struct vfs_class *current_vfs = NULL; - /*** file scope macro definitions ****************************************************************/ #if defined(_AIX) && !defined(NAME_MAX) diff --git a/m4.include/mc-cflags.m4 b/m4.include/mc-cflags.m4 index b81af43e1..8f143118c 100644 --- a/m4.include/mc-cflags.m4 +++ b/m4.include/mc-cflags.m4 @@ -66,6 +66,7 @@ dnl Sorted -W options: MC_CHECK_ONE_CFLAG([-Wmissing-field-initializers]) MC_CHECK_ONE_CFLAG([-Wmissing-parameter-type]) MC_CHECK_ONE_CFLAG([-Wmissing-prototypes]) + MC_CHECK_ONE_CFLAG([-Wmissing-variable-declarations]) MC_CHECK_ONE_CFLAG([-Wnested-externs]) MC_CHECK_ONE_CFLAG([-Wno-long-long]) MC_CHECK_ONE_CFLAG([-Wno-unreachable-code]) diff --git a/src/args.c b/src/args.c index b99a87254..d9a4f6461 100644 --- a/src/args.c +++ b/src/args.c @@ -46,9 +46,6 @@ /*** global variables ****************************************************************************/ -/* If true, show version info and exit */ -gboolean mc_args__show_version = FALSE; - /* If true, assume we are running on an xterm terminal */ gboolean mc_args__force_xterm = FALSE; @@ -80,6 +77,9 @@ char *mc_run_param1 = NULL; /*** file scope variables ************************************************************************/ +/* If true, show version info and exit */ +static gboolean mc_args__show_version = FALSE; + /* forward declarations */ static gboolean parse_mc_e_argument (const gchar * option_name, const gchar * value, gpointer data, GError ** mcerror); @@ -193,7 +193,7 @@ static const GOptionEntry argument_main_table[] = { /* *INDENT-ON* */ }; -GOptionGroup *terminal_group; +static GOptionGroup *terminal_group; #define ARGS_TERM_OPTIONS 0 static const GOptionEntry argument_terminal_table[] = { /* *INDENT-OFF* */ @@ -280,7 +280,7 @@ static const GOptionEntry argument_terminal_table[] = { #undef ARGS_TERM_OPTIONS -GOptionGroup *color_group; +static GOptionGroup *color_group; #define ARGS_COLOR_OPTIONS 0 /* #define ARGS_COLOR_OPTIONS G_OPTION_FLAG_IN_MAIN */ static const GOptionEntry argument_color_table[] = { diff --git a/src/editor/spell.c b/src/editor/spell.c index c55339456..2f9c26bac 100644 --- a/src/editor/spell.c +++ b/src/editor/spell.c @@ -63,7 +63,7 @@ static int (*mc_aspell_config_replace) (struct AspellConfig * ths, const char *k static struct AspellCanHaveError *(*mc_new_aspell_speller) (struct AspellConfig * config); static unsigned int (*mc_aspell_error_number) (const struct AspellCanHaveError * ths); static const char *(*mc_aspell_speller_error_message) (const struct AspellSpeller * ths); -const struct AspellError *(*mc_aspell_speller_error) (const struct AspellSpeller * ths); +static const struct AspellError *(*mc_aspell_speller_error) (const struct AspellSpeller * ths); static struct AspellSpeller *(*mc_to_aspell_speller) (struct AspellCanHaveError * obj); static int (*mc_aspell_speller_check) (struct AspellSpeller * ths, const char *word, int word_size); diff --git a/src/filemanager/boxes.c b/src/filemanager/boxes.c index be3613bd5..6fc445c1f 100644 --- a/src/filemanager/boxes.c +++ b/src/filemanager/boxes.c @@ -93,7 +93,7 @@ /*** file scope variables ************************************************************************/ -unsigned long configure_old_esc_mode_id, configure_time_out_id; +static unsigned long configure_old_esc_mode_id, configure_time_out_id; /* Index in list_types[] for "brief" */ static const int panel_listing_brief_idx = 1; @@ -113,8 +113,8 @@ static int new_display_codepage; static unsigned long ftpfs_always_use_proxy_id, ftpfs_proxy_host_id; #endif /* ENABLE_VFS && ENABLE_VFS_FTP */ -GPtrArray *skin_names; -gchar *current_skin_name; +static GPtrArray *skin_names; +static gchar *current_skin_name; #ifdef ENABLE_BACKGROUND static WListbox *bg_list = NULL; diff --git a/src/filemanager/filegui.c b/src/filemanager/filegui.c index 37e04e02a..e8e0c0d8a 100644 --- a/src/filemanager/filegui.c +++ b/src/filemanager/filegui.c @@ -243,7 +243,7 @@ typedef struct /*** file scope variables ************************************************************************/ -struct +static struct { Widget *w; FileProgressStatus action; diff --git a/src/filemanager/find.c b/src/filemanager/find.c index 4de03b487..835ce5d9c 100644 --- a/src/filemanager/find.c +++ b/src/filemanager/find.c @@ -192,7 +192,7 @@ static struct /* *INDENT-ON* */ static const size_t fbuts_num = G_N_ELEMENTS (fbuts); -const size_t quit_button = 4; /* index of "Quit" button */ +static const size_t quit_button = 4; /* index of "Quit" button */ static WListbox *find_list; /* Listbox with the file list */ diff --git a/src/filemanager/layout.h b/src/filemanager/layout.h index 958549dc7..07a360812 100644 --- a/src/filemanager/layout.h +++ b/src/filemanager/layout.h @@ -48,6 +48,8 @@ extern gboolean xterm_title; extern int free_space; extern int nice_rotating_dash; +extern int ok_to_refresh; + extern panels_layout_t panels_layout; /*** declarations of public functions ************************************************************/ diff --git a/src/filemanager/midnight.c b/src/filemanager/midnight.c index b515ea898..80312bf45 100644 --- a/src/filemanager/midnight.c +++ b/src/filemanager/midnight.c @@ -88,9 +88,6 @@ #include "midnight.h" -/* TODO: merge content of layout.c here */ -extern int ok_to_refresh; - /*** global variables ****************************************************************************/ /* When the modes are active, left_panel, right_panel and tree_panel */ diff --git a/src/filemanager/panel.c b/src/filemanager/panel.c index b867bbb29..28974b973 100644 --- a/src/filemanager/panel.c +++ b/src/filemanager/panel.c @@ -310,8 +310,6 @@ panel_field_t panel_fields[] = { mc_fhl_t *mc_filehighlight = NULL; -extern int saving_setup; - /*** file scope macro definitions ****************************************************************/ #define NORMAL 0 diff --git a/src/setup.h b/src/setup.h index ea4cbff85..203ca3063 100644 --- a/src/setup.h +++ b/src/setup.h @@ -134,6 +134,8 @@ extern struct macro_action_t record_macro_buf[MAX_MACRO_LENGTH]; extern GArray *macros_list; +extern int saving_setup; + /*** declarations of public functions ************************************************************/ const char *setup_init (void); diff --git a/src/vfs/extfs/extfs.c b/src/vfs/extfs/extfs.c index 886c5afae..c9144c501 100644 --- a/src/vfs/extfs/extfs.c +++ b/src/vfs/extfs/extfs.c @@ -66,8 +66,6 @@ /*** global variables ****************************************************************************/ -GArray *extfs_plugins = NULL; - /*** file scope macro definitions ****************************************************************/ #undef ERRNOR @@ -135,6 +133,8 @@ typedef struct /*** file scope variables ************************************************************************/ +static GArray *extfs_plugins = NULL; + static gboolean errloop; static gboolean notadir; diff --git a/src/vfs/sftpfs/config_parser.c b/src/vfs/sftpfs/config_parser.c index b792b37f7..cd954e12c 100644 --- a/src/vfs/sftpfs/config_parser.c +++ b/src/vfs/sftpfs/config_parser.c @@ -71,7 +71,7 @@ enum config_var_type /*** file scope variables ************************************************************************/ /* *INDENT-OFF* */ -struct +static struct { const char *pattern; mc_search_t *pattern_regexp;