]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxfs: fix compile warnings
authorDave Chinner <dchinner@redhat.com>
Wed, 4 Sep 2013 22:05:17 +0000 (22:05 +0000)
committerRich Johnston <rjohnston@sgi.com>
Mon, 16 Sep 2013 20:14:41 +0000 (15:14 -0500)
Some of the code shared with userspace causes compilation warnings
from things turned off in the kernel code, such as differences in
variable signedness. Fix those issues.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Review-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Rich Johnston <rjohnston@sgi.com>
12 files changed:
copy/xfs_copy.c
db/bmroot.c
libxfs/xfs.h
libxfs/xfs_attr_remote.c
libxfs/xfs_bmap.c
libxfs/xfs_da_btree.c
libxfs/xfs_dir2_node.c
libxfs/xfs_ialloc.c
libxfs/xfs_rtalloc.c
repair/attr_repair.c
repair/incore_ino.c
repair/scan.c

index 39517da73f315aa44988abc3b6b714877493f8f4..bb37279a61a81df43df0f84f5f34b7c3c79f7341 100644 (file)
@@ -434,6 +434,10 @@ read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
        off = XFS_AG_DADDR(mp, agno, XFS_SB_DADDR);
        buf->position = (xfs_off_t) off * (xfs_off_t) BBSIZE;
        length = buf->length = first_agbno * blocksize;
+       if (length == 0) {
+               do_log(_("ag header buffer invalid!\n"));
+               exit(1);
+       }
 
        /* handle alignment stuff */
 
@@ -449,7 +453,6 @@ read_ag_header(int fd, xfs_agnumber_t agno, wbuf *buf, ag_header_t *ag,
        if (buf->length % buf->min_io_size != 0)
                buf->length = roundup(buf->length, buf->min_io_size);
 
-       ASSERT(length != 0);
        read_wbuf(fd, buf, mp);
        ASSERT(buf->length >= length);
 
@@ -936,7 +939,12 @@ main(int argc, char **argv)
                for (;;) {
                        /* none of this touches the w_buf buffer */
 
-                       ASSERT(current_level < btree_levels);
+                       if (current_level >= btree_levels) {
+                               do_log(
+                       _("Error: current level %d >= btree levels %d\n"),
+                                       current_level, btree_levels);
+                               exit(1);
+                       }
 
                        current_level++;
 
index 3e18917a66f660dfa6a63b8df0d1193b9aaa019f..12b129ebb86e3997e6c26cd5bdbb409dc324f477 100644 (file)
@@ -91,13 +91,13 @@ bmroota_key_offset(
        int                     idx)
 {
        xfs_bmdr_block_t        *block;
-       /* REFERENCED */
-       xfs_dinode_t            *dip;
+#ifdef DEBUG
+       xfs_dinode_t            *dip = obj;
+#endif
        xfs_bmdr_key_t          *kp;
 
        ASSERT(bitoffs(startoff) == 0);
        ASSERT(obj == iocur_top->data);
-       dip = obj;
        block = (xfs_bmdr_block_t *)((char *)obj + byteize(startoff));
        ASSERT(XFS_DFORK_Q(dip) && (char *)block == XFS_DFORK_APTR(dip));
        ASSERT(be16_to_cpu(block->bb_level) > 0);
index 3fd226c4b382685e204dabfcf3f7d022f4a1ac4f..c9d6a6da7ebfdee939ed2483641ce5d2629b107a 100644 (file)
@@ -189,7 +189,9 @@ roundup_pow_of_two(uint v)
 /* avoid gcc warning */
 #define xfs_incore(bt,blkno,len,lockit)        ({              \
        typeof(blkno) __foo = (blkno);                  \
+       typeof(len) __bar = (len);                      \
        (blkno) = __foo;                                \
+       (len) = __bar; /* no set-but-unused warning */  \
        NULL;                                           \
 })
 #define xfs_buf_relse(bp)              libxfs_putbuf(bp)
@@ -259,7 +261,11 @@ roundup_pow_of_two(uint v)
 #define        xfs_trans_agblocks_delta(tp, d)
 #define        xfs_trans_agflist_delta(tp, d)
 #define        xfs_trans_agbtree_delta(tp, d)
-#define xfs_trans_buf_set_type(tp, bp, t)
+#define xfs_trans_buf_set_type(tp, bp, t)      ({      \
+       int __t = (t);                                  \
+       __t = __t; /* no set-but-unused warning */      \
+})
+
 #define xfs_trans_buf_copy_type(dbp, sbp)
 
 #define xfs_buf_readahead(a,b,c,ops)           ((void) 0)      /* no readahead */
index 0b2ca8c40b85b0c3dfd28ecb4fd13df7ef929272..59bb12d9f787cc2bfb5f00b953a0af8b4f3a7434 100644 (file)
@@ -214,7 +214,7 @@ xfs_attr_rmtval_copyout(
        xfs_ino_t       ino,
        int             *offset,
        int             *valuelen,
-       char            **dst)
+       __uint8_t       **dst)
 {
        char            *src = bp->b_addr;
        xfs_daddr_t     bno = bp->b_bn;
@@ -261,7 +261,7 @@ xfs_attr_rmtval_copyin(
        xfs_ino_t       ino,
        int             *offset,
        int             *valuelen,
-       char            **src)
+       __uint8_t       **src)
 {
        char            *dst = bp->b_addr;
        xfs_daddr_t     bno = bp->b_bn;
@@ -314,7 +314,7 @@ xfs_attr_rmtval_get(
        struct xfs_mount        *mp = args->dp->i_mount;
        struct xfs_buf          *bp;
        xfs_dablk_t             lblkno = args->rmtblkno;
-       char                    *dst = args->value;
+       __uint8_t               *dst = args->value;
        int                     valuelen = args->valuelen;
        int                     nmap;
        int                     error;
@@ -378,7 +378,7 @@ xfs_attr_rmtval_set(
        struct xfs_bmbt_irec    map;
        xfs_dablk_t             lblkno;
        xfs_fileoff_t           lfileoff = 0;
-       char                    *src = args->value;
+       __uint8_t               *src = args->value;
        int                     blkcnt;
        int                     valuelen;
        int                     nmap;
index 6664265b320dc33ec27646fee95aba2af579e1e7..b7f798b599c4501bf30e4992d8c770948c774ca2 100644 (file)
@@ -4437,12 +4437,9 @@ xfs_bmapi_allocate(
        struct xfs_ifork        *ifp = XFS_IFORK_PTR(bma->ip, whichfork);
        int                     tmp_logflags = 0;
        int                     error;
-       int                     rt;
 
        ASSERT(bma->length > 0);
 
-       rt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(bma->ip);
-
        /*
         * For the wasdelay case, we could also just allocate the stuff asked
         * for in this bmap call but that wouldn't be as good.
index d7798af088732abc7daeb6389ca0d319d80868a7..b7b670509a8e7912602a2c9ef392f4aeb0677f37 100644 (file)
@@ -376,7 +376,7 @@ xfs_da3_split(
        struct xfs_da_intnode   *node;
        struct xfs_buf          *bp;
        int                     max;
-       int                     action;
+       int                     action = 0;
        int                     error;
        int                     i;
 
@@ -2431,9 +2431,9 @@ static int
 xfs_buf_map_from_irec(
        struct xfs_mount        *mp,
        struct xfs_buf_map      **mapp,
-       unsigned int            *nmaps,
+       int                     *nmaps,
        struct xfs_bmbt_irec    *irecs,
-       unsigned int            nirecs)
+       int                     nirecs)
 {
        struct xfs_buf_map      *map;
        int                     i;
index fea0131c389feaf42f8352d701e6bdb1e2269e47..030f6207e84673ebde7743418e799566b4704ffa 100644 (file)
@@ -295,11 +295,13 @@ xfs_dir2_free_log_header(
        struct xfs_trans        *tp,
        struct xfs_buf          *bp)
 {
+#ifdef DEBUG
        xfs_dir2_free_t         *free;          /* freespace structure */
 
        free = bp->b_addr;
        ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
               free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
+#endif
        xfs_trans_log_buf(tp, bp, 0, xfs_dir3_free_hdr_size(tp->t_mountp) - 1);
 }
 
index 98513fdf9f6aea5f854404c070b045caaa4bb6e7..4683287b4803650b8dbd61fe0fac090418df3b40 100644 (file)
@@ -1319,7 +1319,7 @@ xfs_imap(
        xfs_agblock_t   cluster_agbno;  /* first block in inode cluster */
        int             error;  /* error code */
        int             offset; /* index of inode in its buffer */
-       int             offset_agbno;   /* blks from chunk start to inode */
+       xfs_agblock_t   offset_agbno;   /* blks from chunk start to inode */
 
        ASSERT(ino != NULLFSINO);
 
index 1de85fd2c530fb00a7126b8e33b9fbe8d67917cc..9797db7fa00fe64c8a418717ba7bea18c60d62a0 100644 (file)
@@ -431,8 +431,8 @@ xfs_rtfree_range(
 {
        xfs_rtblock_t   end;            /* end of the freed extent */
        int             error;          /* error value */
-       xfs_rtblock_t   postblock;      /* first block freed > end */
-       xfs_rtblock_t   preblock;       /* first block freed < start */
+       xfs_rtblock_t   postblock = 0;  /* first block freed > end */
+       xfs_rtblock_t   preblock = 0;   /* first block freed < start */
 
        end = start + len - 1;
        /*
index d42b85f08f95a61fdeb3cd7837dcd4ecc7eece40..ba85fd9a44e8911a5f3e81b9985c13c67000ee40 100644 (file)
@@ -1631,9 +1631,11 @@ process_attributes(
 {
        int             err;
        __u8            aformat = dip->di_aformat;
+#ifdef DEBUG
        xfs_attr_shortform_t *asf;
 
        asf = (xfs_attr_shortform_t *) XFS_DFORK_APTR(dip);
+#endif
 
        if (aformat == XFS_DINODE_FMT_LOCAL) {
                ASSERT(be16_to_cpu(asf->hdr.totsize) <=
index efffe753852e8b1fb38680e736115194536628ee..735737a06b4f8357aea5e6408574db4281ab0197 100644 (file)
@@ -167,6 +167,7 @@ __uint32_t num_inode_references(struct ino_tree_node *irec, int ino_offset)
        default:
                ASSERT(0);
        }
+       return 0;
 }
 
 void set_inode_disk_nlinks(struct ino_tree_node *irec, int ino_offset,
@@ -207,6 +208,7 @@ __uint32_t get_inode_disk_nlinks(struct ino_tree_node *irec, int ino_offset)
        default:
                ASSERT(0);
        }
+       return 0;
 }
 
 /*
index 07880e45d062fda5395a8603ab5070ae66a98e12..4f8bbef74d0f5733a7acb315aa59f56396c72b4c 100644 (file)
@@ -520,6 +520,7 @@ scan_allocbt(
                name = "cnt";
                break;
        default:
+               name = "(unknown)";
                assert(0);
                break;
        }