* [PATCH] hwmon: scmi: Remove redundant pointer check
@ 2018-09-16 0:05 Nathan Chancellor
2018-09-16 0:44 ` Guenter Roeck
0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2018-09-16 0:05 UTC (permalink / raw)
To: Guenter Roeck, Jean Delvare
Cc: linux-hwmon, linux-kernel, Nick Desaulniers, 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.
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.
Reported-by: Nick Desaulniers <ndesaulniers@google.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
drivers/hwmon/scmi-hwmon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/hwmon/scmi-hwmon.c b/drivers/hwmon/scmi-hwmon.c
index 91976b6ca300..2e005edee0c9 100644
--- a/drivers/hwmon/scmi-hwmon.c
+++ b/drivers/hwmon/scmi-hwmon.c
@@ -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;
--
2.19.0
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH] hwmon: scmi: Remove redundant pointer check
2018-09-16 0:05 [PATCH] hwmon: scmi: Remove redundant pointer check Nathan Chancellor
@ 2018-09-16 0:44 ` Guenter Roeck
0 siblings, 0 replies; 2+ messages in thread
From: Guenter Roeck @ 2018-09-16 0:44 UTC (permalink / raw)
To: Nathan Chancellor, Jean Delvare
Cc: linux-hwmon, linux-kernel, Nick Desaulniers
On 09/15/2018 05:05 PM, Nathan Chancellor wrote:
> 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.
>
> Reported-by: Nick Desaulniers <ndesaulniers@google.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Applied to hwmon-next.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-09-16 6:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-16 0:05 [PATCH] hwmon: scmi: Remove redundant pointer check Nathan Chancellor
2018-09-16 0:44 ` Guenter Roeck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox