Skip to contentSkip to conversation

net: usb: aqc111: Properly initialize wol_cfg in aqc111_suspend

PATCH Superseded Nathan Chancellor 2 participants 5 messages Nov 29, 2018 – Dec 1, 2018

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

PATCH 1/1 net: usb: aqc111: Properly initialize wol_cfg in aqc111_suspend

Clang warns:

drivers/net/usb/aqc111.c:1326:37: warning: suggest braces around initialization of subobject [-Wmissing-braces]

                struct aqc111_wol_cfg wol_cfg = { 0 };
                                                  ^
                                                  {}

1 warning generated.

Add another set of braces to initialize the char subobjects as well.

Fixes e58ba4544c77 ("net: usb: aqc111: Add support for wake on LAN by MAGIC packet")
---
 drivers/net/usb/aqc111.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/usb/aqc111.c +1 -1
index f69d566bd523..1c2db1191073 100644
@@ -1323,7 +1323,7 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
 			      1, 1, &reg8);
 
 	if (aqc111_data->wol_flags) {
-		struct aqc111_wol_cfg wol_cfg = { 0 };
+		struct aqc111_wol_cfg wol_cfg = { { 0 } };
 
 		aqc111_data->phy_cfg |= AQ_WOL;
 		ether_addr_copy(wol_cfg.hw_addr, dev->net->dev_addr);
Signature · 1 line
2.20.0.rc1
maintainer
#1 lore raw

From: Nathan Chancellor <[email protected]>
Date: Wed, 28 Nov 2018 22:18:09 -0700

Quoted 7 lines

Clang warns:

drivers/net/usb/aqc111.c:1326:37: warning: suggest braces around initialization of subobject [-Wmissing-braces]

                struct aqc111_wol_cfg wol_cfg = { 0 };
                                                  ^
                                                  {}
Quoted 6 lines

1 warning generated.

Add another set of braces to initialize the char subobjects as well.

Fixes e58ba4544c77 ("net: usb: aqc111: Add support for wake on LAN by MAGIC packet")

This will in turn make some versions of gcc warn.

Please just memset() this object, thanks.

#2 lore raw
Quoted 12 lines · David Miller

From: Nathan Chancellor <[email protected]>
Date: Wed, 28 Nov 2018 22:18:09 -0700

Quoted 9 lines

Clang warns:

drivers/net/usb/aqc111.c:1326:37: warning: suggest braces around initialization of subobject [-Wmissing-braces]

                struct aqc111_wol_cfg wol_cfg = { 0 };
                                                  ^
                                                  {}

1 warning generated.

Quoted 8 lines
Quoted 4 lines

Add another set of braces to initialize the char subobjects as well.

Fixes e58ba4544c77 ("net: usb: aqc111: Add support for wake on LAN by MAGIC packet")

This will in turn make some versions of gcc warn.

Please just memset() this object, thanks.

I thought this was the form that all compilers seemed to agree on but sure, I will send a v2.

Thanks for the quick response,
Nathan

#3 lore raw

PATCH v2 1/1 net: usb: aqc111: Initialize wol_cfg with memset in aqc111_suspend

In reply to Nathan Chancellor

Clang warns:

drivers/net/usb/aqc111.c:1326:37: warning: suggest braces around initialization of subobject [-Wmissing-braces]

                struct aqc111_wol_cfg wol_cfg = { 0 };
                                                  ^
                                                  {}

1 warning generated.

Use memset to initialize the object to take compiler instrumentation out of the equation.

Fixes e58ba4544c77 ("net: usb: aqc111: Add support for wake on LAN by MAGIC packet")

---

v1 -> v2:

* Use memset instead of braces.

 drivers/net/usb/aqc111.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/usb/aqc111.c +3 -1
index f69d566bd523..57f1c94fca0b 100644
@@ -1323,7 +1323,9 @@ static int aqc111_suspend(struct usb_interface *intf, pm_message_t message)
 			      1, 1, &reg8);
 
 	if (aqc111_data->wol_flags) {
-		struct aqc111_wol_cfg wol_cfg = { 0 };
+		struct aqc111_wol_cfg wol_cfg;
+
+		memset(&wol_cfg, 0, sizeof(struct aqc111_wol_cfg));
 
 		aqc111_data->phy_cfg |= AQ_WOL;
 		ether_addr_copy(wol_cfg.hw_addr, dev->net->dev_addr);
Signature · 1 line
2.20.0.rc1
maintainer Applied
#4 lore raw

Re: [PATCH v2] net: usb: aqc111: Initialize wol_cfg with memset in aqc111_suspend

From: Nathan Chancellor <[email protected]>
Date: Wed, 28 Nov 2018 23:01:05 -0700

Quoted 7 lines

Clang warns:

drivers/net/usb/aqc111.c:1326:37: warning: suggest braces around initialization of subobject [-Wmissing-braces]

                struct aqc111_wol_cfg wol_cfg = { 0 };
                                                  ^
                                                  {}
Quoted 7 lines

1 warning generated.

Use memset to initialize the object to take compiler instrumentation out of the equation.

Fixes e58ba4544c77 ("net: usb: aqc111: Add support for wake on LAN by MAGIC packet")

Applied.