Skip to content

Commit 748ea32

Browse files
nathanchancempe
authored andcommitted
macintosh: windfarm: Use unsigned type for 1-bit bitfields
Clang warns: drivers/macintosh/windfarm_lm75_sensor.c:63:14: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] lm->inited = 1; ^ ~ drivers/macintosh/windfarm_smu_sensors.c:356:19: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] pow->fake_volts = 1; ^ ~ drivers/macintosh/windfarm_smu_sensors.c:368:18: error: implicit truncation from 'int' to a one-bit wide bit-field changes value from 1 to -1 [-Werror,-Wsingle-bit-bitfield-constant-conversion] pow->quadratic = 1; ^ ~ There is no bug here since no code checks the actual value of these fields, just whether or not they are zero (boolean context), but this can be easily fixed by switching to an unsigned type. Signed-off-by: Nathan Chancellor <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/20230215-windfarm-wsingle-bit-bitfield-constant-conversion-v1-1-26415072e855@kernel.org
1 parent b0ae5b6 commit 748ea32

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

drivers/macintosh/windfarm_lm75_sensor.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
#endif
3434

3535
struct wf_lm75_sensor {
36-
int ds1775 : 1;
37-
int inited : 1;
36+
unsigned int ds1775 : 1;
37+
unsigned int inited : 1;
3838
struct i2c_client *i2c;
3939
struct wf_sensor sens;
4040
};

drivers/macintosh/windfarm_smu_sensors.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -274,8 +274,8 @@ struct smu_cpu_power_sensor {
274274
struct list_head link;
275275
struct wf_sensor *volts;
276276
struct wf_sensor *amps;
277-
int fake_volts : 1;
278-
int quadratic : 1;
277+
unsigned int fake_volts : 1;
278+
unsigned int quadratic : 1;
279279
struct wf_sensor sens;
280280
};
281281
#define to_smu_cpu_power(c) container_of(c, struct smu_cpu_power_sensor, sens)

0 commit comments

Comments
 (0)