Whamcloud - gitweb
Fix misc. gcc -Wall complaints in the misc and e2fsck directories
authorTheodore Ts'o <tytso@mit.edu>
Wed, 15 Nov 2006 04:38:17 +0000 (23:38 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 15 Nov 2006 04:38:17 +0000 (23:38 -0500)
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
12 files changed:
e2fsck/ChangeLog
e2fsck/journal.c
e2fsck/message.c
e2fsck/pass1.c
e2fsck/pass2.c
e2fsck/profile.c
e2fsck/super.c
e2fsck/unix.c
misc/ChangeLog
misc/chattr.c
misc/filefrag.c
misc/mke2fs.c

index 24288fe..0ab7830 100644 (file)
@@ -1,3 +1,16 @@
+2006-11-14  Theodore Tso  <tytso@mit.edu>
+
+       * unix.c (PRS): Always allocate the replacement PATH environment
+               passed to putenv() to avoid gcc -Wall warning.
+
+       * pass1.c, pass2.c, profile.c, super.c: Remove unused variables
+               and fixed signed vs unsigned and const gcc -Wall warning.
+
+       * message.c (expand_inode_expression): Fix const gcc -Wall warning.
+
+       * journal.c (e2fsck_fix_ext3_journal_hint): Remove unusued
+               variables retval and problem.
+
 2006-11-11  Theodore Tso  <tytso@mit.edu>
 
        * super.c (e2fsck_fix_dirhash_hint, check_super_block): If neither
index 0cb14d3..34a7382 100644 (file)
@@ -971,8 +971,6 @@ int e2fsck_fix_ext3_journal_hint(e2fsck_t ctx)
        struct problem_context pctx;
        char uuid[37], *journal_name;
        struct stat st;
-       problem_t problem;
-       int retval;
 
        if (!(sb->s_feature_compat & EXT3_FEATURE_COMPAT_HAS_JOURNAL) ||
            uuid_is_null(sb->s_journal_uuid))
index f031b7e..268620a 100644 (file)
@@ -241,7 +241,7 @@ static _INLINE_ void expand_inode_expression(char ch,
 {
        struct ext2_inode       *inode;
        struct ext2_inode_large *large_inode;
-       char *                  time_str;
+       const char *            time_str;
        time_t                  t;
        int                     do_gmt = -1;
 
index 9650fe1..57a6b5a 100644 (file)
@@ -246,8 +246,8 @@ static void check_ea_in_inode(e2fsck_t ctx, struct problem_context *pctx)
        struct ext2_super_block *sb = ctx->fs->super;
        struct ext2_inode_large *inode;
        struct ext2_ext_attr_entry *entry;
-       char *start, *end, *name;
-       int storage_size, remain, offs;
+       char *start, *end;
+       unsigned int storage_size, remain, offs;
        int problem = 0;
 
        inode = (struct ext2_inode_large *) pctx->inode;
@@ -327,7 +327,7 @@ fix:
 
        /* simple remove all possible EA(s) */
        *((__u32 *)start) = 0UL;
-       e2fsck_write_inode_full(ctx, pctx->ino, inode,
+       e2fsck_write_inode_full(ctx, pctx->ino, (struct ext2_inode *) inode,
                                EXT2_INODE_SIZE(sb), "pass1");
 }
 
@@ -865,7 +865,6 @@ void e2fsck_pass1(e2fsck_t ctx)
 
        if (ctx->flags & E2F_FLAG_RESIZE_INODE) {
                ext2fs_block_bitmap save_bmap;
-               errcode_t retval;
 
                save_bmap = fs->block_map;
                fs->block_map = ctx->block_found_map;
index 6dc5e5f..e581099 100644 (file)
@@ -645,7 +645,7 @@ static void salvage_directory(ext2_filsys fs,
 {
        char    *cp = (char *) dirent;
        int left = fs->blocksize - *offset - dirent->rec_len;
-       int name_len = dirent->name_len & 0xFF;
+       unsigned int name_len = dirent->name_len & 0xFF;
 
        /*
         * Special case of directory entry of size 8: copy what's left
@@ -662,7 +662,7 @@ static void salvage_directory(ext2_filsys fs,
         * record length.
         */
        if ((left < 0) &&
-           (name_len + 8 <= dirent->rec_len + left) &&
+           (name_len + 8 <= dirent->rec_len + (unsigned) left) &&
            dirent->inode <= fs->super->s_inodes_count &&
            strnlen(dirent->name, name_len) == name_len) {
                dirent->rec_len += left;
index f50cb53..e7768a2 100644 (file)
@@ -136,8 +136,8 @@ struct profile_node {
        char *name;
        char *value;
        int group_level;
-       int final:1;            /* Indicate don't search next file */
-       int deleted:1;
+       unsigned int final:1;           /* Indicate don't search next file */
+       unsigned int deleted:1;
        struct profile_node *first_child;
        struct profile_node *parent;
        struct profile_node *next, *prev;
@@ -217,8 +217,8 @@ static errcode_t profile_get_value(profile_t profile, const char *name,
 
 static int compstr(const void *m1, const void *m2) 
 {
-       const char *s1 = *((const char **) m1);
-       const char *s2 = *((const char **) m2);
+       const char *s1 = *((const char * const *) m1);
+       const char *s2 = *((const char * const *) m2);
 
        return strcmp(s1, s2); 
 }
index 62e03a5..8d4f069 100644 (file)
@@ -318,12 +318,13 @@ return_abort:
  * resize inode should be cleared) as well as the case where on-line
  * resizing is enabled.
  */
-void check_resize_inode(e2fsck_t ctx)
+static void check_resize_inode(e2fsck_t ctx)
 {
        ext2_filsys fs = ctx->fs;
        struct ext2_inode inode;
        struct problem_context  pctx;
-       int             i, j, gdt_off, ind_off;
+       int             i, gdt_off, ind_off;
+       dgrp_t          j;
        blk_t           blk, pblk, expect;
        __u32           *dind_buf = 0, *ind_buf;
        errcode_t       retval;
@@ -439,12 +440,10 @@ cleanup:
 /*
  * This function checks the dirhash signed/unsigned hint if necessary.
  */
-void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
+static void e2fsck_fix_dirhash_hint(e2fsck_t ctx)
 {
        struct ext2_super_block *sb = ctx->fs->super;
        struct problem_context pctx;
-       problem_t problem;
-       int retval;
        char    c;
 
        if ((ctx->options & E2F_OPT_READONLY) ||
@@ -737,14 +736,14 @@ void check_super_block(e2fsck_t ctx)
         * Check to see if the superblock last mount time or last
         * write time is in the future.
         */
-       if (fs->super->s_mtime > ctx->now) {
+       if (fs->super->s_mtime > (__u32) ctx->now) {
                pctx.num = fs->super->s_mtime;
                if (fix_problem(ctx, PR_0_FUTURE_SB_LAST_MOUNT, &pctx)) {
                        fs->super->s_mtime = ctx->now;
                        ext2fs_mark_super_dirty(fs);
                }
        }
-       if (fs->super->s_wtime > ctx->now) {
+       if (fs->super->s_wtime > (__u32) ctx->now) {
                pctx.num = fs->super->s_wtime;
                if (fix_problem(ctx, PR_0_FUTURE_SB_LAST_WRITE, &pctx)) {
                        fs->super->s_wtime = ctx->now;
index 7a617cf..4f4c506 100644 (file)
@@ -810,19 +810,22 @@ static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
        /* Update our PATH to include /sbin if we need to run badblocks  */
        if (cflag) {
                char *oldpath = getenv("PATH");
+               char *newpath;
+               int len = sizeof(PATH_SET) + 1;
+
+               if (oldpath)
+                       len += strlen(oldpath);
+
+               newpath = malloc(len);
+               if (!newpath)
+                       fatal_error(ctx, "Couldn't malloc() newpath");
+               strcpy(newpath, PATH_SET);
+
                if (oldpath) {
-                       char *newpath;
-
-                       newpath = (char *) malloc(sizeof (PATH_SET) + 1 +
-                                                 strlen (oldpath));
-                       if (!newpath)
-                               fatal_error(ctx, "Couldn't malloc() newpath");
-                       strcpy (newpath, PATH_SET);
-                       strcat (newpath, ":");
-                       strcat (newpath, oldpath);
-                       putenv (newpath);
-               } else
-                       putenv (PATH_SET);
+                       strcat(newpath, ":");
+                       strcat(newpath, oldpath);
+               }
+               putenv(newpath);
        }
 #ifdef CONFIG_JBD_DEBUG
        if (getenv("E2FSCK_JBD_DEBUG"))
index 583a477..de52b1d 100644 (file)
@@ -1,3 +1,14 @@
+2006-11-14  Theodore Tso  <tytso@mit.edu>
+
+       * mke2fs.c (PRS): Always allocate the replacement PATH environment
+               passed to putenv() to avoid gcc -Wall warning.  Fix signed
+               vs unsigned warning.
+
+       * filefrag.c: Fix signed vs. unsigned gcc -Wall warning
+
+       * chattr.c (usage, fatal_error): Rework functions to avoid gcc
+               -Wall complaints.
+
 2006-11-12  Theodore Tso  <tytso@mit.edu>
 
        * dumpe2fs.c (main): Open filesystems with the SOFTSUPP flag, to
index 0b800ef..c6d8d9f 100644 (file)
@@ -78,15 +78,14 @@ static unsigned long sf;
 #define STRUCT_STAT    struct stat
 #endif
 
-static void fatal_error(const char * fmt_string, int errcode)
+static void usage(void)
 {
-       fprintf (stderr, fmt_string, program_name);
-       exit (errcode);
+       fprintf(stderr, 
+               _("Usage: %s [-RV] [-+=AacDdijsSu] [-v version] files...\n"),
+               program_name);
+       exit(1);
 }
 
-#define usage() fatal_error(_("Usage: %s [-RV] [-+=AacDdijsSu] [-v version] files...\n"), \
-                            1)
-
 struct flags_char {
        unsigned long   flag;
        char            optchar;
@@ -251,9 +250,11 @@ static int chattr_dir_proc (const char * dir_name, struct dirent * de,
                char *path;
 
                path = malloc(strlen (dir_name) + 1 + strlen (de->d_name) + 1);
-               if (!path)
-                       fatal_error(_("Couldn't allocate path variable "
-                                   "in chattr_dir_proc"), 1);
+               if (!path) {
+                       fprintf(stderr, _("Couldn't allocate path variable "
+                                         "in chattr_dir_proc"));
+                       exit(1);
+               }
                sprintf (path, "%s/%s", dir_name, de->d_name);
                change_attributes (path);
                free(path);
index df90060..e625d4c 100644 (file)
@@ -82,8 +82,8 @@ static void frag_report(const char *filename)
        struct stat     fileinfo;
 #endif
        int             bs;
-       long            i, fd;
-       unsigned long   block, last_block = 0, numblocks;
+       long            fd;
+       unsigned long   block, last_block = 0, numblocks, i;
        long            bpib;   /* Blocks per indirect block */
        long            cylgroups;
        int             discont = 0, expected;
index 64e1a47..80a40ac 100644 (file)
@@ -914,18 +914,20 @@ static void PRS(int argc, char *argv[])
        int             s_opt = -1, r_opt = -1;
        char            *fs_features = 0;
        int             use_bsize;
+       char            *newpath;
+       int             pathlen = sizeof(PATH_SET) + 1;
+
+       if (oldpath)
+               pathlen += strlen(oldpath);
+       newpath = malloc(pathlen);
+       strcpy(newpath, PATH_SET);
 
        /* Update our PATH to include /sbin  */
        if (oldpath) {
-               char *newpath;
-               
-               newpath = malloc(sizeof (PATH_SET) + 1 + strlen (oldpath));
-               strcpy (newpath, PATH_SET);
                strcat (newpath, ":");
                strcat (newpath, oldpath);
-               putenv (newpath);
-       } else
-               putenv (PATH_SET);
+       }
+       putenv (newpath);
 
        tmp = getenv("MKE2FS_SYNC");
        if (tmp)
@@ -1417,7 +1419,7 @@ static void PRS(int argc, char *argv[])
                }
        }
 
-       if (!force && fs_param.s_blocks_count >= (1 << 31)) {
+       if (!force && fs_param.s_blocks_count >= ((unsigned) 1 << 31)) {
                com_err(program_name, 0,
                        _("Filesystem too large.  No more than 2**31-1 blocks\n"
                          "\t (8TB using a blocksize of 4k) are currently supported."));