LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH] ibmvnic: remove default label from to_string switch
@ 2021-05-03 10:23 Michal Suchanek
  2021-05-03 18:21 ` Lijun Pan
  0 siblings, 1 reply; 6+ messages in thread
From: Michal Suchanek @ 2021-05-03 10:23 UTC (permalink / raw)
  To: netdev
  Cc: Michal Suchanek, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, Dany Madden, Sukadev Bhattiprolu, Thomas Falcon,
	David S. Miller, Jakub Kicinski, linuxppc-dev, linux-kernel

This way the compiler warns when a new value is added to the enum but
not the string transation like:

drivers/net/ethernet/ibm/ibmvnic.c: In function 'adapter_state_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:832:2: warning: enumeration value 'VNIC_FOOBAR' not handled in switch [-Wswitch]
  switch (state) {
  ^~~~~~
drivers/net/ethernet/ibm/ibmvnic.c: In function 'reset_reason_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:1935:2: warning: enumeration value 'VNIC_RESET_FOOBAR' not handled in switch [-Wswitch]
  switch (reason) {
  ^~~~~~

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 5788bb956d73..4d439413f6d9 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -846,9 +846,8 @@ static const char *adapter_state_to_string(enum vnic_state state)
 		return "REMOVING";
 	case VNIC_REMOVED:
 		return "REMOVED";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 static int ibmvnic_login(struct net_device *netdev)
@@ -1946,9 +1945,8 @@ static const char *reset_reason_to_string(enum ibmvnic_reset_reason reason)
 		return "TIMEOUT";
 	case VNIC_RESET_CHANGE_PARAM:
 		return "CHANGE_PARAM";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 /*
-- 
2.26.2


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

* Re: [PATCH] ibmvnic: remove default label from to_string switch
  2021-05-03 10:23 [PATCH] ibmvnic: remove default label from to_string switch Michal Suchanek
@ 2021-05-03 18:21 ` Lijun Pan
  2021-05-03 20:47   ` David Miller
  0 siblings, 1 reply; 6+ messages in thread
From: Lijun Pan @ 2021-05-03 18:21 UTC (permalink / raw)
  To: Michal Suchanek
  Cc: netdev, Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	Dany Madden, Sukadev Bhattiprolu, Thomas Falcon, David S. Miller,
	Jakub Kicinski, linuxppc-dev, linux-kernel

On Mon, May 3, 2021 at 5:54 AM Michal Suchanek <msuchanek@suse.de> wrote:
>
> This way the compiler warns when a new value is added to the enum but
> not the string transation like:

s/transation/translation/

This trick works.
Since the original code does not generate gcc warnings/errors, should
this patch be sent to net-next as an improvement?

>
> drivers/net/ethernet/ibm/ibmvnic.c: In function 'adapter_state_to_string':
> drivers/net/ethernet/ibm/ibmvnic.c:832:2: warning: enumeration value 'VNIC_FOOBAR' not handled in switch [-Wswitch]
>   switch (state) {
>   ^~~~~~
> drivers/net/ethernet/ibm/ibmvnic.c: In function 'reset_reason_to_string':
> drivers/net/ethernet/ibm/ibmvnic.c:1935:2: warning: enumeration value 'VNIC_RESET_FOOBAR' not handled in switch [-Wswitch]
>   switch (reason) {
>   ^~~~~~
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> ---

Acked-by: Lijun Pan <lijunp213@gmail.com>

>  drivers/net/ethernet/ibm/ibmvnic.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
> index 5788bb956d73..4d439413f6d9 100644
> --- a/drivers/net/ethernet/ibm/ibmvnic.c
> +++ b/drivers/net/ethernet/ibm/ibmvnic.c
> @@ -846,9 +846,8 @@ static const char *adapter_state_to_string(enum vnic_state state)
>                 return "REMOVING";
>         case VNIC_REMOVED:
>                 return "REMOVED";
> -       default:
> -               return "UNKNOWN";
>         }
> +       return "UNKNOWN";
>  }
>
>  static int ibmvnic_login(struct net_device *netdev)
> @@ -1946,9 +1945,8 @@ static const char *reset_reason_to_string(enum ibmvnic_reset_reason reason)
>                 return "TIMEOUT";
>         case VNIC_RESET_CHANGE_PARAM:
>                 return "CHANGE_PARAM";
> -       default:
> -               return "UNKNOWN";
>         }
> +       return "UNKNOWN";
>  }
>
>  /*
> --
> 2.26.2
>

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

* Re: [PATCH] ibmvnic: remove default label from to_string switch
  2021-05-03 18:21 ` Lijun Pan
@ 2021-05-03 20:47   ` David Miller
  2021-05-04  5:40     ` [PATCH v2 net-next] " Michal Suchanek
  2021-05-04 19:19     ` [PATCH v2 net-next resend] " Michal Suchanek
  0 siblings, 2 replies; 6+ messages in thread
From: David Miller @ 2021-05-03 20:47 UTC (permalink / raw)
  To: lijunp213
  Cc: msuchanek, netdev, mpe, benh, paulus, drt, sukadev, tlfalcon,
	kuba, linuxppc-dev, linux-kernel

From: Lijun Pan <lijunp213@gmail.com>
Date: Mon, 3 May 2021 13:21:00 -0500

> On Mon, May 3, 2021 at 5:54 AM Michal Suchanek <msuchanek@suse.de> wrote:
>>
>> This way the compiler warns when a new value is added to the enum but
>> not the string transation like:
> 
> s/transation/translation/
> 
> This trick works.
> Since the original code does not generate gcc warnings/errors, should
> this patch be sent to net-next as an improvement?

Yes.

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

* [PATCH v2 net-next] ibmvnic: remove default label from to_string switch
  2021-05-03 20:47   ` David Miller
@ 2021-05-04  5:40     ` Michal Suchanek
  2021-05-04 19:19     ` [PATCH v2 net-next resend] " Michal Suchanek
  1 sibling, 0 replies; 6+ messages in thread
From: Michal Suchanek @ 2021-05-04  5:40 UTC (permalink / raw)
  To: netdev
  Cc: Michal Suchanek, Lijun Pan, Dany Madden, Sukadev Bhattiprolu,
	Thomas Falcon, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, David S. Miller, Jakub Kicinski, linuxppc-dev,
	linux-kernel

This way the compiler warns when a new value is added to the enum but
not to the string translation like:

drivers/net/ethernet/ibm/ibmvnic.c: In function 'adapter_state_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:832:2: warning: enumeration value 'VNIC_FOOBAR' not handled in switch [-Wswitch]
  switch (state) {
  ^~~~~~
drivers/net/ethernet/ibm/ibmvnic.c: In function 'reset_reason_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:1935:2: warning: enumeration value 'VNIC_RESET_FOOBAR' not handled in switch [-Wswitch]
  switch (reason) {
  ^~~~~~

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
---
v2: Fix typo in commit message
---
 drivers/net/ethernet/ibm/ibmvnic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 5788bb956d73..4d439413f6d9 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -846,9 +846,8 @@ static const char *adapter_state_to_string(enum vnic_state state)
 		return "REMOVING";
 	case VNIC_REMOVED:
 		return "REMOVED";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 static int ibmvnic_login(struct net_device *netdev)
@@ -1946,9 +1945,8 @@ static const char *reset_reason_to_string(enum ibmvnic_reset_reason reason)
 		return "TIMEOUT";
 	case VNIC_RESET_CHANGE_PARAM:
 		return "CHANGE_PARAM";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 /*
-- 
2.26.2


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

* [PATCH v2 net-next resend] ibmvnic: remove default label from to_string switch
  2021-05-03 20:47   ` David Miller
  2021-05-04  5:40     ` [PATCH v2 net-next] " Michal Suchanek
@ 2021-05-04 19:19     ` Michal Suchanek
  2021-05-04 19:39       ` Lijun Pan
  1 sibling, 1 reply; 6+ messages in thread
From: Michal Suchanek @ 2021-05-04 19:19 UTC (permalink / raw)
  To: netdev
  Cc: Michal Suchanek, Lijun Pan, Dany Madden, Sukadev Bhattiprolu,
	Thomas Falcon, Michael Ellerman, Benjamin Herrenschmidt,
	Paul Mackerras, David S. Miller, Jakub Kicinski, linuxppc-dev,
	linux-kernel

This way the compiler warns when a new value is added to the enum but
not to the string translation like:

drivers/net/ethernet/ibm/ibmvnic.c: In function 'adapter_state_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:832:2: warning: enumeration value 'VNIC_FOOBAR' not handled in switch [-Wswitch]
  switch (state) {
  ^~~~~~
drivers/net/ethernet/ibm/ibmvnic.c: In function 'reset_reason_to_string':
drivers/net/ethernet/ibm/ibmvnic.c:1935:2: warning: enumeration value 'VNIC_RESET_FOOBAR' not handled in switch [-Wswitch]
  switch (reason) {
  ^~~~~~

Signed-off-by: Michal Suchanek <msuchanek@suse.de>
Acked-by: Lijun Pan <lijunp213@gmail.com>
---
v2: Fix typo in commit message
---
 drivers/net/ethernet/ibm/ibmvnic.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index 5788bb956d73..4d439413f6d9 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -846,9 +846,8 @@ static const char *adapter_state_to_string(enum vnic_state state)
 		return "REMOVING";
 	case VNIC_REMOVED:
 		return "REMOVED";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 static int ibmvnic_login(struct net_device *netdev)
@@ -1946,9 +1945,8 @@ static const char *reset_reason_to_string(enum ibmvnic_reset_reason reason)
 		return "TIMEOUT";
 	case VNIC_RESET_CHANGE_PARAM:
 		return "CHANGE_PARAM";
-	default:
-		return "UNKNOWN";
 	}
+	return "UNKNOWN";
 }
 
 /*
-- 
2.26.2


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

* Re: [PATCH v2 net-next resend] ibmvnic: remove default label from to_string switch
  2021-05-04 19:19     ` [PATCH v2 net-next resend] " Michal Suchanek
@ 2021-05-04 19:39       ` Lijun Pan
  0 siblings, 0 replies; 6+ messages in thread
From: Lijun Pan @ 2021-05-04 19:39 UTC (permalink / raw)
  To: Michal Suchanek
  Cc: netdev, Dany Madden, Sukadev Bhattiprolu, Thomas Falcon,
	Michael Ellerman, Benjamin Herrenschmidt, Paul Mackerras,
	David S. Miller, Jakub Kicinski, linuxppc-dev, linux-kernel

On Tue, May 4, 2021 at 2:19 PM Michal Suchanek <msuchanek@suse.de> wrote:
>
> This way the compiler warns when a new value is added to the enum but
> not to the string translation like:
>
> drivers/net/ethernet/ibm/ibmvnic.c: In function 'adapter_state_to_string':
> drivers/net/ethernet/ibm/ibmvnic.c:832:2: warning: enumeration value 'VNIC_FOOBAR' not handled in switch [-Wswitch]
>   switch (state) {
>   ^~~~~~
> drivers/net/ethernet/ibm/ibmvnic.c: In function 'reset_reason_to_string':
> drivers/net/ethernet/ibm/ibmvnic.c:1935:2: warning: enumeration value 'VNIC_RESET_FOOBAR' not handled in switch [-Wswitch]
>   switch (reason) {
>   ^~~~~~
>
> Signed-off-by: Michal Suchanek <msuchanek@suse.de>
> Acked-by: Lijun Pan <lijunp213@gmail.com>
> ---
> v2: Fix typo in commit message
> ---

Hi Michal,

Thank you for reposting the patch and including the Ack-by tag. I
think you need to wait till next Tuesday or so when net-next reopens,
then you can repost the patch.
http://vger.kernel.org/~davem/net-next.html.

Thanks,
Lijun

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

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-03 10:23 [PATCH] ibmvnic: remove default label from to_string switch Michal Suchanek
2021-05-03 18:21 ` Lijun Pan
2021-05-03 20:47   ` David Miller
2021-05-04  5:40     ` [PATCH v2 net-next] " Michal Suchanek
2021-05-04 19:19     ` [PATCH v2 net-next resend] " Michal Suchanek
2021-05-04 19:39       ` Lijun Pan

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git
	git clone --mirror https://lore.kernel.org/lkml/9 lkml/git/9.git
	git clone --mirror https://lore.kernel.org/lkml/10 lkml/git/10.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git