Skip to contentSkip to conversation

ieee802154: fix gcc-4.9 warnings

PATCH In review Arnd Bergmann 4 participants 4 messages Sep 12, 2017

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ieee802154: fix gcc-4.9 warnings

All older compiler versions up to gcc-4.9 produce these harmless warnings:

drivers/net/ieee802154/ca8210.c: In function 'ca8210_skb_tx':
drivers/net/ieee802154/ca8210.c:1947:9: warning: missing braces around initializer [-Wmissing-braces]

This changes the syntax to something that works on all versions without warnings.

Fixes ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
---
 drivers/net/ieee802154/ca8210.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +1 -1
index 24a1eabbbc9d..e6b8ce81a6c3 100644
@@ -1944,7 +1944,7 @@ static int ca8210_skb_tx(
 )
 {
 	int status;
-	struct ieee802154_hdr header = { 0 };
+	struct ieee802154_hdr header = { };
 	struct secspec secspec;
 	unsigned int mac_len;
 
Signature · 1 line
2.9.0
Acked-by on v1 1/1
#1 lore raw

Hello.

Quoted 20 lines · Arnd Bergmann

All older compiler versions up to gcc-4.9 produce these harmless warnings:

drivers/net/ieee802154/ca8210.c: In function 'ca8210_skb_tx':
drivers/net/ieee802154/ca8210.c:1947:9: warning: missing braces around initializer [-Wmissing-braces]

This changes the syntax to something that works on all versions without warnings.

Fixes ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")
---
  drivers/net/ieee802154/ca8210.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ieee802154/ca8210.c +0 -0
index 24a1eabbbc9d..e6b8ce81a6c3 100644

drivers/net/ieee802154/ca8210.c static int ca8210_skb_tx( · line 1950

Quoted 8 lines
drivers/net/ieee802154/ca8210.c +1 -1
@@ -1944,7 +1944,7 @@ static int ca8210_skb_tx(
  )
  {
  	int status;
-	struct ieee802154_hdr header = { 0 };
+	struct ieee802154_hdr header = { };
  	struct secspec secspec;
  	unsigned int mac_len;
 

regards
Stefan Schmidt

#2 lore raw
In reply to Arnd Bergmann

Hi Arnd,

Quoted 6 lines

All older compiler versions up to gcc-4.9 produce these harmless warnings:

drivers/net/ieee802154/ca8210.c: In function 'ca8210_skb_tx':
drivers/net/ieee802154/ca8210.c:1947:9: warning: missing braces around initializer [-Wmissing-braces]

Quoted 8 lines

This changes the syntax to something that works on all versions without warnings.

Fixes ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")

---
drivers/net/ieee802154/ca8210.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

#3 lore raw
In reply to Arnd Bergmann
Quoted 10 lines · Arnd Bergmann

All older compiler versions up to gcc-4.9 produce these harmless warnings:

drivers/net/ieee802154/ca8210.c: In function 'ca8210_skb_tx':
drivers/net/ieee802154/ca8210.c:1947:9: warning: missing braces around initializer [-Wmissing-braces]

This changes the syntax to something that works on all versions without warnings.

Fixes ded845a781a5 ("ieee802154: Add CA8210 IEEE 802.15.4 device driver")

[]

drivers/net/ieee802154/ca8210.c

Quoted 1 line
drivers/net/ieee802154/ca8210.c +0 -0

[]

drivers/net/ieee802154/ca8210.c static int ca8210_skb_tx( · line 1949

Quoted 8 lines
drivers/net/ieee802154/ca8210.c +1 -1
@@ -1944,7 +1944,7 @@ static int ca8210_skb_tx(
 )
 {
 	int status;
-	struct ieee802154_hdr header = { 0 };
+	struct ieee802154_hdr header = { };
 	struct secspec secspec;
 	unsigned int mac_len;

Presumably gcc does this because the first member
of struct ieee802154_hdr is another struct.

I wonder if "struct foo bar = { 0 };" should be
discouraged by checkpatch.

Right now it's about 4:3 in favor of

	struct foo bar = {};
over
	struct foo bar = { 0 };
$ git grep -E "struct\s+\w+\s+\w+\s*=\s*\{\s*0\s*\}\s*[,;]" | wc -l
826
$ git grep -E "struct\s+\w+\s+\w+\s*=\s*\{\s*\}\s*[,;]" | wc -l
990

There are many instances on multiple lines too.
The git grep above doesn't span multiple lines.