Skip to contentSkip to conversation

cxgb4: Use proper enum in cxgb4_dcb_handle_fw_update

PATCH Applied Nathan Chancellor 3 participants 3 messages Oct 1, 2018 – Oct 3, 2018

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

PATCH 1/1 cxgb4: Use proper enum in cxgb4_dcb_handle_fw_update

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:303:7: warning: implicit conversion from enumeration type 'enum cxgb4_dcb_state' to different enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]

                         ? CXGB4_DCB_STATE_FW_ALLSYNCED
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:304:7: warning: implicit
conversion from enumeration type 'enum cxgb4_dcb_state' to different
enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]
                         : CXGB4_DCB_STATE_FW_INCOMPLETE);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2 warnings generated.

Use the equivalent value of the expected type to silence Clang while resulting in no functional change.

CXGB4_DCB_STATE_FW_INCOMPLETE = CXGB4_DCB_INPUT_FW_INCOMPLETE = 2 CXGB4_DCB_STATE_FW_ALLSYNCED = CXGB4_DCB_INPUT_FW_ALLSYNCED = 3

---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c +2 -2
index 6ba3104ff7eb..9bd5f755a0e0 100644
@@ -300,8 +300,8 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
 		enum cxgb4_dcb_state_input input =
 			((pcmd->u.dcb.control.all_syncd_pkd &
 			  FW_PORT_CMD_ALL_SYNCD_F)
-			 ? CXGB4_DCB_STATE_FW_ALLSYNCED
-			 : CXGB4_DCB_STATE_FW_INCOMPLETE);
+			 ? CXGB4_DCB_INPUT_FW_ALLSYNCED
+			 : CXGB4_DCB_INPUT_FW_INCOMPLETE);
 
 		if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
 			dcb_running_version = FW_PORT_CMD_DCB_VERSION_G(
Signature · 1 line
2.19.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 13 lines · Nathan Chancellor

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:303:7: warning: implicit conversion from enumeration type 'enum cxgb4_dcb_state' to different enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]

                         ? CXGB4_DCB_STATE_FW_ALLSYNCED
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:304:7: warning: implicit
conversion from enumeration type 'enum cxgb4_dcb_state' to different
enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]
                         : CXGB4_DCB_STATE_FW_INCOMPLETE);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Quoted 7 lines

2 warnings generated.

Use the equivalent value of the expected type to silence Clang while resulting in no functional change.

CXGB4_DCB_STATE_FW_INCOMPLETE = CXGB4_DCB_INPUT_FW_INCOMPLETE = 2 CXGB4_DCB_STATE_FW_ALLSYNCED = CXGB4_DCB_INPUT_FW_ALLSYNCED = 3

Yep looks good. There's not too many users of cxgb4_dcb_state_input in the kernel. I wonder if it could even be replaced entirely with cxgb4_dcb_state? But for now this patch fixes the warning correctly. Thanks for sending it.

Looks like this was the second case of this warning in this code (I thought I was having Deja Vu; that I had already reviewed this patch earlier): https://lkml.org/lkml/2018/10/1/255 Probably could have been a single patch, but that's ok.

Quoted 24 lines
---
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c +2 -3
index 6ba3104ff7eb..9bd5f755a0e0 100644
@@ -300,8 +300,8 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
                enum cxgb4_dcb_state_input input =
                        ((pcmd->u.dcb.control.all_syncd_pkd &
                          FW_PORT_CMD_ALL_SYNCD_F)
-                        ? CXGB4_DCB_STATE_FW_ALLSYNCED
-                        : CXGB4_DCB_STATE_FW_INCOMPLETE);
+                        ? CXGB4_DCB_INPUT_FW_ALLSYNCED
+                        : CXGB4_DCB_INPUT_FW_INCOMPLETE);
 
                if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
                        dcb_running_version = FW_PORT_CMD_DCB_VERSION_G(
--

2.19.0

Signature · 2 lines
Thanks,
~Nick Desaulniers
maintainer Applied
#2 lore raw
In reply to Nathan Chancellor

From: Nathan Chancellor <[email protected]>
Date: Sun, 30 Sep 2018 20:51:43 -0700

Quoted 14 lines

Clang warns when one enumerated type is implicitly converted to another.

drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:303:7: warning: implicit conversion from enumeration type 'enum cxgb4_dcb_state' to different enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]

                         ? CXGB4_DCB_STATE_FW_ALLSYNCED
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c:304:7: warning: implicit
conversion from enumeration type 'enum cxgb4_dcb_state' to different
enumeration type 'enum cxgb4_dcb_state_input' [-Wenum-conversion]
                         : CXGB4_DCB_STATE_FW_INCOMPLETE);
                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~

2 warnings generated.

Quoted 7 lines

Use the equivalent value of the expected type to silence Clang while resulting in no functional change.

CXGB4_DCB_STATE_FW_INCOMPLETE = CXGB4_DCB_INPUT_FW_INCOMPLETE = 2 CXGB4_DCB_STATE_FW_ALLSYNCED = CXGB4_DCB_INPUT_FW_ALLSYNCED = 3

Applied to net-next.