From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pratyush Yadav <p.yadav@ti.com>
Cc: Jay Fang <f.fangjian@huawei.com>,
linux-spi@vger.kernel.org, broonie@kernel.org,
huangdaode@huawei.com
Subject: Re: [PATCH] spi: cadence-quadspi: Silence shiftTooManyBitsSigned warning
Date: Fri, 5 Mar 2021 12:42:42 +0300 [thread overview]
Message-ID: <20210305094242.GH2222@kadam> (raw)
In-Reply-To: <20210304193427.rdtu75tv6invjq2d@ti.com>
On Fri, Mar 05, 2021 at 01:04:27AM +0530, Pratyush Yadav wrote:
> On 04/03/21 04:08PM, Dan Carpenter wrote:
> > On Thu, Mar 04, 2021 at 06:47:52PM +0800, Jay Fang wrote:
> > > drivers/spi/spi-cadence-quadspi.c:267:18: warning: Shifting signed 32-bit
> > > value by 31 bits is undefined behaviour [shiftTooManyBitsSigned]
> > > return reg & (1 << CQSPI_REG_CONFIG_IDLE_LSB);
> > > ^
> > >
> > > Reported-by: kernel test robot <lkp@intel.com>
> > > Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> > > Signed-off-by: Jay Fang <f.fangjian@huawei.com>
> > > ---
> > > drivers/spi/spi-cadence-quadspi.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
> > > index 442cc7c..9a2798a5 100644
> > > --- a/drivers/spi/spi-cadence-quadspi.c
> > > +++ b/drivers/spi/spi-cadence-quadspi.c
> > > @@ -264,7 +264,7 @@ static bool cqspi_is_idle(struct cqspi_st *cqspi)
> > > {
> > > u32 reg = readl(cqspi->iobase + CQSPI_REG_CONFIG);
> > >
> > > - return reg & (1 << CQSPI_REG_CONFIG_IDLE_LSB);
> > > + return reg & (1UL << CQSPI_REG_CONFIG_IDLE_LSB);
> >
> > This is always going to be false because reg is a u32.
>
> Hmm... I don't see why it would always be false. reg would promoted to
> unsigned long and the result should then depend on the actual value of
> the bit, which can be represented by an unsigned long. There is no loss
> of information.
>
> Anyway, it still makes more sense to make it 1U because reg is u32. Just
> keep the types same and avoid all the conversion rules.
Ah, crap. I'm sorry. I somehow thought when I forwarded this bug the
other day that CQSPI_REG_CONFIG_IDLE_LSB was more than 31.
regards,
dan carpenter
next prev parent reply other threads:[~2021-03-05 9:43 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-04 10:47 [PATCH] spi: cadence-quadspi: Silence shiftTooManyBitsSigned warning Jay Fang
2021-03-04 13:08 ` Dan Carpenter
2021-03-04 19:34 ` Pratyush Yadav
2021-03-05 9:42 ` Dan Carpenter [this message]
2021-03-08 16:08 ` Mark Brown
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=20210305094242.GH2222@kadam \
--to=dan.carpenter@oracle.com \
--cc=broonie@kernel.org \
--cc=f.fangjian@huawei.com \
--cc=huangdaode@huawei.com \
--cc=linux-spi@vger.kernel.org \
--cc=p.yadav@ti.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox