mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke
@ 2020-04-23 16:29 Nathan Chancellor
  2020-04-23 18:10 ` Nick Desaulniers
  0 siblings, 1 reply; 2+ messages in thread
From: Nathan Chancellor @ 2020-04-23 16:29 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman
  Cc: linux-usb, linux-kernel, clang-built-linux, Nathan Chancellor,
	kbuild test robot

Clang warns:

drivers/usb/gadget/udc/s3c2410_udc.c:255:11: warning: comparison of
address of 'ep->queue' equal to a null pointer is always false
[-Wtautological-pointer-compare]
        if (&ep->queue == NULL)
             ~~~~^~~~~    ~~~~
1 warning generated.

It is not wrong, queue is not a pointer so if ep is not NULL, the
address of queue cannot be NULL. No other driver does a check like this
and this check has been around since the driver was first introduced,
presumably with no issues so it does not seem like this check should be
something else. Just remove it.

Commit afe956c577b2d ("kbuild: Enable -Wtautological-compare") exposed
this but it is not the root cause of the warning.

Fixes: 3fc154b6b8134 ("USB Gadget driver for Samsung s3c2410 ARM SoC")
Link: https://github.com/ClangBuiltLinux/linux/issues/1004
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/usb/gadget/udc/s3c2410_udc.c | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
index 0507a2ca0f552..80002d97b59d8 100644
--- a/drivers/usb/gadget/udc/s3c2410_udc.c
+++ b/drivers/usb/gadget/udc/s3c2410_udc.c
@@ -251,10 +251,6 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep,
 static void s3c2410_udc_nuke(struct s3c2410_udc *udc,
 		struct s3c2410_ep *ep, int status)
 {
-	/* Sanity check */
-	if (&ep->queue == NULL)
-		return;
-
 	while (!list_empty(&ep->queue)) {
 		struct s3c2410_request *req;
 		req = list_entry(ep->queue.next, struct s3c2410_request,

base-commit: ae83d0b416db002fe95601e7f97f64b59514d936
-- 
2.26.2


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke
  2020-04-23 16:29 [PATCH] USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke Nathan Chancellor
@ 2020-04-23 18:10 ` Nick Desaulniers
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Desaulniers @ 2020-04-23 18:10 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Felipe Balbi, Greg Kroah-Hartman, linux-usb, LKML,
	clang-built-linux, kbuild test robot

On Thu, Apr 23, 2020 at 9:30 AM Nathan Chancellor
<natechancellor@gmail.com> wrote:
>
> Clang warns:
>
> drivers/usb/gadget/udc/s3c2410_udc.c:255:11: warning: comparison of
> address of 'ep->queue' equal to a null pointer is always false
> [-Wtautological-pointer-compare]
>         if (&ep->queue == NULL)
>              ~~~~^~~~~    ~~~~
> 1 warning generated.
>
> It is not wrong, queue is not a pointer so if ep is not NULL, the
> address of queue cannot be NULL. No other driver does a check like this
> and this check has been around since the driver was first introduced,
> presumably with no issues so it does not seem like this check should be
> something else. Just remove it.
>
> Commit afe956c577b2d ("kbuild: Enable -Wtautological-compare") exposed
> this but it is not the root cause of the warning.
>
> Fixes: 3fc154b6b8134 ("USB Gadget driver for Samsung s3c2410 ARM SoC")
> Link: https://github.com/ClangBuiltLinux/linux/issues/1004
> Reported-by: kbuild test robot <lkp@intel.com>
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

Thanks for the patch!  If anything, I'd be happy to see some more NULL
checks against `ep`, though the callers of s3c2410_udc_nuke() also
seem quite confident that the pointer is not NULL.

Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>  drivers/usb/gadget/udc/s3c2410_udc.c | 4 ----
>  1 file changed, 4 deletions(-)
>
> diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c
> index 0507a2ca0f552..80002d97b59d8 100644
> --- a/drivers/usb/gadget/udc/s3c2410_udc.c
> +++ b/drivers/usb/gadget/udc/s3c2410_udc.c
> @@ -251,10 +251,6 @@ static void s3c2410_udc_done(struct s3c2410_ep *ep,
>  static void s3c2410_udc_nuke(struct s3c2410_udc *udc,
>                 struct s3c2410_ep *ep, int status)
>  {
> -       /* Sanity check */
> -       if (&ep->queue == NULL)
> -               return;
> -
>         while (!list_empty(&ep->queue)) {
>                 struct s3c2410_request *req;
>                 req = list_entry(ep->queue.next, struct s3c2410_request,
>
> base-commit: ae83d0b416db002fe95601e7f97f64b59514d936
> --
> 2.26.2
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200423162923.10886-1-natechancellor%40gmail.com.



-- 
Thanks,
~Nick Desaulniers

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-04-23 18:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-23 16:29 [PATCH] USB: gadget: udc: s3c2410_udc: Remove pointless NULL check in s3c2410_udc_nuke Nathan Chancellor
2020-04-23 18:10 ` Nick Desaulniers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®