OSDN Git Service

Clean up sparse warnings
authorTheodore Ts'o <tytso@mit.edu>
Mon, 16 Dec 2013 23:56:36 +0000 (18:56 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 16 Dec 2013 23:56:36 +0000 (18:56 -0500)
Mostly by adding static and removing excess extern qualifiers.  Also
convert a few remaining non-ANSI function declarations to ANSI.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
43 files changed:
debugfs/debugfs.h
debugfs/extent_inode.c
debugfs/logdump.c
debugfs/util.c
e2fsck/dirinfo.c
e2fsck/e2fsck.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/unix.c
e2fsck/util.c
lib/et/com_err.c
lib/et/error_message.c
lib/et/error_table.h
lib/et/et_name.c
lib/ext2fs/Makefile.in
lib/ext2fs/bmap.c
lib/ext2fs/dblist.c
lib/ext2fs/dir_iterate.c
lib/ext2fs/extent.c
lib/ext2fs/fileio.c
lib/ext2fs/mmp.c
lib/ext2fs/punch.c
lib/ss/error.c
lib/ss/execute_cmd.c
lib/ss/help.c
lib/ss/invocation.c
lib/ss/pager.c
lib/ss/parse.c
lib/ss/request_tbl.c
lib/ss/ss_internal.h
misc/badblocks.c
misc/dumpe2fs.c
misc/e2image.c
misc/e2initrd_helper.c
misc/e2undo.c
misc/e4defrag.c
misc/fsck.c
misc/logsave.c
misc/mke2fs.c
resize/main.c
resize/resize2fs.c
resize/resize2fs.h
util/subst.c

index 45175cf..6b4f6ef 100644 (file)
@@ -170,6 +170,9 @@ extern void do_set_mmp_value(int argc, char **argv);
 extern void do_freefrag(int argc, char **argv);
 extern void do_filefrag(int argc, char *argv[]);
 
+/* util.c */
+extern time_t string_to_time(const char *arg);
+
 /* zap.c */
 extern void do_zap_block(int argc, char **argv);
 extern void do_block_dump(int argc, char **argv);
index 75e328c..b3c55f9 100644 (file)
@@ -25,8 +25,8 @@ extern char *optarg;
 
 #include "debugfs.h"
 
-ext2_ino_t     current_ino;
-ext2_extent_handle_t current_handle;
+static ext2_ino_t      current_ino;
+static ext2_extent_handle_t current_handle;
 
 static void dbg_print_extent(char *desc, struct ext2fs_extent *extent)
 {
index a61d553..66a5428 100644 (file)
@@ -39,10 +39,10 @@ enum journal_location {JOURNAL_IS_INTERNAL, JOURNAL_IS_EXTERNAL};
 
 #define ANY_BLOCK ((blk64_t) -1)
 
-int            dump_all, dump_contents, dump_descriptors;
-blk64_t                block_to_dump, bitmap_to_dump, inode_block_to_dump;
-unsigned int   group_to_dump, inode_offset_to_dump;
-ext2_ino_t     inode_to_dump;
+static int             dump_all, dump_contents, dump_descriptors;
+static blk64_t         block_to_dump, bitmap_to_dump, inode_block_to_dump;
+static unsigned int    group_to_dump, inode_offset_to_dump;
+static ext2_ino_t      inode_to_dump;
 
 struct journal_source
 {
index 09088e0..aafbc56 100644 (file)
@@ -211,7 +211,7 @@ char *time_to_string(__u32 cl)
  * Parse a string as a time.  Return ((time_t)-1) if the string
  * doesn't appear to be a sane time.
  */
-extern time_t string_to_time(const char *arg)
+time_t string_to_time(const char *arg)
 {
        struct  tm      ts;
        time_t          ret;
index c81777a..dc08f90 100644 (file)
@@ -320,7 +320,7 @@ int e2fsck_get_num_dirinfo(e2fsck_t ctx)
        return ctx->dir_info ? ctx->dir_info->count : 0;
 }
 
-extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
+struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
 {
        struct dir_info_iter *iter;
        struct dir_info_db *db = ctx->dir_info;
@@ -334,8 +334,8 @@ extern struct dir_info_iter *e2fsck_dir_info_iter_begin(e2fsck_t ctx)
        return iter;
 }
 
-extern void e2fsck_dir_info_iter_end(e2fsck_t ctx EXT2FS_ATTR((unused)),
-                                    struct dir_info_iter *iter)
+void e2fsck_dir_info_iter_end(e2fsck_t ctx EXT2FS_ATTR((unused)),
+                             struct dir_info_iter *iter)
 {
        free(iter->tdb_iter.dptr);
        ext2fs_free_mem(&iter);
index 994f80e..0ec1540 100644 (file)
@@ -199,7 +199,7 @@ void e2fsck_free_context(e2fsck_t ctx)
  */
 typedef void (*pass_t)(e2fsck_t ctx);
 
-pass_t e2fsck_passes[] = {
+static pass_t e2fsck_passes[] = {
        e2fsck_pass1, e2fsck_pass2, e2fsck_pass3, e2fsck_pass4,
        e2fsck_pass5, 0 };
 
index a8237af..71b3000 100644 (file)
@@ -509,8 +509,8 @@ static void check_is_really_dir(e2fsck_t ctx, struct problem_context *pctx,
        }
 }
 
-extern void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
-                                   ext2_icount_t *ret)
+void e2fsck_setup_tdb_icount(e2fsck_t ctx, int flags,
+                            ext2_icount_t *ret)
 {
        unsigned int            threshold;
        ext2_ino_t              num_dirs;
index b7268e3..7277a7b 100644 (file)
@@ -1260,8 +1260,8 @@ static void clear_htree(e2fsck_t ctx, ext2_ino_t ino)
 }
 
 
-extern int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
-                                   ext2_ino_t ino, char *buf)
+int e2fsck_process_bad_inode(e2fsck_t ctx, ext2_ino_t dir,
+                            ext2_ino_t ino, char *buf)
 {
        ext2_filsys fs = ctx->fs;
        struct ext2_inode       inode;
index 10f0628..6f94644 100644 (file)
@@ -464,7 +464,7 @@ struct percent_tbl {
        int     max_pass;
        int     table[32];
 };
-struct percent_tbl e2fsck_tbl = {
+static struct percent_tbl e2fsck_tbl = {
        5, { 0, 70, 90, 92,  95, 100 }
 };
 static char bar[128], spaces[128];
@@ -483,7 +483,7 @@ static float calc_percent(struct percent_tbl *tbl, int pass, int curr,
                + tbl->table[pass-1]);
 }
 
-extern void e2fsck_clear_progbar(e2fsck_t ctx)
+void e2fsck_clear_progbar(e2fsck_t ctx)
 {
        if (!(ctx->flags & E2F_FLAG_PROG_BAR))
                return;
index eb3e0f4..9f920b2 100644 (file)
@@ -463,9 +463,9 @@ void e2fsck_read_inode_full(e2fsck_t ctx, unsigned long ino,
        }
 }
 
-extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
-                              struct ext2_inode * inode, int bufsize,
-                              const char *proc)
+void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
+                            struct ext2_inode * inode, int bufsize,
+                            const char *proc)
 {
        errcode_t retval;
 
@@ -477,8 +477,8 @@ extern void e2fsck_write_inode_full(e2fsck_t ctx, unsigned long ino,
        }
 }
 
-extern void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
-                              struct ext2_inode * inode, const char *proc)
+void e2fsck_write_inode(e2fsck_t ctx, unsigned long ino,
+                       struct ext2_inode * inode, const char *proc)
 {
        errcode_t retval;
 
index 4ea52de..d38998a 100644 (file)
@@ -85,8 +85,7 @@ void com_err (const char *whoami,
     va_end(pvar);
 }
 
-errf set_com_err_hook (new_proc)
-    errf new_proc;
+errf set_com_err_hook(errf new_proc)
 {
     errf x = com_err_hook;
 
@@ -98,7 +97,7 @@ errf set_com_err_hook (new_proc)
     return x;
 }
 
-errf reset_com_err_hook () {
+errf reset_com_err_hook(void) {
     errf x = com_err_hook;
     com_err_hook = default_com_err_proc;
     return x;
index 92509e6..5d8d242 100644 (file)
@@ -105,8 +105,7 @@ typedef char *(*gettextf) (const char *);
 
 static gettextf com_err_gettext = NULL;
 
-gettextf set_com_err_gettext (new_proc)
-    gettextf new_proc;
+gettextf set_com_err_gettext(gettextf new_proc)
 {
     gettextf x = com_err_gettext;
 
index 4f10991..24e4762 100644 (file)
@@ -18,7 +18,7 @@ struct et_list {
     struct et_list *next;
     const struct error_table *table;
 };
-extern struct et_list * _et_list;
+extern struct et_list *_et_list, *_et_dynamic_list;
 
 #define        ERRCODE_RANGE   8       /* # of bits to shift table number */
 #define        BITS_PER_CHAR   6       /* # bits to shift per character in name */
index 6b59edd..d9a3e87 100644 (file)
@@ -21,8 +21,7 @@ static const char char_set[] =
 
 static char buf[6];
 
-const char * error_table_name(num)
-    errcode_t num;
+const char * error_table_name(errcode_t num)
 {
     int ch;
     int i;
index abe2124..87678c6 100644 (file)
@@ -306,7 +306,7 @@ extent_cmds.c extent_cmds.h: $(top_srcdir)/debugfs/extent_cmds.ct
 
 DEBUG_OBJS= debug_cmds.o debugfs.o util.o ncheck.o icheck.o ls.o \
        lsdel.o dump.o set_fields.o logdump.o htree.o unused.o \
-       e2freefrag.o filefrag.o extent_inode.o extent_cmds.o
+       e2freefrag.o filefrag.o extent_inode.o extent_cmds.o zap.o
 
 debugfs.o: $(top_srcdir)/debugfs/debugfs.c
        $(E) "  CC $<"
@@ -356,6 +356,10 @@ unused.o: $(top_srcdir)/debugfs/unused.c
        $(E) "  CC $<"
        $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
 
+zap.o: $(top_srcdir)/debugfs/zap.c
+       $(E) "  CC $<"
+       $(Q) $(CC) $(ALL_CFLAGS) -c $< -o $@
+
 e2freefrag.o: $(top_srcdir)/misc/e2freefrag.c
        $(E) "  CC $<"
        $(Q) $(CC) $(ALL_CFLAGS) -DDEBUGFS -I$(top_srcdir)/debugfs -c $< -o $@
index 3a18d76..b944c27 100644 (file)
@@ -18,7 +18,7 @@
 #include <errno.h>
 
 #include "ext2_fs.h"
-#include "ext2fs.h"
+#include "ext2fsP.h"
 
 #if defined(__GNUC__) && !defined(NO_INLINE_FUNCS)
 #define _BMAP_INLINE_  __inline__
index 4cb7ca1..3f6ea50 100644 (file)
@@ -393,10 +393,11 @@ int ext2fs_dblist_count(ext2_dblist dblist)
 errcode_t ext2fs_dblist_get_last(ext2_dblist dblist,
                                 struct ext2_db_entry **entry)
 {
-       EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
        static struct ext2_db_entry ret_entry;
        struct ext2_db_entry2 *last;
 
+       EXT2_CHECK_MAGIC(dblist, EXT2_ET_MAGIC_DBLIST);
+
        if (dblist->count == 0)
                return EXT2_ET_DBLIST_EMPTY;
 
index 5125d19..589af69 100644 (file)
@@ -151,16 +151,16 @@ static int xlate_func(ext2_ino_t dir EXT2FS_ATTR((unused)),
        return (*xl->func)(dirent, offset, blocksize, buf, xl->real_private);
 }
 
-extern errcode_t ext2fs_dir_iterate(ext2_filsys fs,
-                             ext2_ino_t dir,
-                             int flags,
-                             char *block_buf,
-                             int (*func)(struct ext2_dir_entry *dirent,
-                                         int   offset,
-                                         int   blocksize,
-                                         char  *buf,
-                                         void  *priv_data),
-                             void *priv_data)
+errcode_t ext2fs_dir_iterate(ext2_filsys fs,
+                            ext2_ino_t dir,
+                            int flags,
+                            char *block_buf,
+                            int (*func)(struct ext2_dir_entry *dirent,
+                                        int    offset,
+                                        int    blocksize,
+                                        char   *buf,
+                                        void   *priv_data),
+                            void *priv_data)
 {
        struct xlate xl;
 
index f3ee49d..5cdc2e4 100644 (file)
@@ -160,7 +160,7 @@ errcode_t ext2fs_extent_header_verify(void *ptr, int size)
 /*
  * Begin functions to handle an inode's extent information
  */
-extern void ext2fs_extent_free(ext2_extent_handle_t handle)
+void ext2fs_extent_free(ext2_extent_handle_t handle)
 {
        int                     i;
 
@@ -177,13 +177,13 @@ extern void ext2fs_extent_free(ext2_extent_handle_t handle)
        ext2fs_free_mem(&handle);
 }
 
-extern errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
+errcode_t ext2fs_extent_open(ext2_filsys fs, ext2_ino_t ino,
                                    ext2_extent_handle_t *ret_handle)
 {
        return ext2fs_extent_open2(fs, ino, NULL, ret_handle);
 }
 
-extern errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
+errcode_t ext2fs_extent_open2(ext2_filsys fs, ext2_ino_t ino,
                                    struct ext2_inode *inode,
                                    ext2_extent_handle_t *ret_handle)
 {
index 7732804..5a39c32 100644 (file)
@@ -395,7 +395,8 @@ ext2_off_t ext2fs_file_get_size(ext2_file_t file)
 }
 
 /* Zero the parts of the last block that are past EOF. */
-errcode_t ext2fs_file_zero_past_offset(ext2_file_t file, ext2_off64_t offset)
+static errcode_t ext2fs_file_zero_past_offset(ext2_file_t file,
+                                             ext2_off64_t offset)
 {
        ext2_filsys fs = file->fs;
        char *b = NULL;
index fb266d1..e4c7dcc 100644 (file)
@@ -127,7 +127,7 @@ errcode_t ext2fs_mmp_write(ext2_filsys fs, blk64_t mmp_blk, void *buf)
 #define rand()         random()
 #endif
 
-unsigned ext2fs_mmp_new_seq()
+unsigned ext2fs_mmp_new_seq(void)
 {
        unsigned new_seq;
        struct timeval tv;
index 9fff704..25d7953 100644 (file)
@@ -410,10 +410,10 @@ errout:
  * Deallocate all logical blocks starting at start to end, inclusive.
  * If end is ~0, then this is effectively truncate.
  */
-extern errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
-                             struct ext2_inode *inode,
-                             char *block_buf, blk64_t start,
-                             blk64_t end)
+errcode_t ext2fs_punch(ext2_filsys fs, ext2_ino_t ino,
+                      struct ext2_inode *inode,
+                      char *block_buf, blk64_t start,
+                      blk64_t end)
 {
        errcode_t               retval;
        struct ext2_inode       inode_buf;
index 781ba82..8d345a9 100644 (file)
@@ -20,8 +20,7 @@
 
 #include <stdarg.h>
 
-char * ss_name(sci_idx)
-    int sci_idx;
+char *ss_name(int sci_idx)
 {
     register char *ret_val;
     register ss_data *infop;
@@ -70,10 +69,7 @@ void ss_error (int sci_idx, long code, const char * fmt, ...)
     va_end(pvar);
 }
 
-void ss_perror (sci_idx, code, msg) /* for compatibility */
-    int sci_idx;
-    long code;
-    char const *msg;
+void ss_perror(int sci_idx, long code, char const *msg) /* for compatibility */
 {
     ss_error (sci_idx, code, "%s", msg);
 }
index 53c10c9..d443a46 100644 (file)
@@ -82,11 +82,8 @@ static struct _ss_request_entry * get_request (tbl, idx)
  * Notes:
  */
 
-static int check_request_table (rqtbl, argc, argv, sci_idx)
-    register ss_request_table *rqtbl;
-    int argc;
-    char *argv[];
-    int sci_idx;
+static int check_request_table(register ss_request_table *rqtbl, int argc,
+                              char *argv[], int sci_idx)
 {
 #ifdef __SABER__
     struct _ss_request_entry *request;
@@ -135,10 +132,7 @@ static int check_request_table (rqtbl, argc, argv, sci_idx)
  * Notes:
  */
 
-static int really_execute_command (sci_idx, argc, argv)
-    int sci_idx;
-    int argc;
-    char **argv[];
+static int really_execute_command(int sci_idx, int argc, char **argv[])
 {
     register ss_request_table **rqtbl;
     register ss_data *info;
@@ -168,9 +162,7 @@ static int really_execute_command (sci_idx, argc, argv)
  * Notes:
  */
 
-int ss_execute_command(sci_idx, argv)
-       int sci_idx;
-       register char *argv[];
+int ss_execute_command(int sci_idx, register char *argv[])
 {
        register int i, argc;
        char **argp;
@@ -202,9 +194,7 @@ int ss_execute_command(sci_idx, argv)
  * Notes:
  */
 
-int ss_execute_line (sci_idx, line_ptr)
-    int sci_idx;
-    char *line_ptr;
+int ss_execute_line(int sci_idx, char *line_ptr)
 {
     char **argv;
     int argc, ret;
index 5278c95..5204401 100644 (file)
@@ -36,11 +36,7 @@ extern int errno;
 #endif
 #include "ss_internal.h"
 
-void ss_help (argc, argv, sci_idx, info_ptr)
-    int argc;
-    char const * const *argv;
-    int sci_idx;
-    pointer info_ptr;
+void ss_help(int argc, char const * const *argv, int sci_idx, pointer info_ptr)
 {
     char *buffer;
     char const *request_name;
@@ -117,7 +113,7 @@ void ss_help (argc, argv, sci_idx, info_ptr)
        ss_page_stdin();
     default:
        (void) close(fd); /* what can we do if it fails? */
-       while (wait(0) != child) {
+       while (wait(NULL) != child) {
            /* do nothing if wrong pid */
        };
     }
@@ -129,10 +125,7 @@ void ss_help (argc, argv, sci_idx, info_ptr)
 #include <dirent.h>
 #endif
 
-void ss_add_info_dir(sci_idx, info_dir, code_ptr)
-    int sci_idx;
-    char *info_dir;
-    int *code_ptr;
+void ss_add_info_dir(int sci_idx, char *info_dir, int *code_ptr)
 {
     register ss_data *info;
     DIR *d;
@@ -166,10 +159,7 @@ void ss_add_info_dir(sci_idx, info_dir, code_ptr)
     *code_ptr = 0;
 }
 
-void ss_delete_info_dir(sci_idx, info_dir, code_ptr)
-    int sci_idx;
-    char *info_dir;
-    int *code_ptr;
+void ss_delete_info_dir(int sci_idx, char *info_dir, int *code_ptr)
 {
     register char **i_d;
     register char **info_dirs;
index 08b66f2..61c2e35 100644 (file)
 #endif
 #include <errno.h>
 
-int ss_create_invocation(subsystem_name, version_string, info_ptr,
-                        request_table_ptr, code_ptr)
-       const char *subsystem_name, *version_string;
-       void *info_ptr;
-       ss_request_table *request_table_ptr;
-       int *code_ptr;
+int ss_create_invocation(const char *subsystem_name, const char *version_string,
+                        void *info_ptr, ss_request_table *request_table_ptr,
+                        int *code_ptr)
 {
        register int sci_idx;
        register ss_data *new_table;
@@ -90,8 +87,7 @@ int ss_create_invocation(subsystem_name, version_string, info_ptr,
 }
 
 void
-ss_delete_invocation(sci_idx)
-       int sci_idx;
+ss_delete_invocation(int sci_idx)
 {
        register ss_data *t;
        int ignored_code;
index 8b54dd1..330249e 100644 (file)
@@ -42,7 +42,6 @@ extern int errno;
 #endif
 
 static char MORE[] = "more";
-extern char *_ss_pager_name;
 extern char *getenv PROTOTYPE((const char *));
 
 char *ss_safe_getenv(const char *arg)
@@ -131,7 +130,7 @@ static int write_all(int fd, char *buf, size_t count)
        return c;
 }
 
-void ss_page_stdin()
+void ss_page_stdin(void)
 {
        int i;
        sigset_t mask;
index baded66..e2928e2 100644 (file)
@@ -43,10 +43,7 @@ enum parse_mode { WHITESPACE, TOKEN, QUOTED_STRING };
 #define NEW_ARGV(old,n) (char **)realloc((char *)old,\
                                         (unsigned)(n+2)*sizeof(char*))
 
-char **ss_parse (sci_idx, line_ptr, argc_ptr)
-    int sci_idx;
-    register char *line_ptr;
-    int *argc_ptr;
+char **ss_parse(int sci_idx, register char *line_ptr, int *argc_ptr)
 {
     register char **argv, *cp;
     register int argc;
index efdabfa..135cb28 100644 (file)
 
 #define ssrt ss_request_table  /* for some readable code... */
 
-void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
-       int sci_idx;
-       ssrt *rqtbl_ptr;
-       int position;           /* 1 -> becomes second... */
-       int *code_ptr;
+void ss_add_request_table(int sci_idx, ssrt *rqtbl_ptr, int position, int *code_ptr)
 {
        register ss_data *info;
        register int i, size;
@@ -53,10 +49,7 @@ void ss_add_request_table(sci_idx, rqtbl_ptr, position, code_ptr)
        *code_ptr = 0;
 }
 
-void ss_delete_request_table(sci_idx, rqtbl_ptr, code_ptr)
-     int sci_idx;
-     ssrt *rqtbl_ptr;
-     int *code_ptr;
+void ss_delete_request_table(int sci_idx, ssrt *rqtbl_ptr, int *code_ptr)
 {
      register ss_data *info;
      register ssrt **rt1, **rt2;
index 15d618e..19a6be7 100644 (file)
@@ -94,6 +94,7 @@ char **ss_rl_completion(const char *text, int start, int end);
 
 extern ss_data **_ss_table;
 extern char *ss_et_msgs[];
+extern char *_ss_pager_name;
 
 #ifdef USE_SIGPROCMASK
 /* fake sigmask, sigblock, sigsetmask */
index 89f2439..912ef28 100644 (file)
 #define _GNU_SOURCE /* for O_DIRECT */
 #endif
 
-#ifndef O_LARGEFILE
-#define O_LARGEFILE 0
-#endif
-
 #include "config.h"
 #include <errno.h>
 #include <fcntl.h>
@@ -65,8 +61,12 @@ extern int optind;
 #include "ext2fs/ext2fs.h"
 #include "nls-enable.h"
 
-const char * program_name = "badblocks";
-const char * done_string = N_("done                                                 \n");
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
+static const char * program_name = "badblocks";
+static const char * done_string = N_("done                                                 \n");
 
 static int v_flag;                     /* verbose */
 static int w_flag;                     /* do r/w test: 0=no, 1=yes,
@@ -84,7 +84,7 @@ static struct timeval time_start;
 
 #define T_INC 32
 
-unsigned int sys_page_size = 4096;
+static unsigned int sys_page_size = 4096;
 
 static void usage(void)
 {
index b4b313a..cb59f41 100644 (file)
@@ -45,10 +45,10 @@ extern int optind;
 
 #define in_use(m, x)   (ext2fs_test_bit ((x), (m)))
 
-const char * program_name = "dumpe2fs";
-char * device_name = NULL;
-int hex_format = 0;
-int blocks64 = 0;
+static const char * program_name = "dumpe2fs";
+static char * device_name = NULL;
+static int hex_format = 0;
+static int blocks64 = 0;
 
 static void usage(void)
 {
index 257cbcd..4fb9a96 100644 (file)
@@ -50,10 +50,10 @@ extern int optind;
 #define QCOW_OFLAG_COPIED     (1LL << 63)
 
 
-const char * program_name = "e2image";
-char * device_name = NULL;
-char all_data;
-char output_is_blk;
+static const char * program_name = "e2image";
+static char * device_name = NULL;
+static char all_data;
+static char output_is_blk;
 /* writing to blk device: don't skip zeroed blocks */
 
 static void lseek_error_and_exit(int errnum)
@@ -224,9 +224,9 @@ static void write_image_file(ext2_filsys fs, int fd)
 /*
  * These set of functions are used to write a RAW image file.
  */
-ext2fs_block_bitmap meta_block_map;
-ext2fs_block_bitmap scramble_block_map;        /* Directory blocks to be scrambled */
-blk64_t meta_blocks_count;
+static ext2fs_block_bitmap meta_block_map;
+static ext2fs_block_bitmap scramble_block_map; /* Directory blocks to be scrambled */
+static blk64_t meta_blocks_count;
 
 struct process_block_struct {
        ext2_ino_t      ino;
@@ -419,7 +419,7 @@ static void write_block(int fd, char *buf, int sparse_offset,
        generic_write(fd, buf, blocksize, block);
 }
 
-int name_id[256];
+static int name_id[256];
 
 #define EXT4_MAX_REC_LEN               ((1<<16)-1)
 
index aa97557..765716d 100644 (file)
@@ -39,8 +39,8 @@ extern char *optarg;
 #include "../version.h"
 #include "nls-enable.h"
 
-const char * program_name = "e2initrd_helper";
-char * device_name;
+static const char * program_name = "e2initrd_helper";
+static char * device_name;
 static int open_flag;
 static int root_type;
 static blkid_cache cache = NULL;
index a7402b3..a43c26f 100644 (file)
 #include "ext2fs/ext2fs.h"
 #include "nls-enable.h"
 
-unsigned char mtime_key[] = "filesystem MTIME";
-unsigned char uuid_key[] = "filesystem UUID";
-unsigned char blksize_key[] = "filesystem BLKSIZE";
+static unsigned char mtime_key[] = "filesystem MTIME";
+static unsigned char uuid_key[] = "filesystem UUID";
+static unsigned char blksize_key[] = "filesystem BLKSIZE";
 
-char *prg_name;
+static char *prg_name;
 
 static void usage(void)
 {
index 07d56d9..c6a5f0d 100644 (file)
@@ -164,23 +164,23 @@ struct frag_statistic_ino {
        char msg_buffer[PATH_MAX + 1];  /* pathname of the file */
 };
 
-char   lost_found_dir[PATH_MAX + 1];
-int    block_size;
-int    extents_before_defrag;
-int    extents_after_defrag;
-int    mode_flag;
-unsigned int   current_uid;
-unsigned int   defraged_file_count;
-unsigned int   frag_files_before_defrag;
-unsigned int   frag_files_after_defrag;
-unsigned int   regular_count;
-unsigned int   succeed_cnt;
-unsigned int   total_count;
-__u8 log_groups_per_flex;
-__u32 blocks_per_group;
-__u32 feature_incompat;
-ext4_fsblk_t   files_block_count;
-struct frag_statistic_ino      frag_rank[SHOW_FRAG_FILES];
+static char    lost_found_dir[PATH_MAX + 1];
+static int     block_size;
+static int     extents_before_defrag;
+static int     extents_after_defrag;
+static int     mode_flag;
+static unsigned int    current_uid;
+static unsigned int    defraged_file_count;
+static unsigned int    frag_files_before_defrag;
+static unsigned int    frag_files_after_defrag;
+static unsigned int    regular_count;
+static unsigned int    succeed_cnt;
+static unsigned int    total_count;
+static __u8 log_groups_per_flex;
+static __u32 blocks_per_group;
+static __u32 feature_incompat;
+static ext4_fsblk_t    files_block_count;
+static struct frag_statistic_ino       frag_rank[SHOW_FRAG_FILES];
 
 
 /* Local definitions of some syscalls glibc may not yet have */
@@ -1865,12 +1865,13 @@ int main(int argc, char *argv[])
                }
 
                switch (arg_type) {
+                       int mount_dir_len = 0;
+
                case DIRNAME:
                        if (!(mode_flag & STATISTIC))
                                printf("ext4 defragmentation "
                                        "for directory(%s)\n", argv[i]);
 
-                       int mount_dir_len = 0;
                        mount_dir_len = strnlen(lost_found_dir, PATH_MAX);
 
                        strncat(lost_found_dir, "/lost+found",
index 19e0dfb..826aaeb 100644 (file)
@@ -97,32 +97,32 @@ static const char *really_wanted[] = {
 /*
  * Global variables for options
  */
-char *devices[MAX_DEVICES];
-char *args[MAX_ARGS];
-int num_devices, num_args;
-
-int verbose = 0;
-int doall = 0;
-int noexecute = 0;
-int serialize = 0;
-int skip_root = 0;
-int ignore_mounted = 0;
-int notitle = 0;
-int parallel_root = 0;
-int progress = 0;
-int progress_fd = 0;
-int force_all_parallel = 0;
-int num_running = 0;
-int max_running = 0;
-volatile int cancel_requested = 0;
-int kill_sent = 0;
-char *progname;
-char *fstype = NULL;
-struct fs_info *filesys_info = NULL, *filesys_last = NULL;
-struct fsck_instance *instance_list;
-const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
-char *fsck_path = 0;
-blkid_cache cache = NULL;
+static char *devices[MAX_DEVICES];
+static char *args[MAX_ARGS];
+static int num_devices, num_args;
+
+static int verbose = 0;
+static int doall = 0;
+static int noexecute = 0;
+static int serialize = 0;
+static int skip_root = 0;
+static int ignore_mounted = 0;
+static int notitle = 0;
+static int parallel_root = 0;
+static int progress = 0;
+static int progress_fd = 0;
+static int force_all_parallel = 0;
+static int num_running = 0;
+static int max_running = 0;
+static volatile int cancel_requested = 0;
+static int kill_sent = 0;
+static char *progname;
+static char *fstype = NULL;
+static struct fs_info *filesys_info = NULL, *filesys_last = NULL;
+static struct fsck_instance *instance_list;
+static const char *fsck_prefix_path = "/sbin:/sbin/fs.d:/sbin/fs:/etc/fs:/etc";
+static char *fsck_path = 0;
+static blkid_cache cache = NULL;
 
 static char *string_copy(const char *s)
 {
@@ -728,7 +728,7 @@ static void fsck_device(struct fs_info *fs, int interactive)
 /*
  * Deal with the fsck -t argument.
  */
-struct fs_type_compile {
+static struct fs_type_compile {
        char **list;
        int *type;
        int  negate;
index e783546..8612edf 100644 (file)
@@ -32,13 +32,13 @@ extern char *optarg;
 extern int optind;
 #endif
 
-int    outfd = -1;
-int    outbufsize = 0;
-void   *outbuf = 0;
-int    verbose = 0;
-int    do_skip = 0;
-int    skip_mode = 0;
-pid_t  child_pid = -1;
+static int     outfd = -1;
+static int     outbufsize = 0;
+static void    *outbuf = 0;
+static int     verbose = 0;
+static int     do_skip = 0;
+static int     skip_mode = 0;
+static pid_t   child_pid = -1;
 
 static void usage(char *progname)
 {
index b7b93b0..d5541ab 100644 (file)
@@ -76,40 +76,40 @@ extern int optind;
 extern int isatty(int);
 extern FILE *fpopen(const char *cmd, const char *mode);
 
-const char * program_name = "mke2fs";
-const char * device_name /* = NULL */;
+static const char * program_name = "mke2fs";
+static const char * device_name /* = NULL */;
 
 /* Command line options */
-int    cflag;
-int    verbose;
-int    quiet;
-int    super_only;
-int    discard = 1;    /* attempt to discard device before fs creation */
-int    direct_io;
-int    force;
-int    noaction;
-uid_t  root_uid;
-gid_t  root_gid;
+static int     cflag;
+static int     verbose;
+static int     quiet;
+static int     super_only;
+static int     discard = 1;    /* attempt to discard device before fs creation */
+static int     direct_io;
+static int     force;
+static int     noaction;
+static uid_t   root_uid;
+static gid_t   root_gid;
 int    journal_size;
 int    journal_flags;
-int    lazy_itable_init;
-char   *bad_blocks_filename = NULL;
-__u32  fs_stride;
-int    quotatype = -1;  /* Initialize both user and group quotas by default */
-
-struct ext2_super_block fs_param;
-char *fs_uuid = NULL;
-char *creator_os;
-char *volume_label;
-char *mount_dir;
+static int     lazy_itable_init;
+static char    *bad_blocks_filename = NULL;
+static __u32   fs_stride;
+static int     quotatype = -1;  /* Initialize both user and group quotas by default */
+
+static struct ext2_super_block fs_param;
+static char *fs_uuid = NULL;
+static char *creator_os;
+static char *volume_label;
+static char *mount_dir;
 char *journal_device;
-int sync_kludge;       /* Set using the MKE2FS_SYNC env. option */
-char **fs_types;
+static int sync_kludge;        /* Set using the MKE2FS_SYNC env. option */
+static char **fs_types;
 
-profile_t      profile;
+static profile_t       profile;
 
-int sys_page_size = 4096;
-int linux_version_code = 0;
+static int sys_page_size = 4096;
+static int linux_version_code = 0;
 
 static void usage(void)
 {
index 6f3954f..2b7abff 100644 (file)
@@ -36,7 +36,8 @@ extern int optind;
 
 #include "../version.h"
 
-char *program_name, *device_name, *io_options;
+char *program_name;
+static char *device_name, *io_options;
 
 static void usage (char *prog)
 {
index 80193de..c4c2517 100644 (file)
@@ -73,7 +73,7 @@ static errcode_t mark_table_blocks(ext2_filsys fs,
 #define GE_CLSTR(x, y) (B2C(x) >= B2C(y))
 #define GT_CLSTR(x, y) (B2C(x) >  B2C(y))
 
-int lazy_itable_init;
+static int lazy_itable_init;
 
 /*
  * This is the top-level routine which does the dirty deed....
@@ -1353,7 +1353,7 @@ errout:
  * take special care when mapping a source block number to its
  * destination block number.
  */
-__u64 extent_translate(ext2_filsys fs, ext2_extent extent, __u64 old_loc)
+static __u64 extent_translate(ext2_filsys fs, ext2_extent extent, __u64 old_loc)
 {
        __u64 new_block = C2B(ext2fs_extent_translate(extent, B2C(old_loc)));
 
index 52319b5..7aeab91 100644 (file)
@@ -160,6 +160,9 @@ extern void ext2fs_extent_dump(ext2_extent extent, FILE *out);
 extern errcode_t ext2fs_iterate_extent(ext2_extent extent, __u64 *old_loc,
                                       __u64 *new_loc, __u64 *size);
 
+/* main.c */
+extern char *program_name;
+
 /* online.c */
 extern errcode_t online_resize_fs(ext2_filsys fs, const char *mtpt,
                                  blk64_t *new_size, int flags);
index 8544b6d..20dd6f2 100644 (file)
@@ -30,7 +30,7 @@ struct subst_entry {
        struct subst_entry *next;
 };
 
-struct subst_entry *subst_table = 0;
+static struct subst_entry *subst_table = 0;
 
 static int add_subst(char *name, char *value)
 {