diff mbox series

ext2: fix empty body warnings when -Wextra is used

Message ID e18a7395-61fb-2093-18e8-ed4f8cf56248@infradead.org
State Not Applicable
Headers show
Series ext2: fix empty body warnings when -Wextra is used | expand

Commit Message

Randy Dunlap March 23, 2020, 2:45 a.m. UTC
From: Randy Dunlap <rdunlap@infradead.org>

When EXT2_ATTR_DEBUG is not defined, modify the 2 debug macros
to use the no_printk() macro instead of <nothing>.
This fixes gcc warnings when -Wextra is used:

../fs/ext2/xattr.c:252:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
../fs/ext2/xattr.c:258:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
../fs/ext2/xattr.c:330:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
../fs/ext2/xattr.c:872:45: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]

I have verified that the only object code change (with gcc 7.5.0) is
the reversal of some instructions from 'cmp a,b' to 'cmp b,a'.

Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jan Kara <jack@suse.com>
Cc: linux-ext4@vger.kernel.org
---
 fs/ext2/xattr.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Comments

kernel test robot March 23, 2020, 6:08 a.m. UTC | #1
Hi Randy,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on linus/master]
[also build test ERROR on v5.6-rc7]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Randy-Dunlap/ext2-fix-empty-body-warnings-when-Wextra-is-used/20200323-113040
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 16fbf79b0f83bc752cee8589279f1ebfe57b3b6e
config: h8300-randconfig-a001-20200322 (attached as .config)
compiler: h8300-linux-gcc (GCC) 9.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=9.2.0 make.cross ARCH=h8300 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/kernel.h:15,
                    from include/linux/list.h:9,
                    from include/linux/wait.h:7,
                    from include/linux/wait_bit.h:8,
                    from include/linux/fs.h:6,
                    from include/linux/buffer_head.h:12,
                    from fs/ext2/xattr.c:57:
   fs/ext2/xattr.c: In function 'ext2_xattr_cache_insert':
>> fs/ext2/xattr.c:869:18: error: 'ext2_xattr_cache' undeclared (first use in this function); did you mean 'ext2_xattr_list'?
     869 |     atomic_read(&ext2_xattr_cache->c_entry_count));
         |                  ^~~~~~~~~~~~~~~~
   include/linux/printk.h:137:17: note: in definition of macro 'no_printk'
     137 |   printk(fmt, ##__VA_ARGS__);  \
         |                 ^~~~~~~~~~~
>> fs/ext2/xattr.c:868:4: note: in expansion of macro 'ea_bdebug'
     868 |    ea_bdebug(bh, "already in cache (%d cache entries)",
         |    ^~~~~~~~~
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
     269 | #define READ_ONCE(x) __READ_ONCE(x, 1)
         |                      ^~~~~~~~~~~
   arch/h8300/include/asm/atomic.h:17:25: note: in expansion of macro 'READ_ONCE'
      17 | #define atomic_read(v)  READ_ONCE((v)->counter)
         |                         ^~~~~~~~~
>> fs/ext2/xattr.c:869:5: note: in expansion of macro 'atomic_read'
     869 |     atomic_read(&ext2_xattr_cache->c_entry_count));
         |     ^~~~~~~~~~~
   fs/ext2/xattr.c:869:18: note: each undeclared identifier is reported only once for each function it appears in
     869 |     atomic_read(&ext2_xattr_cache->c_entry_count));
         |                  ^~~~~~~~~~~~~~~~
   include/linux/printk.h:137:17: note: in definition of macro 'no_printk'
     137 |   printk(fmt, ##__VA_ARGS__);  \
         |                 ^~~~~~~~~~~
>> fs/ext2/xattr.c:868:4: note: in expansion of macro 'ea_bdebug'
     868 |    ea_bdebug(bh, "already in cache (%d cache entries)",
         |    ^~~~~~~~~
   include/linux/compiler.h:269:22: note: in expansion of macro '__READ_ONCE'
     269 | #define READ_ONCE(x) __READ_ONCE(x, 1)
         |                      ^~~~~~~~~~~
   arch/h8300/include/asm/atomic.h:17:25: note: in expansion of macro 'READ_ONCE'
      17 | #define atomic_read(v)  READ_ONCE((v)->counter)
         |                         ^~~~~~~~~
>> fs/ext2/xattr.c:869:5: note: in expansion of macro 'atomic_read'
     869 |     atomic_read(&ext2_xattr_cache->c_entry_count));
         |     ^~~~~~~~~~~

vim +869 fs/ext2/xattr.c

^1da177e4c3f41 Linus Torvalds 2005-04-16  849  
^1da177e4c3f41 Linus Torvalds 2005-04-16  850  /*
^1da177e4c3f41 Linus Torvalds 2005-04-16  851   * ext2_xattr_cache_insert()
^1da177e4c3f41 Linus Torvalds 2005-04-16  852   *
^1da177e4c3f41 Linus Torvalds 2005-04-16  853   * Create a new entry in the extended attribute cache, and insert
^1da177e4c3f41 Linus Torvalds 2005-04-16  854   * it unless such an entry is already in the cache.
^1da177e4c3f41 Linus Torvalds 2005-04-16  855   *
^1da177e4c3f41 Linus Torvalds 2005-04-16  856   * Returns 0, or a negative error number on failure.
^1da177e4c3f41 Linus Torvalds 2005-04-16  857   */
^1da177e4c3f41 Linus Torvalds 2005-04-16  858  static int
7a2508e1b657cf Jan Kara       2016-02-22  859  ext2_xattr_cache_insert(struct mb_cache *cache, struct buffer_head *bh)
^1da177e4c3f41 Linus Torvalds 2005-04-16  860  {
^1da177e4c3f41 Linus Torvalds 2005-04-16  861  	__u32 hash = le32_to_cpu(HDR(bh)->h_hash);
^1da177e4c3f41 Linus Torvalds 2005-04-16  862  	int error;
^1da177e4c3f41 Linus Torvalds 2005-04-16  863  
3e159b9553e402 Chengguang Xu  2018-11-15  864  	error = mb_cache_entry_create(cache, GFP_NOFS, hash, bh->b_blocknr,
3e159b9553e402 Chengguang Xu  2018-11-15  865  				      true);
^1da177e4c3f41 Linus Torvalds 2005-04-16  866  	if (error) {
^1da177e4c3f41 Linus Torvalds 2005-04-16  867  		if (error == -EBUSY) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 @868  			ea_bdebug(bh, "already in cache (%d cache entries)",
^1da177e4c3f41 Linus Torvalds 2005-04-16 @869  				atomic_read(&ext2_xattr_cache->c_entry_count));
^1da177e4c3f41 Linus Torvalds 2005-04-16  870  			error = 0;
^1da177e4c3f41 Linus Torvalds 2005-04-16  871  		}
be0726d33cb8f4 Jan Kara       2016-02-22  872  	} else
be0726d33cb8f4 Jan Kara       2016-02-22  873  		ea_bdebug(bh, "inserting [%x]", (int)hash);
^1da177e4c3f41 Linus Torvalds 2005-04-16  874  	return error;
^1da177e4c3f41 Linus Torvalds 2005-04-16  875  }
^1da177e4c3f41 Linus Torvalds 2005-04-16  876  

:::::: The code at line 869 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
Jan Kara March 23, 2020, 12:02 p.m. UTC | #2
On Sun 22-03-20 19:45:41, Randy Dunlap wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
> 
> When EXT2_ATTR_DEBUG is not defined, modify the 2 debug macros
> to use the no_printk() macro instead of <nothing>.
> This fixes gcc warnings when -Wextra is used:
> 
> ../fs/ext2/xattr.c:252:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
> ../fs/ext2/xattr.c:258:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
> ../fs/ext2/xattr.c:330:42: warning: suggest braces around empty body in an ‘if’ statement [-Wempty-body]
> ../fs/ext2/xattr.c:872:45: warning: suggest braces around empty body in an ‘else’ statement [-Wempty-body]
> 
> I have verified that the only object code change (with gcc 7.5.0) is
> the reversal of some instructions from 'cmp a,b' to 'cmp b,a'.
> 
> Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
> Cc: Jan Kara <jack@suse.com>
> Cc: linux-ext4@vger.kernel.org

Thanks! I've queued the patch to my tree.

								Honza

> ---
>  fs/ext2/xattr.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> --- linux-next-20200320.orig/fs/ext2/xattr.c
> +++ linux-next-20200320/fs/ext2/xattr.c
> @@ -56,6 +56,7 @@
>  
>  #include <linux/buffer_head.h>
>  #include <linux/init.h>
> +#include <linux/printk.h>
>  #include <linux/slab.h>
>  #include <linux/mbcache.h>
>  #include <linux/quotaops.h>
> @@ -84,8 +85,8 @@
>  		printk("\n"); \
>  	} while (0)
>  #else
> -# define ea_idebug(f...)
> -# define ea_bdebug(f...)
> +# define ea_idebug(inode, f...)	no_printk(f)
> +# define ea_bdebug(bh, f...)	no_printk(f)
>  #endif
>  
>  static int ext2_xattr_set2(struct inode *, struct buffer_head *,
>
diff mbox series

Patch

--- linux-next-20200320.orig/fs/ext2/xattr.c
+++ linux-next-20200320/fs/ext2/xattr.c
@@ -56,6 +56,7 @@ 
 
 #include <linux/buffer_head.h>
 #include <linux/init.h>
+#include <linux/printk.h>
 #include <linux/slab.h>
 #include <linux/mbcache.h>
 #include <linux/quotaops.h>
@@ -84,8 +85,8 @@ 
 		printk("\n"); \
 	} while (0)
 #else
-# define ea_idebug(f...)
-# define ea_bdebug(f...)
+# define ea_idebug(inode, f...)	no_printk(f)
+# define ea_bdebug(bh, f...)	no_printk(f)
 #endif
 
 static int ext2_xattr_set2(struct inode *, struct buffer_head *,