All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alan Stern <stern@rowland.harvard.edu>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Rui Miguel Silva <rui.silva@linaro.org>,
	kernel test robot <lkp@intel.com>,
	clang-built-linux@googlegroups.com, kbuild-all@lists.01.org,
	linux-usb@vger.kernel.org
Subject: 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: Thu, 19 Aug 2021 11:06:30 -0400	[thread overview]
Message-ID: <20210819150630.GB228422@rowland.harvard.edu> (raw)
In-Reply-To: <YR5xuManlukIAf3L@kroah.com>

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

WARNING: multiple messages have this Message-ID (diff)
From: Alan Stern <stern@rowland.harvard.edu>
To: kbuild-all@lists.01.org
Subject: 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: Thu, 19 Aug 2021 11:06:30 -0400	[thread overview]
Message-ID: <20210819150630.GB228422@rowland.harvard.edu> (raw)
In-Reply-To: <YR5xuManlukIAf3L@kroah.com>

[-- Attachment #1: Type: text/plain, Size: 2484 bytes --]

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

  reply	other threads:[~2021-08-19 15:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 22:09 [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] kernel test robot
2021-08-18 22:09 ` kernel test robot
2021-08-19  7:47 ` Rui Miguel Silva
2021-08-19  7:47   ` Rui Miguel Silva
2021-08-19 14:59   ` Greg Kroah-Hartman
2021-08-19 14:59     ` Greg Kroah-Hartman
2021-08-19 15:06     ` Alan Stern [this message]
2021-08-19 15:06       ` Alan Stern

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210819150630.GB228422@rowland.harvard.edu \
    --to=stern@rowland.harvard.edu \
    --cc=clang-built-linux@googlegroups.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=kbuild-all@lists.01.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=rui.silva@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.