[PATCH] staging: wilc1000: Remove unnecessary pointer check

valdis.kletnieks at vt.edu valdis.kletnieks at vt.edu
Fri Sep 21 05:25:32 UTC 2018


On Thu, 20 Sep 2018 14:26:49 -0700, Nathan Chancellor said:
> Clang warns that the address of a pointer will always evaluated as true
> in a boolean context:
>
> drivers/staging/wilc1000/linux_wlan.c:267:20: warning: address of
> 'vif->ndev->dev' will always evaluate to 'true'
> [-Wpointer-bool-conversion]
>         if (!(&vif->ndev->dev))
>             ~  ~~~~~~~~~~~^~~
> 1 warning generated.
>
> Since this statement always evaluates to false due to the logical not,
> remove it.

Often, "just nuke it because it's now dead code" isn't the best answer...

At one time, that was likely intended to be checking whether ->dev was a null
pointer, to make sure we don't pass request_firmware() a null pointer and oops
the kernel, or other things that go pear-shaped....

So the question becomes:   Is it safe to just remove it, or was it intended to
test for something that could  legitimately be null if we've hit an error along
the way (which means we should fix the condition to be proper and acceptable
to both gcc and clang)?


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 486 bytes
Desc: not available
URL: <http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/attachments/20180921/c9d88a63/attachment-0001.asc>


More information about the devel mailing list