diff mbox series

[RESEND] usb: gadget: udc: bdc: Remove unnecessary NULL checks in bdc_req_complete

Message ID 20200329011246.27599-1-natechancellor@gmail.com (mailing list archive)
State Mainlined
Commit 09b04abb70f096333bef6bc95fa600b662e7ee13
Headers show
Series [RESEND] usb: gadget: udc: bdc: Remove unnecessary NULL checks in bdc_req_complete | expand

Commit Message

Nathan Chancellor March 29, 2020, 1:12 a.m. UTC
When building with Clang + -Wtautological-pointer-compare:

drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
address of 'req->queue' equal to a null pointer is always false
[-Wtautological-pointer-compare]
        if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
                             ~~~~~^~~~~    ~~~~
drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
address of 'req->usb_req' equal to a null pointer is always false
[-Wtautological-pointer-compare]
        if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
                                                    ~~~~~^~~~~~~    ~~~~
2 warnings generated.

As it notes, these statements will always evaluate to false so remove
them.

Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
Link: https://github.com/ClangBuiltLinux/linux/issues/749
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
---
 drivers/usb/gadget/udc/bdc/bdc_ep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Felipe Balbi March 29, 2020, 7:43 a.m. UTC | #1
Hi Nathan,

Nathan Chancellor <natechancellor@gmail.com> writes:

> When building with Clang + -Wtautological-pointer-compare:
>
> drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
> address of 'req->queue' equal to a null pointer is always false
> [-Wtautological-pointer-compare]
>         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>                              ~~~~~^~~~~    ~~~~
> drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
> address of 'req->usb_req' equal to a null pointer is always false
> [-Wtautological-pointer-compare]
>         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>                                                     ~~~~~^~~~~~~    ~~~~
> 2 warnings generated.
>
> As it notes, these statements will always evaluate to false so remove
> them.
>
> Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
> Link: https://github.com/ClangBuiltLinux/linux/issues/749
> Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>

It's now in my queue for v5.8. It doesn't really look like a bug fix, so
it's not going in during v5.7-rc
Nathan Chancellor March 29, 2020, 2:47 p.m. UTC | #2
On Sun, Mar 29, 2020 at 10:43:54AM +0300, Felipe Balbi wrote:
> 
> Hi Nathan,
> 
> Nathan Chancellor <natechancellor@gmail.com> writes:
> 
> > When building with Clang + -Wtautological-pointer-compare:
> >
> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
> > address of 'req->queue' equal to a null pointer is always false
> > [-Wtautological-pointer-compare]
> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
> >                              ~~~~~^~~~~    ~~~~
> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
> > address of 'req->usb_req' equal to a null pointer is always false
> > [-Wtautological-pointer-compare]
> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
> >                                                     ~~~~~^~~~~~~    ~~~~
> > 2 warnings generated.
> >
> > As it notes, these statements will always evaluate to false so remove
> > them.
> >
> > Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
> > Link: https://github.com/ClangBuiltLinux/linux/issues/749
> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> 
> It's now in my queue for v5.8. It doesn't really look like a bug fix, so
> it's not going in during v5.7-rc
> 
> -- 
> balbi

Thank you for picking it up. It would be nice to see it in 5.7 since
we're enabling this warning and this is one of two outstanding
instances in -next and the other one's patch has been picked up plus the
patch itself is rather benign. Not to mention that I did send this patch
back in October. However, when it is merged into Linus' tree is
ultimately your call so I won't argue as long as it gets there
eventually.

Cheers,
Nathan
Felipe Balbi March 29, 2020, 4:43 p.m. UTC | #3
Hi,

Nathan Chancellor <natechancellor@gmail.com> writes:
>> > When building with Clang + -Wtautological-pointer-compare:
>> >
>> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
>> > address of 'req->queue' equal to a null pointer is always false
>> > [-Wtautological-pointer-compare]
>> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>> >                              ~~~~~^~~~~    ~~~~
>> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
>> > address of 'req->usb_req' equal to a null pointer is always false
>> > [-Wtautological-pointer-compare]
>> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>> >                                                     ~~~~~^~~~~~~    ~~~~
>> > 2 warnings generated.
>> >
>> > As it notes, these statements will always evaluate to false so remove
>> > them.
>> >
>> > Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
>> > Link: https://github.com/ClangBuiltLinux/linux/issues/749
>> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> 
>> It's now in my queue for v5.8. It doesn't really look like a bug fix, so
>> it's not going in during v5.7-rc
>> 
>> -- 
>> balbi
>
> Thank you for picking it up. It would be nice to see it in 5.7 since
> we're enabling this warning and this is one of two outstanding
> instances in -next and the other one's patch has been picked up plus the
> patch itself is rather benign. Not to mention that I did send this patch
> back in October. However, when it is merged into Linus' tree is
> ultimately your call so I won't argue as long as it gets there
> eventually.

If Greg's okay with this patch going in during v5.7-rc, I can send it as
a fix, no worries. Greg?
Greg Kroah-Hartman March 30, 2020, 6:08 a.m. UTC | #4
On Sun, Mar 29, 2020 at 07:43:52PM +0300, Felipe Balbi wrote:
> 
> Hi,
> 
> Nathan Chancellor <natechancellor@gmail.com> writes:
> >> > When building with Clang + -Wtautological-pointer-compare:
> >> >
> >> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
> >> > address of 'req->queue' equal to a null pointer is always false
> >> > [-Wtautological-pointer-compare]
> >> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
> >> >                              ~~~~~^~~~~    ~~~~
> >> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
> >> > address of 'req->usb_req' equal to a null pointer is always false
> >> > [-Wtautological-pointer-compare]
> >> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
> >> >                                                     ~~~~~^~~~~~~    ~~~~
> >> > 2 warnings generated.
> >> >
> >> > As it notes, these statements will always evaluate to false so remove
> >> > them.
> >> >
> >> > Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
> >> > Link: https://github.com/ClangBuiltLinux/linux/issues/749
> >> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
> >> 
> >> It's now in my queue for v5.8. It doesn't really look like a bug fix, so
> >> it's not going in during v5.7-rc
> >> 
> >> -- 
> >> balbi
> >
> > Thank you for picking it up. It would be nice to see it in 5.7 since
> > we're enabling this warning and this is one of two outstanding
> > instances in -next and the other one's patch has been picked up plus the
> > patch itself is rather benign. Not to mention that I did send this patch
> > back in October. However, when it is merged into Linus' tree is
> > ultimately your call so I won't argue as long as it gets there
> > eventually.
> 
> If Greg's okay with this patch going in during v5.7-rc, I can send it as
> a fix, no worries. Greg?

Yes, clang build warnings fixes are valid fixes for the -rc period, and
I take them into stable where needed as well.

thanks,

greg k-h
Felipe Balbi March 30, 2020, 7:22 a.m. UTC | #5
Hi,

Greg Kroah-Hartman <gregkh@linuxfoundation.org> writes:
>> >> > When building with Clang + -Wtautological-pointer-compare:
>> >> >
>> >> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:28: warning: comparison of
>> >> > address of 'req->queue' equal to a null pointer is always false
>> >> > [-Wtautological-pointer-compare]
>> >> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>> >> >                              ~~~~~^~~~~    ~~~~
>> >> > drivers/usb/gadget/udc/bdc/bdc_ep.c:543:51: warning: comparison of
>> >> > address of 'req->usb_req' equal to a null pointer is always false
>> >> > [-Wtautological-pointer-compare]
>> >> >         if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
>> >> >                                                     ~~~~~^~~~~~~    ~~~~
>> >> > 2 warnings generated.
>> >> >
>> >> > As it notes, these statements will always evaluate to false so remove
>> >> > them.
>> >> >
>> >> > Fixes: efed421a94e6 ("usb: gadget: Add UDC driver for Broadcom USB3.0 device controller IP BDC")
>> >> > Link: https://github.com/ClangBuiltLinux/linux/issues/749
>> >> > Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
>> >> 
>> >> It's now in my queue for v5.8. It doesn't really look like a bug fix, so
>> >> it's not going in during v5.7-rc
>> >> 
>> >> -- 
>> >> balbi
>> >
>> > Thank you for picking it up. It would be nice to see it in 5.7 since
>> > we're enabling this warning and this is one of two outstanding
>> > instances in -next and the other one's patch has been picked up plus the
>> > patch itself is rather benign. Not to mention that I did send this patch
>> > back in October. However, when it is merged into Linus' tree is
>> > ultimately your call so I won't argue as long as it gets there
>> > eventually.
>> 
>> If Greg's okay with this patch going in during v5.7-rc, I can send it as
>> a fix, no worries. Greg?
>
> Yes, clang build warnings fixes are valid fixes for the -rc period, and
> I take them into stable where needed as well.

Thanks for confirming, Greg. I'll move the commit to my testing/fixes
diff mbox series

Patch

diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c
index a4d9b5e1e50e..d49c6dc1082d 100644
--- a/drivers/usb/gadget/udc/bdc/bdc_ep.c
+++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c
@@ -540,7 +540,7 @@  static void bdc_req_complete(struct bdc_ep *ep, struct bdc_req *req,
 {
 	struct bdc *bdc = ep->bdc;
 
-	if (req == NULL  || &req->queue == NULL || &req->usb_req == NULL)
+	if (req == NULL)
 		return;
 
 	dev_dbg(bdc->dev, "%s ep:%s status:%d\n", __func__, ep->name, status);