* [PATCH 4.4 091/100] ext2: fix empty body warnings when -Wextra is used
[not found] <20200422095022.476101261@linuxfoundation.org>
@ 2020-04-22 9:57 ` Greg Kroah-Hartman
2020-04-25 11:43 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Greg Kroah-Hartman @ 2020-04-22 9:57 UTC (permalink / raw)
To: linux-kernel
Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Jan Kara, linux-ext4,
Jan Kara, Sasha Levin
From: Randy Dunlap <rdunlap@infradead.org>
[ Upstream commit 44a52022e7f15cbaab957df1c14f7a4f527ef7cf ]
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'.
Link: https://lore.kernel.org/r/e18a7395-61fb-2093-18e8-ed4f8cf56248@infradead.org
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Jan Kara <jack@suse.com>
Cc: linux-ext4@vger.kernel.org
Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
fs/ext2/xattr.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 22d817dc821e9..6f6f4f89a2f0c 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -55,6 +55,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>
@@ -85,8 +86,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 *,
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.4 091/100] ext2: fix empty body warnings when -Wextra is used
2020-04-22 9:57 ` [PATCH 4.4 091/100] ext2: fix empty body warnings when -Wextra is used Greg Kroah-Hartman
@ 2020-04-25 11:43 ` Joe Perches
2020-04-25 11:47 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2020-04-25 11:43 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel
Cc: stable, Randy Dunlap, Jan Kara, linux-ext4, Jan Kara, Sasha Levin
On Wed, 2020-04-22 at 11:57 +0200, Greg Kroah-Hartman wrote:
> From: Randy Dunlap <rdunlap@infradead.org>
>
> [ Upstream commit 44a52022e7f15cbaab957df1c14f7a4f527ef7cf ]
>
> 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'.
It'd be better to use the ext4 style defines:
fs/ext4/xattr.c:# define ea_idebug(inode, fmt, ...) \
fs/ext4/xattr.c- printk(KERN_DEBUG "inode %s:%lu: " fmt "\n", \
fs/ext4/xattr.c- inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
fs/ext4/xattr.c:# define ea_bdebug(bh, fmt, ...) \
fs/ext4/xattr.c- printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \
fs/ext4/xattr.c- bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
--
fs/ext4/xattr.c:# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
fs/ext4/xattr.c:# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
So the output logging won't be split across multiple lines.
> diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
[]
> @@ -55,6 +55,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>
> @@ -85,8 +86,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 *,
---
fs/ext2/xattr.c | 22 ++++++++--------------
1 file changed, 8 insertions(+), 14 deletions(-)
diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
index 943cc46..7740582 100644
--- a/fs/ext2/xattr.c
+++ b/fs/ext2/xattr.c
@@ -72,21 +72,15 @@
#define IS_LAST_ENTRY(entry) (*(__u32 *)(entry) == 0)
#ifdef EXT2_XATTR_DEBUG
-# define ea_idebug(inode, f...) do { \
- printk(KERN_DEBUG "inode %s:%ld: ", \
- inode->i_sb->s_id, inode->i_ino); \
- printk(f); \
- printk("\n"); \
- } while (0)
-# define ea_bdebug(bh, f...) do { \
- printk(KERN_DEBUG "block %pg:%lu: ", \
- bh->b_bdev, (unsigned long) bh->b_blocknr); \
- printk(f); \
- printk("\n"); \
- } while (0)
+# define ea_idebug(inode, fmt, ...) \
+ printk(KERN_DEBUG "inode %s:%lu: " fmt "\n", \
+ inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
+# define ea_bdebug(bh, fmt, ...) \
+ printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \
+ bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
#else
-# define ea_idebug(inode, f...) no_printk(f)
-# define ea_bdebug(bh, f...) no_printk(f)
+# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
+# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
#endif
static int ext2_xattr_set2(struct inode *, struct buffer_head *,
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.4 091/100] ext2: fix empty body warnings when -Wextra is used
2020-04-25 11:43 ` Joe Perches
@ 2020-04-25 11:47 ` Joe Perches
0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2020-04-25 11:47 UTC (permalink / raw)
To: Greg Kroah-Hartman, linux-kernel
Cc: stable, Randy Dunlap, Jan Kara, linux-ext4, Jan Kara, Sasha Levin
On Sat, 2020-04-25 at 04:43 -0700, Joe Perches wrote:
> On Wed, 2020-04-22 at 11:57 +0200, Greg Kroah-Hartman wrote:
> > From: Randy Dunlap <rdunlap@infradead.org>
> >
> > [ Upstream commit 44a52022e7f15cbaab957df1c14f7a4f527ef7cf ]
> >
> > 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'.
>
> It'd be better to use the ext4 style defines:
>
> fs/ext4/xattr.c:# define ea_idebug(inode, fmt, ...) \
> fs/ext4/xattr.c- printk(KERN_DEBUG "inode %s:%lu: " fmt "\n", \
> fs/ext4/xattr.c- inode->i_sb->s_id, inode->i_ino, ##__VA_ARGS__)
> fs/ext4/xattr.c:# define ea_bdebug(bh, fmt, ...) \
> fs/ext4/xattr.c- printk(KERN_DEBUG "block %pg:%lu: " fmt "\n", \
> fs/ext4/xattr.c- bh->b_bdev, (unsigned long)bh->b_blocknr, ##__VA_ARGS__)
> --
> fs/ext4/xattr.c:# define ea_idebug(inode, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
> fs/ext4/xattr.c:# define ea_bdebug(bh, fmt, ...) no_printk(fmt, ##__VA_ARGS__)
>
> So the output logging won't be split across multiple lines.
And beyond that, why is a -Wextra warning being fixed in -stable at all?
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-04-25 11:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20200422095022.476101261@linuxfoundation.org>
2020-04-22 9:57 ` [PATCH 4.4 091/100] ext2: fix empty body warnings when -Wextra is used Greg Kroah-Hartman
2020-04-25 11:43 ` Joe Perches
2020-04-25 11:47 ` Joe Perches
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).