]> git.openfabrics.org - ~emulex/infiniband.git/commitdiff
reiserfs: fix warnings with gcc 4.4
authorJeff Mahoney <jeffm@jeffreymahoney.com>
Wed, 17 Jun 2009 23:26:29 +0000 (16:26 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 18 Jun 2009 20:03:46 +0000 (13:03 -0700)
Several code paths in reiserfs have a construct like:

 if (is_direntry_le_ih(ih = B_N_PITEM_HEAD(src, item_num))) ...

which, in addition to being ugly, end up causing compiler warnings with
gcc 4.4.0.  Previous compilers didn't issue a warning.

fs/reiserfs/do_balan.c:1273: warning: operation on `aux_ih' may be undefined
fs/reiserfs/lbalance.c:393: warning: operation on `ih' may be undefined
fs/reiserfs/lbalance.c:421: warning: operation on `ih' may be undefined
fs/reiserfs/lbalance.c:777: warning: operation on `ih' may be undefined

I believe this is due to the ih being passed to macros which evaluate the
argument more than once.  This is old code and we haven't seen any
problems with it, but this patch eliminates the warnings.

It converts the multiple evaluation macros to static inlines and does a
preassignment for the cases that were causing the warnings because that
code is just ugly.

Reported-by: Chris Mason <mason@oracle.com>
Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/reiserfs/do_balan.c
fs/reiserfs/lbalance.c
include/linux/reiserfs_fs.h

index 4beb964a2a3e602d4fc1723597d9ad5b669ff1c0..128d3f7c8aa5a56a9ca6ad38487034dbdcaf9b92 100644 (file)
@@ -1270,9 +1270,8 @@ static int balance_leaf(struct tree_balance *tb, struct item_head *ih,    /* item h
 
                                        RFALSE(ih, "PAP-12210: ih must be 0");
 
-                                       if (is_direntry_le_ih
-                                           (aux_ih =
-                                            B_N_PITEM_HEAD(tbS0, item_pos))) {
+                                       aux_ih = B_N_PITEM_HEAD(tbS0, item_pos);
+                                       if (is_direntry_le_ih(aux_ih)) {
                                                /* we append to directory item */
 
                                                int entry_count;
index 381750a155f62d544ac6286896e314b43b5404ac..03d85cbf90bf644e40ef046c606c0dff61d99506 100644 (file)
@@ -390,7 +390,8 @@ static void leaf_item_bottle(struct buffer_info *dest_bi,
 
        if (last_first == FIRST_TO_LAST) {
                /* if ( if item in position item_num in buffer SOURCE is directory item ) */
-               if (is_direntry_le_ih(ih = B_N_PITEM_HEAD(src, item_num)))
+               ih = B_N_PITEM_HEAD(src, item_num);
+               if (is_direntry_le_ih(ih))
                        leaf_copy_dir_entries(dest_bi, src, FIRST_TO_LAST,
                                              item_num, 0, cpy_bytes);
                else {
@@ -418,7 +419,8 @@ static void leaf_item_bottle(struct buffer_info *dest_bi,
                }
        } else {
                /*  if ( if item in position item_num in buffer SOURCE is directory item ) */
-               if (is_direntry_le_ih(ih = B_N_PITEM_HEAD(src, item_num)))
+               ih = B_N_PITEM_HEAD(src, item_num);
+               if (is_direntry_le_ih(ih))
                        leaf_copy_dir_entries(dest_bi, src, LAST_TO_FIRST,
                                              item_num,
                                              I_ENTRY_COUNT(ih) - cpy_bytes,
@@ -774,8 +776,8 @@ void leaf_delete_items(struct buffer_info *cur_bi, int last_first,
                        leaf_delete_items_entirely(cur_bi, first + 1,
                                                   del_num - 1);
 
-                       if (is_direntry_le_ih
-                           (ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1)))
+                       ih = B_N_PITEM_HEAD(bh, B_NR_ITEMS(bh) - 1);
+                       if (is_direntry_le_ih(ih))
                                /* the last item is directory  */
                                /* len = numbers of directory entries in this item */
                                len = ih_entry_count(ih);
index 2245c78d5876e7035519d65cc487855b1be778b9..dd31e7bae35cd606943ca4f52bc585c42a9a65f7 100644 (file)
@@ -660,23 +660,54 @@ static inline void set_le_key_k_type(int version, struct reiserfs_key *key,
                   cpu_to_le32(type2uniqueness(type)))
            : (void)(set_offset_v2_k_type(&(key->u.k_offset_v2), type));
 }
+
 static inline void set_le_ih_k_type(struct item_head *ih, int type)
 {
        set_le_key_k_type(ih_version(ih), &(ih->ih_key), type);
 }
 
-#define is_direntry_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRENTRY)
-#define is_direct_le_key(version,key) (le_key_k_type (version, key) == TYPE_DIRECT)
-#define is_indirect_le_key(version,key) (le_key_k_type (version, key) == TYPE_INDIRECT)
-#define is_statdata_le_key(version,key) (le_key_k_type (version, key) == TYPE_STAT_DATA)
+static inline int is_direntry_le_key(int version, struct reiserfs_key *key)
+{
+       return le_key_k_type(version, key) == TYPE_DIRENTRY;
+}
+
+static inline int is_direct_le_key(int version, struct reiserfs_key *key)
+{
+       return le_key_k_type(version, key) == TYPE_DIRECT;
+}
+
+static inline int is_indirect_le_key(int version, struct reiserfs_key *key)
+{
+       return le_key_k_type(version, key) == TYPE_INDIRECT;
+}
+
+static inline int is_statdata_le_key(int version, struct reiserfs_key *key)
+{
+       return le_key_k_type(version, key) == TYPE_STAT_DATA;
+}
 
 //
 // item header has version.
 //
-#define is_direntry_le_ih(ih) is_direntry_le_key (ih_version (ih), &((ih)->ih_key))
-#define is_direct_le_ih(ih) is_direct_le_key (ih_version (ih), &((ih)->ih_key))
-#define is_indirect_le_ih(ih) is_indirect_le_key (ih_version(ih), &((ih)->ih_key))
-#define is_statdata_le_ih(ih) is_statdata_le_key (ih_version (ih), &((ih)->ih_key))
+static inline int is_direntry_le_ih(struct item_head *ih)
+{
+       return is_direntry_le_key(ih_version(ih), &ih->ih_key);
+}
+
+static inline int is_direct_le_ih(struct item_head *ih)
+{
+       return is_direct_le_key(ih_version(ih), &ih->ih_key);
+}
+
+static inline int is_indirect_le_ih(struct item_head *ih)
+{
+       return is_indirect_le_key(ih_version(ih), &ih->ih_key);
+}
+
+static inline int is_statdata_le_ih(struct item_head *ih)
+{
+       return is_statdata_le_key(ih_version(ih), &ih->ih_key);
+}
 
 //
 // key is pointer to cpu key, result is cpu