public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnd Bergmann <arnd@arndb.de>
To: Hartley Sweeten <HartleyS@visionengravers.com>
Cc: Ian Abbott <abbotti@mev.co.uk>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Amitoj Kaur Chawla <amitoj1606@gmail.com>,
	Bhaktipriya Shridhar <bhaktipriya96@gmail.com>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] staging/comedi/dt282x: avoid integer overflow warning
Date: Tue, 15 Mar 2016 22:50:16 +0100	[thread overview]
Message-ID: <3577040.FW0X5IMTpl@wuerfel> (raw)
In-Reply-To: <BN3PR0101MB1057ABAE207C199306C431C0D0890@BN3PR0101MB1057.prod.exchangelabs.com>

On Tuesday 15 March 2016 21:35:40 Hartley Sweeten wrote:
> On Monday, March 14, 2016 3:48 PM, Arnd Bergmann wrote:
> > gcc-6 warns about passing negative signed integer into swab16()
> > in the dt282x driver:
> 
> <snip>
> 
> > The warning makes sense, though the code is correct as far as I
> > can tell.
> >
> > This disambiguates the operation by making the constant expressions
> > we pass here explicitly 'unsigned', which helps to avoid the warning.
> >
> > Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> > ---
> >  drivers/staging/comedi/drivers/dt282x.c | 62 ++++++++++++++++-----------------
> >  1 file changed, 31 insertions(+), 31 deletions(-)
> >
> > diff --git a/drivers/staging/comedi/drivers/dt282x.c b/drivers/staging/comedi/drivers/dt282x.c
> > index 40bf00984fa5..d4d45c759c62 100644
> > --- a/drivers/staging/comedi/drivers/dt282x.c
> > +++ b/drivers/staging/comedi/drivers/dt282x.c
> > @@ -69,48 +69,48 @@
> >   * Register map
> >   */
> >  #define DT2821_ADCSR_REG		0x00
> > -#define DT2821_ADCSR_ADERR		(1 << 15)
> > -#define DT2821_ADCSR_ADCLK		(1 << 9)
> > -#define DT2821_ADCSR_MUXBUSY		(1 << 8)
> > -#define DT2821_ADCSR_ADDONE		(1 << 7)
> > -#define DT2821_ADCSR_IADDONE		(1 << 6)
> > +#define DT2821_ADCSR_ADERR		(1u << 15)
> 
> Changing all of these to use the BIT() macro should also avoid the warning.

Yes, but it won't work for the ones that have more than one bit:

#define DT2821_SUPCSR_DS_AD_TRIG       (3 << 10)

I considered using BIT() but decided against it for consistency.

	Arnd

  reply	other threads:[~2016-03-15 21:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-14 22:48 [PATCH] staging/comedi/dt282x: avoid integer overflow warning Arnd Bergmann
2016-03-15 21:35 ` Hartley Sweeten
2016-03-15 21:50   ` Arnd Bergmann [this message]
2016-03-16 17:04     ` Hartley Sweeten
2016-03-16 20:52       ` Arnd Bergmann

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=3577040.FW0X5IMTpl@wuerfel \
    --to=arnd@arndb.de \
    --cc=HartleyS@visionengravers.com \
    --cc=abbotti@mev.co.uk \
    --cc=amitoj1606@gmail.com \
    --cc=bhaktipriya96@gmail.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox