diff mbox series

btrfs: fix gcc-4.8 build warning

Message ID 20200429132743.1295615-1-arnd@arndb.de (mailing list archive)
State New, archived
Headers show
Series btrfs: fix gcc-4.8 build warning | expand

Commit Message

Arnd Bergmann April 29, 2020, 1:27 p.m. UTC
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")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/btrfs/backref.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Qu Wenruo April 29, 2020, 1:32 p.m. UTC | #1
On 2020/4/29 下午9:27, Arnd Bergmann wrote:
> 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")

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

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu

> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  fs/btrfs/backref.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
> index 60a69f7c0b36..ac3c34f47b56 100644
> --- a/fs/btrfs/backref.c
> +++ b/fs/btrfs/backref.c
> @@ -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;
>
David Sterba April 29, 2020, 11:48 p.m. UTC | #2
On Wed, Apr 29, 2020 at 03:27:32PM +0200, Arnd Bergmann wrote:
> 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")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Added to devel queue, thanks.
diff mbox series

Patch

diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c
index 60a69f7c0b36..ac3c34f47b56 100644
--- a/fs/btrfs/backref.c
+++ b/fs/btrfs/backref.c
@@ -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;