Thread (8 messages) 8 messages, 5 authors, 2021-09-20

Re: [PATCH] btrfs: fix initialiser warning in fs/btrfs/tree-checker.c

From: Qu Wenruo <hidden>
Date: 2021-09-19 22:45:21


On 2021/9/20 06:40, Russell King (Oracle) wrote:
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.
This should be a compiler bug.

= { 0 }; is completely fine here, in fact = { }; would be more problematic.

What's the compiler version? I haven't hit such problem for GCC 11.1.0
nor clang 12.0.1.

Thanks,
Qu
quoted hunk ↗ jump to hunk
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 = { };
  	const u64 valid_root_flags = BTRFS_ROOT_SUBVOL_RDONLY |
  				     BTRFS_ROOT_SUBVOL_DEAD;
  	int ret;
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help