Re: [usb:usb-testing 54/97] drivers/usb/isp1760/isp1760-hcd.c:735:2: warning: Value stored to 'scratch' is never read [clang-analyzer-deadcode.DeadStores]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 19, 2021 at 04:59:04PM +0200, Greg Kroah-Hartman wrote:
> On Thu, Aug 19, 2021 at 08:47:37AM +0100, Rui Miguel Silva wrote:
> > Hi,
> > On Wed Aug 18, 2021 at 11:09 PM WEST, kernel test robot wrote:

> > >    drivers/usb/isp1760/isp1760-core.c:490:2: warning: Value stored to 'udc_enabled' is never read [clang-analyzer-deadcode.DeadStores]
> > >            udc_enabled = ((devflags & ISP1760_FLAG_ISP1763) ||
> > >            ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >    drivers/usb/isp1760/isp1760-core.c:490:2: note: Value stored to 'udc_enabled' is never read
> > >            udc_enabled = ((devflags & ISP1760_FLAG_ISP1763) ||
> > >            ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > >    Suppressed 4 warnings (4 in non-user code).
> > >    Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
> > >    4 warnings generated.
> > >    Suppressed 4 warnings (4 in non-user code).
> > >    Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
> > >    9 warnings generated.
> > > >> drivers/usb/isp1760/isp1760-hcd.c:735:2: warning: Value stored to 'scratch' is never read [clang-analyzer-deadcode.DeadStores]
> > >            scratch = isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);
> > >            ^         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> > 
> > yeah, this is desired behaviour, this read is only to make sure  that
> > we make something different than the pattern to test go over the bus.
> > However I will take a look to this warning and other clang warnings
> > that I am seeing in this report.
> 
> This is why I hate this type of warning, doing a read like this is
> totally normal for drivers.  Compilers that think this is something they
> can ignore or warn about are just wrong.

No, no.  The compiler isn't complaining about the call to 
isp1760_hcd_read(); it's complaining about the fact that scratch 
stores the return value.  Since the value isn't used anywhere, there's 
no point in storing it.

You can get rid of the warning by changing the line to:

		(void) isp1760_hcd_read(hcd, HC_CHIP_ID_HIGH);

(The (void) cast isn't really necessary; it's just there to point out 
that the return value is being thrown away.  You can omit it if you 
prefer.)

Likewise for the store to udc_enabled.

Alan Stern



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux