hwmon: Mark expected switch fall-throughs
PATCH 1/1 hwmon: Mark expected switch fall-throughs
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
--- drivers/hwmon/emc1403.c | 2 ++ drivers/hwmon/nct6775.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)
drivers/hwmon/emc1403.c +2 -0
@@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,switch (id->driver_data) {case emc1404: data->groups[2 ] = &emc1404_group; +/* fall through */ case emc1403: data->groups[1 ] = &emc1403_group; +/* fall through */ case emc1402: data->groups[0 ] = &emc1402_group; }
drivers/hwmon/nct6775.c +1 -1
@@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)case thermal_cruise:nct6775_write_value (data, data->REG_TARGET[nr], data->target_temp[nr]); -/* intentional */ +/* fall through */ default : reg =nct6775_read_value (data, data->REG_FAN_MODE[nr]); reg = (reg & ~data->tolerance_mask) |
Signature · 1 line
2.7.4
Hi Gustavo,
Quoted 2 lines · Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
That's a great initiative, thanks for doing that.
Quoted 26 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/hwmon/emc1403.c | 2 ++ drivers/hwmon/nct6775.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)drivers/hwmon/emc1403.c +2
-0@@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,switch (id->driver_data) {case emc1404: data->groups[2 ] = &emc1404_group; +/* fall through */ case emc1403: data->groups[1 ] = &emc1403_group; +/* fall through */ case emc1402: data->groups[0 ] = &emc1402_group; }drivers/hwmon/nct6775.c +0
-0
drivers/hwmon/nct6775.c static void pwm_update_registers(struct nct6775_data *data, int nr) · line 2544
Quoted 5 lines
drivers/hwmon/nct6775.c +1
-1@@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)case thermal_cruise:nct6775_write_value (data, data->REG_TARGET[nr], data->target_temp[nr]); -/* intentional */ +/* fall through */
Do you know which -Wimplicit-fallthrough level we will be using? Level 1 would be happy with the initial comment, no change would be needed. If level 2-4 then yes the change is needed.
drivers/hwmon/nct6775.c static void pwm_update_registers(struct nct6775_data *data, int nr) · line 2547
Quoted 3 lines
drivers/hwmon/nct6775.c +0
-0default : reg =nct6775_read_value (data, data->REG_FAN_MODE[nr]); reg = (reg & ~data->tolerance_mask) |
Signature · 2 lines
Jean Delvare SUSE L3 Support
Hi Jean,
Quoted 8 lines · Jean Delvare
Hi Gustavo,
Quoted 2 lines · Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
That's a great initiative, thanks for doing that.
Glad to help. :)
Quoted 27 lines
Quoted 27 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/hwmon/emc1403.c | 2 ++ drivers/hwmon/nct6775.c | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-)drivers/hwmon/emc1403.c +2
-0@@ -443,8 +443,10 @@ static int emc1403_probe(struct i2c_client *client,switch (id->driver_data) {case emc1404: data->groups[2 ] = &emc1404_group; +/* fall through */ case emc1403: data->groups[1 ] = &emc1403_group; +/* fall through */ case emc1402: data->groups[0 ] = &emc1402_group; }drivers/hwmon/nct6775.c +0
-0@@ -2541,7 +2541,7 @@ static void pwm_update_registers(struct nct6775_data *data, int nr)case thermal_cruise:
Quoted 9 lines
drivers/hwmon/nct6775.c static void pwm_update_registers(struct nct6775_data *data, int nr) · line 2544
Quoted 4 lines
drivers/hwmon/nct6775.c +1
-1nct6775_write_value (data, data->REG_TARGET[nr], data->target_temp[nr]); -/* intentional */ +/* fall through */ Do you know which -Wimplicit-fallthrough level we will be using? Level 1 would be happy with the initial comment, no change would be needed. If level 2-4 then yes the change is needed.
We are trying level 2, so we can perfectly use annotations like this one (else: fall through):
Quoted 6 lines
drivers/hwmon/nct6775.c static void pwm_update_registers(struct nct6775_data *data, int nr) · line 2547
Quoted 3 lines
drivers/hwmon/nct6775.c +0
-0default : reg =nct6775_read_value (data, data->REG_FAN_MODE[nr]); reg = (reg & ~data->tolerance_mask) |Reviewed-by Jean Delvare <[email protected]>
Thanks
--
Gustavo
Quoted 5 lines · Gustavo A. R. Silva
In preparation to enabling -Wimplicit-fallthrough, mark switch cases where we are expecting to fall through.
Signed-off-by Gustavo A. R. Silva <[email protected]>Reviewed-by Jean Delvare <[email protected]>
Applied to hwmon-next.
Thanks,
Guenter