summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-12-16 18:56:36 -0500
committerTheodore Ts'o <tytso@mit.edu>2013-12-16 18:56:36 -0500
commitf404167dda29a59d2be2882328aeb074b9899669 (patch)
tree6ee643255b5b9a9b7680bef1ec61f74f3d9da77f
parent4727c67dc20f0c15cc8502b9bc3ee9f73d7e2c3a (diff)
downloade2fsprogs-f404167dda29a59d2be2882328aeb074b9899669.tar.gz
Clean up sparse warnings
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>
-rw-r--r--debugfs/debugfs.h3
-rw-r--r--debugfs/extent_inode.c4
-rw-r--r--debugfs/logdump.c8
-rw-r--r--debugfs/util.c2
-rw-r--r--e2fsck/dirinfo.c6
-rw-r--r--e2fsck/e2fsck.c2
-rw-r--r--e2fsck/pass1.c4
-rw-r--r--e2fsck/pass2.c4
-rw-r--r--e2fsck/unix.c4
-rw-r--r--e2fsck/util.c10
-rw-r--r--lib/et/com_err.c5
-rw-r--r--lib/et/error_message.c3
-rw-r--r--lib/et/error_table.h2
-rw-r--r--lib/et/et_name.c3
-rw-r--r--lib/ext2fs/Makefile.in6
-rw-r--r--lib/ext2fs/bmap.c2
-rw-r--r--lib/ext2fs/dblist.c3
-rw-r--r--lib/ext2fs/dir_iterate.c20
-rw-r--r--lib/ext2fs/extent.c6
-rw-r--r--lib/ext2fs/fileio.c3
-rw-r--r--lib/ext2fs/mmp.c2
-rw-r--r--lib/ext2fs/punch.c8
-rw-r--r--lib/ss/error.c8
-rw-r--r--lib/ss/execute_cmd.c20
-rw-r--r--lib/ss/help.c18
-rw-r--r--lib/ss/invocation.c12
-rw-r--r--lib/ss/pager.c3
-rw-r--r--lib/ss/parse.c5
-rw-r--r--lib/ss/request_tbl.c11
-rw-r--r--lib/ss/ss_internal.h1
-rw-r--r--misc/badblocks.c14
-rw-r--r--misc/dumpe2fs.c8
-rw-r--r--misc/e2image.c16
-rw-r--r--misc/e2initrd_helper.c4
-rw-r--r--misc/e2undo.c8
-rw-r--r--misc/e4defrag.c37
-rw-r--r--misc/fsck.c54
-rw-r--r--misc/logsave.c14
-rw-r--r--misc/mke2fs.c54
-rw-r--r--resize/main.c3
-rw-r--r--resize/resize2fs.c4
-rw-r--r--resize/resize2fs.h3
-rw-r--r--util/subst.c2
43 files changed, 191 insertions, 218 deletions
diff --git a/debugfs/debugfs.h b/debugfs/debugfs.h
index 45175cf9..6b4f6ef1 100644
--- a/debugfs/debugfs.h
+++ b/debugfs/debugfs.h
@@ -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);
diff --git a/debugfs/extent_inode.c b/debugfs/extent_inode.c
index 75e328c6..b3c55f91 100644
--- a/debugfs/extent_inode.c
+++ b/debugfs/extent_inode.c
@@ -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)
{
diff --git a/debugfs/logdump.c b/debugfs/logdump.c
index a61d5532..66a5428d 100644
--- a/debugfs/logdump.c
+++ b/debugfs/logdump.c
@@ -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
{
diff --git a/debugfs/util.c b/debugfs/util.c
index 09088e07..aafbc567 100644
--- a/debugfs/util.c
+++ b/debugfs/util.c
@@ -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;
diff --git a/e2fsck/dirinfo.c b/e2fsck/dirinfo.c
index c81777a5..dc08f90a 100644
--- a/e2fsck/dirinfo.c
+++ b/e2fsck/dirinfo.c
@@ -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);
diff --git a/e2fsck/e2fsck.c b/e2fsck/e2fsck.c
index 994f80e8..0ec15404 100644
--- a/e2fsck/e2fsck.c
+++ b/e2fsck/e2fsck.c
@@ -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 };
diff --git a/e2fsck/pass1.c b/e2fsck/pass1.c
index a8237af9..71b3000a 100644
--- a/e2fsck/pass1.c
+++ b/e2fsck/pass1.c
@@ -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;
diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c
index b7268e34..7277a7b3 100644
--- a/e2fsck/pass2.c
+++ b/e2fsck/pass2.c
@@ -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;
diff --git a/e2fsck/unix.c b/e2fsck/unix.c
index 10f0628f..6f94644e 100644
--- a/e2fsck/unix.c
+++ b/e2fsck/unix.c
@@ -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;
diff --git a/e2fsck/util.c b/e2fsck/util.c
index eb3e0f45..9f920b2c 100644
--- a/e2fsck/util.c
+++ b/e2fsck/util.c
@@ -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;
diff --git a/lib/et/com_err.c b/lib/et/com_err.c
index 4ea52def..d38998a2 100644
--- a/lib/et/com_err.c
+++ b/lib/et/com_err.c
@@ -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;
diff --git a/lib/et/error_message.c b/lib/et/error_message.c
index 92509e63..5d8d2422 100644
--- a/lib/et/error_message.c
+++ b/lib/et/error_message.c
@@ -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;
diff --git a/lib/et/error_table.h b/lib/et/error_table.h
index 4f109911..24e4762a 100644
--- a/lib/et/error_table.h
+++ b/lib/et/error_table.h
@@ -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 */
diff --git a/lib/et/et_name.c b/lib/et/et_name.c
index 6b59eddb..d9a3e874 100644
--- a/lib/et/et_name.c
+++ b/lib/et/et_name.c
@@ -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;
diff --git a/lib/ext2fs/Makefile.in b/lib/ext2fs/Makefile.in
index abe21247..87678c6a 100644
--- a/lib/ext2fs/Makefile.in
+++ b/lib/ext2fs/Makefile.in
@@ -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 $@
diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c
index 3a18d760..b944c273 100644
--- a/lib/ext2fs/bmap.c
+++ b/lib/ext2fs/bmap.c
@@ -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__
diff --git a/lib/ext2fs/dblist.c b/lib/ext2fs/dblist.c
index 4cb7ca18..3f6ea50d 100644
--- a/lib/ext2fs/dblist.c
+++ b/lib/ext2fs/dblist.c
@@ -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;
diff --git a/lib/ext2fs/dir_iterate.c b/lib/ext2fs/dir_iterate.c
index 5125d199..589af692 100644
--- a/lib/ext2fs/dir_iterate.c
+++ b/lib/ext2fs/dir_iterate.c
@@ -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;
diff --git a/lib/ext2fs/extent.c b/lib/ext2fs/extent.c
index f3ee49d6..5cdc2e49 100644
--- a/lib/ext2fs/extent.c
+++ b/lib/ext2fs/extent.c
@@ -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)
{
diff --git a/lib/ext2fs/fileio.c b/lib/ext2fs/fileio.c
index 77328042..5a39c321 100644
--- a/lib/ext2fs/fileio.c
+++ b/lib/ext2fs/fileio.c
@@ -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;
diff --git a/lib/ext2fs/mmp.c b/lib/ext2fs/mmp.c
index fb266d1d..e4c7dccd 100644
--- a/lib/ext2fs/mmp.c
+++ b/lib/ext2fs/mmp.c
@@ -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;
diff --git a/lib/ext2fs/punch.c b/lib/ext2fs/punch.c
index 9fff7048..25d79532 100644
--- a/lib/ext2fs/punch.c
+++ b/lib/ext2fs/punch.c
@@ -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;
diff --git a/lib/ss/error.c b/lib/ss/error.c
index 781ba82d..8d345a9f 100644
--- a/lib/ss/error.c
+++ b/lib/ss/error.c
@@ -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);
}
diff --git a/lib/ss/execute_cmd.c b/lib/ss/execute_cmd.c
index 53c10c9c..d443a468 100644
--- a/lib/ss/execute_cmd.c
+++ b/lib/ss/execute_cmd.c
@@ -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;
diff --git a/lib/ss/help.c b/lib/ss/help.c
index 5278c953..5204401b 100644
--- a/lib/ss/help.c
+++ b/lib/ss/help.c
@@ -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;
diff --git a/lib/ss/invocation.c b/lib/ss/invocation.c
index 08b66f28..61c2e350 100644
--- a/lib/ss/invocation.c
+++ b/lib/ss/invocation.c
@@ -22,12 +22,9 @@
#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;
diff --git a/lib/ss/pager.c b/lib/ss/pager.c
index 8b54dd1a..330249ec 100644
--- a/lib/ss/pager.c
+++ b/lib/ss/pager.c
@@ -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;
diff --git a/lib/ss/parse.c b/lib/ss/parse.c
index baded665..e2928e22 100644
--- a/lib/ss/parse.c
+++ b/lib/ss/parse.c
@@ -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;
diff --git a/lib/ss/request_tbl.c b/lib/ss/request_tbl.c
index efdabfa3..135cb28b 100644
--- a/lib/ss/request_tbl.c
+++ b/lib/ss/request_tbl.c
@@ -20,11 +20,7 @@
#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;
diff --git a/lib/ss/ss_internal.h b/lib/ss/ss_internal.h
index 15d618ee..19a6be7a 100644
--- a/lib/ss/ss_internal.h
+++ b/lib/ss/ss_internal.h
@@ -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 */
diff --git a/misc/badblocks.c b/misc/badblocks.c
index 89f24398..912ef286 100644
--- a/misc/badblocks.c
+++ b/misc/badblocks.c
@@ -33,10 +33,6 @@
#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)
{
diff --git a/misc/dumpe2fs.c b/misc/dumpe2fs.c
index b4b313a5..cb59f412 100644
--- a/misc/dumpe2fs.c
+++ b/misc/dumpe2fs.c
@@ -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)
{
diff --git a/misc/e2image.c b/misc/e2image.c
index 257cbcda..4fb9a969 100644
--- a/misc/e2image.c
+++ b/misc/e2image.c
@@ -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)
diff --git a/misc/e2initrd_helper.c b/misc/e2initrd_helper.c
index aa97557c..765716d6 100644
--- a/misc/e2initrd_helper.c
+++ b/misc/e2initrd_helper.c
@@ -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;
diff --git a/misc/e2undo.c b/misc/e2undo.c
index a7402b31..a43c26fd 100644
--- a/misc/e2undo.c
+++ b/misc/e2undo.c
@@ -24,11 +24,11 @@
#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)
{
diff --git a/misc/e4defrag.c b/misc/e4defrag.c
index 07d56d9f..c6a5f0da 100644
--- a/misc/e4defrag.c
+++ b/misc/e4defrag.c
@@ -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",
diff --git a/misc/fsck.c b/misc/fsck.c
index 19e0dfb1..826aaebb 100644
--- a/misc/fsck.c
+++ b/misc/fsck.c
@@ -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;
diff --git a/misc/logsave.c b/misc/logsave.c
index e783546d..8612edfb 100644
--- a/misc/logsave.c
+++ b/misc/logsave.c
@@ -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)
{
diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index b7b93b05..d5541abd 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -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)
{
diff --git a/resize/main.c b/resize/main.c
index 6f3954f9..2b7abff3 100644
--- a/resize/main.c
+++ b/resize/main.c
@@ -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)
{
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 80193deb..c4c25170 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -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)));
diff --git a/resize/resize2fs.h b/resize/resize2fs.h
index 52319b52..7aeab919 100644
--- a/resize/resize2fs.h
+++ b/resize/resize2fs.h
@@ -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);
diff --git a/util/subst.c b/util/subst.c
index 8544b6da..20dd6f21 100644
--- a/util/subst.c
+++ b/util/subst.c
@@ -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)
{