Skip to contentSkip to conversation

hwmon: replace impossible fallthroughs with breaks

PATCH In review Dan Carpenter 2 participants 2 messages Aug 31, 2020

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

PATCH 1/1 hwmon: replace impossible fallthroughs with breaks

It's impossible to reach these fall through statements because all the possible values are handled. In that situation it's cleaner to use a break statement instead of a fall through statement.

Fixes c947e51cf803 ("hwmon: (adt7462) Mark expected switch fall-throughs")
---
 drivers/hwmon/adt7462.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/adt7462.c +4 -4
index e75bbd87ad09..634a44591c7f 100644
@@ -435,7 +435,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
 		case 3:
 			return "+1.5V";
 		}
-		fallthrough;
+		break;
 	case 2:
 		if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
 			return "+12V3";
@@ -493,7 +493,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
 		case 3:
 			return "+1.5";
 		}
-		fallthrough;
+		break;
 	case 11:
 		if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT =
 					ADT7462_PIN28_VOLT &&
@@ -531,7 +531,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
 		case 3:
 			return 7800;
 		}
-		fallthrough;
+		break;
 	case 2:
 		if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
 			return 62500;
@@ -589,7 +589,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
 		case 3:
 			return 7800;
 		}
-		fallthrough;
+		break;
 	case 11:
 	case 12:
 		if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT =
Signature · 1 line
2.28.0
maintainer
#1 lore raw
Quoted 4 lines · Dan Carpenter

It's impossible to reach these fall through statements because all the possible values are handled. In that situation it's cleaner to use a break statement instead of a fall through statement.

Makes sense. Applied.

Thanks,
Guenter

Quoted 46 lines
Fixes c947e51cf803 ("hwmon: (adt7462) Mark expected switch fall-throughs")
---
 drivers/hwmon/adt7462.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/hwmon/adt7462.c +4 -4
index e75bbd87ad09..634a44591c7f 100644
@@ -435,7 +435,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
 		case 3:
 			return "+1.5V";
 		}
-		fallthrough;
+		break;
 	case 2:
 		if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
 			return "+12V3";
@@ -493,7 +493,7 @@ static const char *voltage_label(struct adt7462_data *data, int which)
 		case 3:
 			return "+1.5";
 		}
-		fallthrough;
+		break;
 	case 11:
 		if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT =
 					ADT7462_PIN28_VOLT &&
@@ -531,7 +531,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
 		case 3:
 			return 7800;
 		}
-		fallthrough;
+		break;
 	case 2:
 		if (!(data->pin_cfg[1] & ADT7462_PIN22_INPUT))
 			return 62500;
@@ -589,7 +589,7 @@ static int voltage_multiplier(struct adt7462_data *data, int which)
 		case 3:
 			return 7800;
 		}
-		fallthrough;
+		break;
 	case 11:
 	case 12:
 		if (data->pin_cfg[3] >> ADT7462_PIN28_SHIFT =