Skip to contentSkip to conversation

btrfs: fix gcc-4.8 build warning

PATCH In review Arnd Bergmann 3 participants 3 messages Apr 29, 2020 Btrfs file system

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 btrfs: fix gcc-4.8 build warning

Some older compilers like gcc-4.8 warn about mismatched curly braces in a initializer:

fs/btrfs/backref.c: In function 'is_shared_data_backref':
fs/btrfs/backref.c:394:9: error: missing braces around initializer [-Werror=missing-braces]

  struct prelim_ref target = {0};
         ^

fs/btrfs/backref.c:394:9: error: (near initialization for 'target.rbnode') [-Werror=missing-braces]

Use the GNU empty initializer extension to avoid this.

Fixes ed58f2e66e84 ("btrfs: backref, don't add refs from shared block when resolving normal backref")
---
 fs/btrfs/backref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/backref.c +1 -1
index 60a69f7c0b36..ac3c34f47b56 100644
@@ -392,7 +392,7 @@ static int is_shared_data_backref(struct preftrees *preftrees, u64 bytenr)
 	struct rb_node **p = &preftrees->direct.root.rb_root.rb_node;
 	struct rb_node *parent = NULL;
 	struct prelim_ref *ref = NULL;
-	struct prelim_ref target = {0};
+	struct prelim_ref target = {};
 	int result;
 
 	target.parent = bytenr;
Signature · 1 line
2.26.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Arnd Bergmann

Some older compilers like gcc-4.8 warn about mismatched curly braces in a initializer:

fs/btrfs/backref.c: In function 'is_shared_data_backref':
fs/btrfs/backref.c:394:9: error: missing braces around initializer [-Werror=missing-braces]

Quoted 8 lines
  struct prelim_ref target = {0};
         ^

fs/btrfs/backref.c:394:9: error: (near initialization for 'target.rbnode') [-Werror=missing-braces]

Use the GNU empty initializer extension to avoid this.

Fixes ed58f2e66e84 ("btrfs: backref, don't add refs from shared block when resolving normal backref")

OK, at least this fix is mentioning it's older gcc causing problem, and the fix using GNU extension is also clear.

Thanks,
Qu

Quoted 19 lines
---
 fs/btrfs/backref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/btrfs/backref.c +1 -1
index 60a69f7c0b36..ac3c34f47b56 100644
@@ -392,7 +392,7 @@ static int is_shared_data_backref(struct preftrees *preftrees, u64 bytenr)
 	struct rb_node **p = &preftrees->direct.root.rb_root.rb_node;
 	struct rb_node *parent = NULL;
 	struct prelim_ref *ref = NULL;
-	struct prelim_ref target = {0};
+	struct prelim_ref target = {};
 	int result;
 
 	target.parent = bytenr;
#2 lore raw
In reply to Arnd Bergmann
Quoted 8 lines · Arnd Bergmann

Some older compilers like gcc-4.8 warn about mismatched curly braces in a initializer:

fs/btrfs/backref.c: In function 'is_shared_data_backref':
fs/btrfs/backref.c:394:9: error: missing braces around initializer [-Werror=missing-braces]

  struct prelim_ref target = {0};
         ^
Quoted 7 lines

fs/btrfs/backref.c:394:9: error: (near initialization for 'target.rbnode') [-Werror=missing-braces]

Use the GNU empty initializer extension to avoid this.

Fixes ed58f2e66e84 ("btrfs: backref, don't add refs from shared block when resolving normal backref")

Added to devel queue, thanks.