Skip to contentSkip to conversation

fallthrough related handling

PATCH In review Stephen Hemminger 4 participants 9 messages Nov 14, 2024 – Nov 19, 2024

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

cover fallthrough related handling

Fix lack of fallthrough checking and bug in e1000 driver.

Stephen Hemminger (2):
net/e1000: fix incorrect fallthrough in switch common/dpaax: do not disable fallthrough warnings

 drivers/common/dpaax/caamflib/rta/operation_cmd.h | 4 ----
 drivers/net/e1000/base/e1000_82575.c              | 3 +--
 drivers/net/e1000/base/e1000_api.c                | 2 +-
 drivers/net/e1000/base/meson.build                | 1 -
 4 files changed, 2 insertions(+), 8 deletions(-)
Signature · 1 line
2.45.2
#1 lore raw

PATCH 1/2 net/e1000: fix incorrect fallthrough in switch

There is an incorrect fallthrough identified by PVS studio. Even though this is in base code it should be fixed, and the warning should be re-enabled to prevent future bugs.

Fixes f2553cb9eba6 ("net/e1000/base: add new I219 devices")
---
 drivers/net/e1000/base/e1000_82575.c | 3 +--
 drivers/net/e1000/base/e1000_api.c   | 2 +-
 drivers/net/e1000/base/meson.build   | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/e1000/base/e1000_82575.c +1 -2
index 7c78649393..bcc695e8a1 100644
@@ -1721,7 +1721,7 @@ STATIC s32 e1000_get_media_type_82575(struct e1000_hw *hw)
 			dev_spec->sgmii_active = true;
 			break;
 		}
-		/* Fall through for I2C based SGMII */
+		/* fallthrough */
 	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
 		/* read media type from SFP EEPROM */
 		ret_val = e1000_set_sfp_media_type_82575(hw);
@@ -3585,4 +3585,3 @@ void e1000_i2c_bus_clear(struct e1000_hw *hw)
 	/* Put the i2c bus back to default state */
 	e1000_i2c_stop(hw);
 }
-
drivers/net/e1000/base/e1000_api.c +1 -1
index 0f6e5afa3b..61b3ead469 100644
@@ -295,6 +295,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
 	case E1000_DEV_ID_PCH_RPL_I219_LM23:
 	case E1000_DEV_ID_PCH_RPL_I219_V23:
 		mac->type = e1000_pch_tgp;
+		break;
 	case E1000_DEV_ID_PCH_ADL_I219_LM17:
 	case E1000_DEV_ID_PCH_ADL_I219_V17:
 	case E1000_DEV_ID_PCH_RPL_I219_LM22:
@@ -1368,4 +1369,3 @@ void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
 	if (hw->mac.ops.shutdown_serdes)
 		hw->mac.ops.shutdown_serdes(hw);
 }
-
drivers/net/e1000/base/meson.build +0 -1
index 6d6048488f..e73f3d6d55 100644
@@ -24,7 +24,6 @@ sources = [
 
 error_cflags = [
         '-Wno-unused-parameter',
-        '-Wno-implicit-fallthrough',
 ]
 c_args = cflags
 foreach flag: error_cflags
Signature · 1 line
2.45.2
Acked-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] net/e1000: fix incorrect fallthrough in switch

Quoted 10 lines · Stephen Hemminger

There is an incorrect fallthrough identified by PVS studio. Even though this is in base code it should be fixed, and the warning should be re-enabled to prevent future bugs.

Fixes f2553cb9eba6 ("net/e1000/base: add new I219 devices")

Thanks. Two minor comments below.

Quoted 11 lines
---
 drivers/net/e1000/base/e1000_82575.c | 3 +--
 drivers/net/e1000/base/e1000_api.c   | 2 +-
 drivers/net/e1000/base/meson.build   | 1 -
 3 files changed, 2 insertions(+), 4 deletions(-)
drivers/net/e1000/base/e1000_82575.c +0 -0
index 7c78649393..bcc695e8a1 100644

drivers/net/e1000/base/e1000_82575.c STATIC s32 e1000_get_media_type_82575(struct e1000_hw *hw) · line 1724

Quoted 5 lines
drivers/net/e1000/base/e1000_82575.c +1 -1
@@ -1721,7 +1721,7 @@ STATIC s32 e1000_get_media_type_82575(struct e1000_hw *hw)
 			dev_spec->sgmii_active = true;
 			break;
 		}
-		/* Fall through for I2C based SGMII */
+		/* fallthrough */

Can we keep the old comment as well as the new?

drivers/net/e1000/base/e1000_82575.c void e1000_i2c_bus_clear(struct e1000_hw *hw) · line 3588

Quoted 8 lines
drivers/net/e1000/base/e1000_82575.c +0 -1
 	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
 		/* read media type from SFP EEPROM */
 		ret_val = e1000_set_sfp_media_type_82575(hw);
@@ -3585,4 +3585,3 @@ void e1000_i2c_bus_clear(struct e1000_hw *hw)
 	/* Put the i2c bus back to default state */
 	e1000_i2c_stop(hw);
 }
-

Unrelated whitespace change, and also below. No big deal though.

Quoted 32 lines
drivers/net/e1000/base/e1000_api.c +1 -1
index 0f6e5afa3b..61b3ead469 100644
@@ -295,6 +295,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
 	case E1000_DEV_ID_PCH_RPL_I219_LM23:
 	case E1000_DEV_ID_PCH_RPL_I219_V23:
 		mac->type = e1000_pch_tgp;
+		break;
 	case E1000_DEV_ID_PCH_ADL_I219_LM17:
 	case E1000_DEV_ID_PCH_ADL_I219_V17:
 	case E1000_DEV_ID_PCH_RPL_I219_LM22:
@@ -1368,4 +1369,3 @@ void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
 	if (hw->mac.ops.shutdown_serdes)
 		hw->mac.ops.shutdown_serdes(hw);
 }
-
drivers/net/e1000/base/meson.build +0 -1
index 6d6048488f..e73f3d6d55 100644
@@ -24,7 +24,6 @@ sources = [
 
 error_cflags = [
         '-Wno-unused-parameter',
-        '-Wno-implicit-fallthrough',
 ]
 c_args = cflags
 foreach flag: error_cflags
Signature · 1 line
2.45.2
#3 lore raw

PATCH 2/2 common/dpaax: do not disable fallthrough warnings

In reply to Stephen Hemminger

Fallthrough warnings catch real bugs and should not be disabled. There are warnings in this driver in current build.

The commit that added the disable is old, and the problematic code appears to have been already removed.

Fixes 2ab9a9483196 ("crypto/dpaa2_sec: fix build with GCC 7")
---
 drivers/common/dpaax/caamflib/rta/operation_cmd.h | 4 ----
 1 file changed, 4 deletions(-)
drivers/common/dpaax/caamflib/rta/operation_cmd.h +0 -4
index fe1ac37ee8..563735eb88 100644
@@ -7,10 +7,6 @@
 #ifndef __RTA_OPERATION_CMD_H__
 #define __RTA_OPERATION_CMD_H__
 
-#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 70000)
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-#endif
-
 extern enum rta_sec_era rta_sec_era;
 
 static inline int
Signature · 1 line
2.45.2
Acked-by on v1 2/2
#4 lore raw

Re: [PATCH 2/2] common/dpaax: do not disable fallthrough warnings

Quoted 19 lines · Stephen Hemminger

Fallthrough warnings catch real bugs and should not be disabled. There are warnings in this driver in current build.

The commit that added the disable is old, and the problematic code appears to have been already removed.

Fixes 2ab9a9483196 ("crypto/dpaa2_sec: fix build with GCC 7")
---
  drivers/common/dpaax/caamflib/rta/operation_cmd.h | 4 ----
  1 file changed, 4 deletions(-)
drivers/common/dpaax/caamflib/rta/operation_cmd.h +0 -0
index fe1ac37ee8..563735eb88 100644

drivers/common/dpaax/caamflib/rta/operation_cmd.h line 12

Quoted 10 lines
drivers/common/dpaax/caamflib/rta/operation_cmd.h +0 -4
@@ -7,10 +7,6 @@
  #ifndef __RTA_OPERATION_CMD_H__
  #define __RTA_OPERATION_CMD_H__
 
-#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 70000)
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-#endif
-
  extern enum rta_sec_era rta_sec_era;
 
  static inline int
#5 lore raw

v2 cover re-enable implicit fallthrough checks

In reply to Stephen Hemminger

Fix bug detected from bad fallthroug in E1000 code. And re-enable compiler flag in both e1000 and dpaax

v2 - minor comment fix

Stephen Hemminger (2):
common/dpaax: do not disable fallthrough warnings net/e1000: fix incorrect fallthrough in switch

 drivers/common/dpaax/caamflib/rta/operation_cmd.h | 4 ----
 drivers/net/e1000/base/e1000_82575.c              | 2 +-
 drivers/net/e1000/base/e1000_api.c                | 2 +-
 drivers/net/e1000/base/meson.build                | 1 -
 4 files changed, 2 insertions(+), 7 deletions(-)
Signature · 1 line
2.45.2
#6 lore raw

PATCH v2 1/2 common/dpaax: do not disable fallthrough warnings

Fallthrough warnings catch real bugs and should not be disabled. There are warnings in this driver in current build.

The commit that added the disable is old, and the problematic code appears to have been already removed.

Fixes 2ab9a9483196 ("crypto/dpaa2_sec: fix build with GCC 7")
---
 drivers/common/dpaax/caamflib/rta/operation_cmd.h | 4 ----
 1 file changed, 4 deletions(-)
drivers/common/dpaax/caamflib/rta/operation_cmd.h +0 -4
index fe1ac37ee8..563735eb88 100644
@@ -7,10 +7,6 @@
 #ifndef __RTA_OPERATION_CMD_H__
 #define __RTA_OPERATION_CMD_H__
 
-#if defined(RTE_TOOLCHAIN_GCC) && (GCC_VERSION >= 70000)
-#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
-#endif
-
 extern enum rta_sec_era rta_sec_era;
 
 static inline int
Signature · 1 line
2.45.2
#7 lore raw

PATCH v2 2/2 net/e1000: fix incorrect fallthrough in switch

In reply to Stephen Hemminger

There is an incorrect fallthrough identified by PVS studio. Even though this is in base code it should be fixed, and the warning should be re-enabled to prevent future bugs.

Fixes f2553cb9eba6 ("net/e1000/base: add new I219 devices")
---
 drivers/net/e1000/base/e1000_82575.c | 2 +-
 drivers/net/e1000/base/e1000_api.c   | 2 +-
 drivers/net/e1000/base/meson.build   | 1 -
 3 files changed, 2 insertions(+), 3 deletions(-)
drivers/net/e1000/base/e1000_82575.c +1 -1
index 7c78649393..ccc7aeab21 100644
@@ -1722,6 +1722,7 @@ STATIC s32 e1000_get_media_type_82575(struct e1000_hw *hw)
 			break;
 		}
 		/* Fall through for I2C based SGMII */
+		/* Fall through */
 	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES:
 		/* read media type from SFP EEPROM */
 		ret_val = e1000_set_sfp_media_type_82575(hw);
@@ -3585,4 +3586,3 @@ void e1000_i2c_bus_clear(struct e1000_hw *hw)
 	/* Put the i2c bus back to default state */
 	e1000_i2c_stop(hw);
 }
-
drivers/net/e1000/base/e1000_api.c +1 -1
index 0f6e5afa3b..61b3ead469 100644
@@ -295,6 +295,7 @@ s32 e1000_set_mac_type(struct e1000_hw *hw)
 	case E1000_DEV_ID_PCH_RPL_I219_LM23:
 	case E1000_DEV_ID_PCH_RPL_I219_V23:
 		mac->type = e1000_pch_tgp;
+		break;
 	case E1000_DEV_ID_PCH_ADL_I219_LM17:
 	case E1000_DEV_ID_PCH_ADL_I219_V17:
 	case E1000_DEV_ID_PCH_RPL_I219_LM22:
@@ -1368,4 +1369,3 @@ void e1000_shutdown_fiber_serdes_link(struct e1000_hw *hw)
 	if (hw->mac.ops.shutdown_serdes)
 		hw->mac.ops.shutdown_serdes(hw);
 }
-
drivers/net/e1000/base/meson.build +0 -1
index 6d6048488f..e73f3d6d55 100644
@@ -24,7 +24,6 @@ sources = [
 
 error_cflags = [
         '-Wno-unused-parameter',
-        '-Wno-implicit-fallthrough',
 ]
 c_args = cflags
 foreach flag: error_cflags
Signature · 1 line
2.45.2
#8 lore raw

Re: [PATCH v2 0/2] re-enable implicit fallthrough checks

In reply to Stephen Hemminger

14/11/2024 18:11, Stephen Hemminger:

Quoted 8 lines

Fix bug detected from bad fallthroug in E1000 code. And re-enable compiler flag in both e1000 and dpaax

v2 - minor comment fix

Stephen Hemminger (2):
common/dpaax: do not disable fallthrough warnings net/e1000: fix incorrect fallthrough in switch

Applied, thanks.