hwmon: (smpro-hwmon) Improve switch statments in smpro_is_visible()
PATCH v2 1/1 hwmon: (smpro-hwmon) Improve switch statments in smpro_is_visible()
Clang warns:
drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]
default:
^
drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through
default:
^
break;1 error generated.
Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return.
Add the missing break to silence the warning. Additionally, adjust the indentation of a break and add a default case to the inner switch statement.
---
v2:
* Add missing default case to inner switch statement (Guenter)
* Fix indentation of break in inner switch statement (Guenter)
* Reword commit message to include these changes
v1: https://lore.kernel.org/[email protected]/
drivers/hwmon/smpro-hwmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/hwmon/smpro-hwmon.c +4 -1
@@ -373,8 +373,11 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, ret =regmap_read (hwmon->regmap, temperature[channel].reg, &value);if (ret || value ==0xFFFF )return 0 ; -break ; +break ; +default : +break ; } +break ;default :break ; }
base-commit: 0ffb687b6508c36a17b99bdaf014b38532404182
Signature · 1 line
2.38.1
Quoted 17 lines · Nathan Chancellor
Clang warns:
drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]default: ^ drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through default: ^ break;1 error generated.
Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in
deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return.
Quoted 7 lines
Add the missing break to silence the warning. Additionally, adjust the indentation of a break and add a default case to the inner switch statement.
Fixes a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")Signed-off-by Nathan Chancellor <[email protected]>
Applied.
Thanks,
Guenter
Quoted 33 lines
---
v2:
* Add missing default case to inner switch statement (Guenter)
* Fix indentation of break in inner switch statement (Guenter)
* Reword commit message to include these changesv1: https://lore.kernel.org/[email protected]/
drivers/hwmon/smpro-hwmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)base-commit:
0ffb687b6508c36a17b99bdaf014b38532404182drivers/hwmon/smpro-hwmon.c +4
-1@@ -373,8 +373,11 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, ret =regmap_read (hwmon->regmap, temperature[channel].reg, &value);if (ret || value ==0xFFFF )return 0 ; -break ; +break ; +default : +break ; } +break ;default :break ; }
Thanks Nathan for the fix.
- Quan
Quoted 64 lines · Guenter Roeck
Quoted 17 lines · Nathan Chancellor
Clang warns:
drivers/hwmon/smpro-hwmon.c:378:2: error: unannotated fall-through between switch labels [-Werror,-Wimplicit-fallthrough]default: ^ drivers/hwmon/smpro-hwmon.c:378:2: note: insert 'break;' to avoid fall-through default: ^ break;1 error generated.
Clang is a little more pedantic than GCC, which does not warn when falling through to a case that is just break or return. Clang's version is more in line with the kernel's own stance in
deprecated.rst, which states that all switch/case blocks must end in either break, fallthrough, continue, goto, or return.Quoted 7 lines
Add the missing break to silence the warning. Additionally, adjust the indentation of a break and add a default case to the inner switch statement.
Fixes a87456864cbb ("hwmon: Add Ampere's Altra smpro-hwmon driver")Signed-off-by Nathan Chancellor <[email protected]>Applied.
Thanks,
GuenterQuoted 33 lines
---
v2:
* Add missing default case to inner switch statement (Guenter)
* Fix indentation of break in inner switch statement (Guenter)
* Reword commit message to include these changesv1: https://lore.kernel.org/[email protected]/
drivers/hwmon/smpro-hwmon.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)base-commit:
0ffb687b6508c36a17b99bdaf014b38532404182drivers/hwmon/smpro-hwmon.c +4
-1@@ -373,8 +373,11 @@ static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, ret =regmap_read (hwmon->regmap, temperature[channel].reg, &value);if (ret || value ==0xFFFF )return 0 ; -break ; +break ; +default : +break ; } +break ;default :break ; }