Skip to contentSkip to conversation

hwmon: scmi: Remove redundant pointer check

PATCH Applied Nathan Chancellor 2 participants 2 messages Sep 16, 2018

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

PATCH 1/1 hwmon: scmi: Remove redundant pointer check

Clang warns when the address of a pointer is used in a boolean context as it will always return true.

drivers/hwmon/scmi-hwmon.c:59:24: warning: address of array 'sensor->name' will always evaluate to 'true' [-Wpointer-bool-conversion]

        if (sensor && sensor->name)
                   ~~ ~~~~~~~~^~~~

1 warning generated.

Remove the check as it isn't doing anything currently; if validation of the contents of the data structure was intended by the original author (since this line has been present from the first version of this driver), it can be added in a follow-up patch.

---
 drivers/hwmon/scmi-hwmon.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hwmon/scmi-hwmon.c +1 -1
index 91976b6ca300..2e005edee0c9 100644
@@ -56,7 +56,7 @@ scmi_hwmon_is_visible(const void *drvdata, enum hwmon_sensor_types type,
 	const struct scmi_sensors *scmi_sensors = drvdata;
 
 	sensor = *(scmi_sensors->info[type] + channel);
-	if (sensor && sensor->name)
+	if (sensor)
 		return S_IRUGO;
 
 	return 0;
Signature · 1 line
2.19.0
maintainer Applied
#1 lore raw
Quoted 10 lines · Nathan Chancellor

Clang warns when the address of a pointer is used in a boolean context as it will always return true.

drivers/hwmon/scmi-hwmon.c:59:24: warning: address of array 'sensor->name' will always evaluate to 'true' [-Wpointer-bool-conversion]

         if (sensor && sensor->name)
                    ~~ ~~~~~~~~^~~~

1 warning generated.

Quoted 7 lines

Remove the check as it isn't doing anything currently; if validation of the contents of the data structure was intended by the original author (since this line has been present from the first version of this driver), it can be added in a follow-up patch.

Applied to hwmon-next.

Thanks,
Guenter