linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] net: ethernet: mscc: fix missing brace warning for old compilers
@ 2020-11-03  2:55 Pujin Shi
  2020-11-03 19:05 ` Jakub Kicinski
  0 siblings, 1 reply; 3+ messages in thread
From: Pujin Shi @ 2020-11-03  2:55 UTC (permalink / raw)
  To: Jakub Kicinski, David S . Miller
  Cc: Microchip Linux Driver Support, Vladimir Oltean, Claudiu Manoil,
	Alexandre Belloni, Xiaoliang Yang, netdev, linux-kernel,
	Pujin Shi

For older versions of gcc, the array = {0}; will cause warnings:

drivers/net/ethernet/mscc/ocelot_vcap.c: In function 'is1_entry_set':
drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: missing braces around initializer [-Wmissing-braces]
    struct ocelot_vcap_u16 etype = {0};
           ^
drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: (near initialization for 'etype.value') [-Wmissing-braces]

1 warnings generated

Fixes: 75944fda1dfe ("net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1")
Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
---
 drivers/net/ethernet/mscc/ocelot_vcap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
index d8c778ee6f1b..b5167570521c 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.c
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
@@ -752,7 +752,7 @@ static void is1_entry_set(struct ocelot *ocelot, int ix,
 					     dport);
 		} else {
 			/* IPv4 "other" frame */
-			struct ocelot_vcap_u16 etype = {0};
+			struct ocelot_vcap_u16 etype = {{0}};
 
 			/* Overloaded field */
 			etype.value[0] = proto.value[0];
-- 
2.18.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] net: ethernet: mscc: fix missing brace warning for old compilers
  2020-11-03  2:55 [PATCH V2] net: ethernet: mscc: fix missing brace warning for old compilers Pujin Shi
@ 2020-11-03 19:05 ` Jakub Kicinski
  2020-11-03 19:26   ` Vladimir Oltean
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Kicinski @ 2020-11-03 19:05 UTC (permalink / raw)
  To: Pujin Shi
  Cc: David S . Miller, Microchip Linux Driver Support,
	Vladimir Oltean, Claudiu Manoil, Alexandre Belloni,
	Xiaoliang Yang, netdev, linux-kernel

On Tue,  3 Nov 2020 10:55:19 +0800 Pujin Shi wrote:
> For older versions of gcc, the array = {0}; will cause warnings:

Please include the version of gcc which generates this warning here.

> drivers/net/ethernet/mscc/ocelot_vcap.c: In function 'is1_entry_set':
> drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: missing braces around initializer [-Wmissing-braces]
>     struct ocelot_vcap_u16 etype = {0};
>            ^
> drivers/net/ethernet/mscc/ocelot_vcap.c:755:11: warning: (near initialization for 'etype.value') [-Wmissing-braces]
> 
> 1 warnings generated
> 
> Fixes: 75944fda1dfe ("net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1")
> Signed-off-by: Pujin Shi <shipujin.t@gmail.com>
> ---
>  drivers/net/ethernet/mscc/ocelot_vcap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
> index d8c778ee6f1b..b5167570521c 100644
> --- a/drivers/net/ethernet/mscc/ocelot_vcap.c
> +++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
> @@ -752,7 +752,7 @@ static void is1_entry_set(struct ocelot *ocelot, int ix,
>  					     dport);
>  		} else {
>  			/* IPv4 "other" frame */
> -			struct ocelot_vcap_u16 etype = {0};
> +			struct ocelot_vcap_u16 etype = {{0}};

I believe Vladimir asked to use a memset instead;

			struct ocelot_vcap_u16 etype;

			memset(&etype, 0, sizeof(etype));
>  			/* Overloaded field */
>  			etype.value[0] = proto.value[0];


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH V2] net: ethernet: mscc: fix missing brace warning for old compilers
  2020-11-03 19:05 ` Jakub Kicinski
@ 2020-11-03 19:26   ` Vladimir Oltean
  0 siblings, 0 replies; 3+ messages in thread
From: Vladimir Oltean @ 2020-11-03 19:26 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Pujin Shi, David S . Miller, Microchip Linux Driver Support,
	Claudiu Manoil, Alexandre Belloni, Xiaoliang Yang, netdev,
	linux-kernel

On Tue, Nov 03, 2020 at 11:05:09AM -0800, Jakub Kicinski wrote:
> I believe Vladimir asked to use a memset instead;
> 
> 			struct ocelot_vcap_u16 etype;
> 
> 			memset(&etype, 0, sizeof(etype));

Thanks, Jakub.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-03 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03  2:55 [PATCH V2] net: ethernet: mscc: fix missing brace warning for old compilers Pujin Shi
2020-11-03 19:05 ` Jakub Kicinski
2020-11-03 19:26   ` Vladimir Oltean

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).