Re: [PATCH] btrfs: fix initialiser warning in fs/btrfs/tree-checker.c
From: Qu Wenruo <hidden>
Date: 2021-09-20 08:25:42
On 2021/9/20 16:12, David Sterba wrote:
On Sun, Sep 19, 2021 at 11:40:39PM +0100, Russell King (Oracle) wrote:quoted
Debian gcc 10.2.1 complains thusly: fs/btrfs/tree-checker.c:1071:9: warning: missing braces around initializer [-Wmissing-braces] struct btrfs_root_item ri = { 0 }; ^ fs/btrfs/tree-checker.c:1071:9: warning: (near initialization for 'ri.inode') [-Wmissing-braces] Fix it by removing the unnecessary '0' initialiser, leaving the braces. Fixes: 1465af12e254 ("btrfs: tree-checker: fix false alert caused by legacy btrfs root item") Signed-off-by: Russell King (Oracle) <redacted> --- 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 a8b2e0d2c025..1737b62756a6 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c@@ -1068,7 +1068,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 = { };Kees Cook does a tree wide unification to { } because there are some oddities with partial initialization and { 0 } so this will get fixed eventually.
Does this mean in the future only "= { }" is preferred?
It would looks a little weird to me as C89/C90 doesn't allow this.
And I guess checkpatch would also be updated to handle that?
Thanks,
Qu
But again the minimum gcc version is now 5.1 so it won't matter for 4.9 anyway.