* Clang warning in drivers/hwmon/scmi-hwmon.c
@ 2018-09-15 5:10 Nathan Chancellor
2018-09-15 23:37 ` Guenter Roeck
0 siblings, 1 reply; 3+ messages in thread
From: Nathan Chancellor @ 2018-09-15 5:10 UTC (permalink / raw)
To: Sudeep Holla
Cc: Jean Delvare, Guenter Roeck, linux-hwmon, linux-kernel,
Nick Desaulniers
Hi Sundeep and others,
A group of us are trying to clean up all the warnings we see with an
'allyesconfig' arm64 build done with Clang and this one came up:
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.
Would it be appropriate to just delete that check or does the check
need to be adjusted in some way (such as checking for the first value
'sensor->name[0]')? Either option technically solves the warning but I
don't have the hardware to check if this breaks the driver.
Thanks,
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Clang warning in drivers/hwmon/scmi-hwmon.c
2018-09-15 5:10 Clang warning in drivers/hwmon/scmi-hwmon.c Nathan Chancellor
@ 2018-09-15 23:37 ` Guenter Roeck
2018-09-16 0:06 ` Nathan Chancellor
0 siblings, 1 reply; 3+ messages in thread
From: Guenter Roeck @ 2018-09-15 23:37 UTC (permalink / raw)
To: Nathan Chancellor, Sudeep Holla
Cc: Jean Delvare, linux-hwmon, linux-kernel, Nick Desaulniers
On 09/14/2018 10:10 PM, Nathan Chancellor wrote:
> Hi Sundeep and others,
>
> A group of us are trying to clean up all the warnings we see with an
> 'allyesconfig' arm64 build done with Clang and this one came up:
>
> 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.
>
> Would it be appropriate to just delete that check or does the check
> need to be adjusted in some way (such as checking for the first value
> 'sensor->name[0]')? Either option technically solves the warning but I
> don't have the hardware to check if this breaks the driver.
>
Presumably the check is supposed to validate the content of the data structure,
so dropping the test doesn't seem to make sense. However, one could argue
that, if the _content_ is to be checked, it should be checked earlier,
before the data pointer is stored (ie in scmi_hwmon_probe()).
Given that, I'll be happy to accept a patch to just drop the check; it
does not change the behavior of the driver, after all. If a real validation
is desirable, it can be added (into the probe function) with a separate patch.
Thanks,
Guenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Clang warning in drivers/hwmon/scmi-hwmon.c
2018-09-15 23:37 ` Guenter Roeck
@ 2018-09-16 0:06 ` Nathan Chancellor
0 siblings, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2018-09-16 0:06 UTC (permalink / raw)
To: Guenter Roeck
Cc: Sudeep Holla, Jean Delvare, linux-hwmon, linux-kernel,
Nick Desaulniers
On Sat, Sep 15, 2018 at 04:37:20PM -0700, Guenter Roeck wrote:
> On 09/14/2018 10:10 PM, Nathan Chancellor wrote:
> > Hi Sundeep and others,
> >
> > A group of us are trying to clean up all the warnings we see with an
> > 'allyesconfig' arm64 build done with Clang and this one came up:
> >
> > 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.
> >
> > Would it be appropriate to just delete that check or does the check
> > need to be adjusted in some way (such as checking for the first value
> > 'sensor->name[0]')? Either option technically solves the warning but I
> > don't have the hardware to check if this breaks the driver.
> >
>
> Presumably the check is supposed to validate the content of the data structure,
> so dropping the test doesn't seem to make sense. However, one could argue
> that, if the _content_ is to be checked, it should be checked earlier,
> before the data pointer is stored (ie in scmi_hwmon_probe()).
>
> Given that, I'll be happy to accept a patch to just drop the check; it
> does not change the behavior of the driver, after all. If a real validation
> is desirable, it can be added (into the probe function) with a separate patch.
>
> Thanks,
> Guenter
>
Thank you for the quick response and clarification, patch sent.
Nathan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-09-16 0:06 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-09-15 5:10 Clang warning in drivers/hwmon/scmi-hwmon.c Nathan Chancellor
2018-09-15 23:37 ` Guenter Roeck
2018-09-16 0:06 ` Nathan Chancellor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).