* [PATCH] fs: tree-checker: fix missing brace warning for old compilers
@ 2020-10-03 0:11 Pujin Shi
2020-10-03 1:04 ` Su Yue
2020-10-03 8:04 ` Nikolay Borisov
0 siblings, 2 replies; 3+ messages in thread
From: Pujin Shi @ 2020-10-03 0:11 UTC (permalink / raw)
To: Chris Mason, Josef Bacik, David Sterba
Cc: Qu Wenruo, linux-btrfs, linux-kernel, hankinsea, Pujin Shi
For older versions of gcc, the array = {0}; will cause warnings:
fs/btrfs/tree-checker.c: In function 'check_root_item':
fs/btrfs/tree-checker.c:1038:9: warning: missing braces around initializer [-Wmissing-braces]
struct btrfs_root_item ri = { 0 };
^
fs/btrfs/tree-checker.c:1038:9: warning: (near initialization for 'ri.inode') [-Wmissing-braces]
1 warnings generated
Fixes: 443b313c7ff8 ("btrfs: tree-checker: fix false alert caused by legacy btrfs root item")
Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
---
fs/btrfs/tree-checker.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index f0ffd5ee77bd..5028b3af308c 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -1035,7 +1035,7 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key,
int slot)
{
struct btrfs_fs_info *fs_info = leaf->fs_info;
- struct btrfs_root_item ri = { 0 };
+ struct btrfs_root_item ri = {};
const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY |
BTRFS_ROOT_SUBVOL_DEAD;
int ret;
--
2.18.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: tree-checker: fix missing brace warning for old compilers
2020-10-03 0:11 [PATCH] fs: tree-checker: fix missing brace warning for old compilers Pujin Shi
@ 2020-10-03 1:04 ` Su Yue
2020-10-03 8:04 ` Nikolay Borisov
1 sibling, 0 replies; 3+ messages in thread
From: Su Yue @ 2020-10-03 1:04 UTC (permalink / raw)
To: Pujin Shi
Cc: Chris Mason, Josef Bacik, David Sterba, Qu Wenruo, linux-btrfs,
linux-kernel, hankinsea
On Sat 03 Oct 2020 at 08:11, Pujin Shi <shipujin.t@gmail.com>
wrote:
> For older versions of gcc, the array = {0}; will cause warnings:
>
So what's the version number of the gcc? "struct foo = { 0 }"
should be
correct.
May be the compiler issue[1] related?
1: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=53119
> fs/btrfs/tree-checker.c: In function 'check_root_item':
> fs/btrfs/tree-checker.c:1038:9: warning: missing braces around
> initializer [-Wmissing-braces]
> struct btrfs_root_item ri = { 0 };
> ^
> fs/btrfs/tree-checker.c:1038:9: warning: (near initialization
> for 'ri.inode') [-Wmissing-braces]
>
> 1 warnings generated
>
> Fixes: 443b313c7ff8 ("btrfs: tree-checker: fix false alert
> caused by legacy btrfs root item")
> Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
> ---
> fs/btrfs/tree-checker.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index f0ffd5ee77bd..5028b3af308c 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -1035,7 +1035,7 @@ static int check_root_item(struct
> extent_buffer *leaf, struct btrfs_key *key,
> int slot)
> {
> struct btrfs_fs_info *fs_info = leaf->fs_info;
> - struct btrfs_root_item ri = { 0 };
> + struct btrfs_root_item ri = {};
> const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY |
> BTRFS_ROOT_SUBVOL_DEAD;
> int ret;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs: tree-checker: fix missing brace warning for old compilers
2020-10-03 0:11 [PATCH] fs: tree-checker: fix missing brace warning for old compilers Pujin Shi
2020-10-03 1:04 ` Su Yue
@ 2020-10-03 8:04 ` Nikolay Borisov
1 sibling, 0 replies; 3+ messages in thread
From: Nikolay Borisov @ 2020-10-03 8:04 UTC (permalink / raw)
To: Pujin Shi, Chris Mason, Josef Bacik, David Sterba
Cc: Qu Wenruo, linux-btrfs, linux-kernel, hankinsea
On 3.10.20 г. 3:11 ч., Pujin Shi wrote:
> For older versions of gcc, the array = {0}; will cause warnings:
>
> fs/btrfs/tree-checker.c: In function 'check_root_item':
> fs/btrfs/tree-checker.c:1038:9: warning: missing braces around initializer [-Wmissing-braces]
> struct btrfs_root_item ri = { 0 };
> ^
> fs/btrfs/tree-checker.c:1038:9: warning: (near initialization for 'ri.inode') [-Wmissing-braces]
>
> 1 warnings generated
>
> Fixes: 443b313c7ff8 ("btrfs: tree-checker: fix false alert caused by legacy btrfs root item")
> Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
This is a compiler artifact, please see:
http://www.ex-parrot.com/~chris/random/initialise.html
ALso having an empty initialization list like = {} while valid for gcc
is actually invalid according to the official standard. Check ISO C
Standard section 6.7.9 for the correct syntax of initializer-list.
IOW - NAK.
> ---
> fs/btrfs/tree-checker.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
> index f0ffd5ee77bd..5028b3af308c 100644
> --- a/fs/btrfs/tree-checker.c
> +++ b/fs/btrfs/tree-checker.c
> @@ -1035,7 +1035,7 @@ static int check_root_item(struct extent_buffer *leaf, struct btrfs_key *key,
> int slot)
> {
> struct btrfs_fs_info *fs_info = leaf->fs_info;
> - struct btrfs_root_item ri = { 0 };
> + struct btrfs_root_item ri = {};
> const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY |
> BTRFS_ROOT_SUBVOL_DEAD;
> int ret;
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-03 8:04 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-03 0:11 [PATCH] fs: tree-checker: fix missing brace warning for old compilers Pujin Shi
2020-10-03 1:04 ` Su Yue
2020-10-03 8:04 ` Nikolay Borisov
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).