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>,
"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning
Date: Thu, 17 Mar 2016 17:08:34 +0100 [thread overview]
Message-ID: <3053856.pfRJflhkJ8@wuerfel> (raw)
In-Reply-To: <BN3PR0101MB1057257A9A9915F22A8DF0ABD08B0@BN3PR0101MB1057.prod.exchangelabs.com>
On Thursday 17 March 2016 15:47:57 Hartley Sweeten wrote:
> On Wednesday, March 16, 2016 1:51 PM, Arnd Bergmann wrote:
>
> Is this a gcc-6 specific issue? Seems line this warning should be showing
> up in a lot of drivers.
Yes, I did not see this before moving to gcc-6.0, but this is the only driver
I've encountered the warning for, in around 7000 randconfig builds.
> > 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.
> >
> > As pointed out by Hartley Sweeten, scripts/checkpatch.pl notices that
> > the shifts here are rather unreadable, though the suggested BIT()
> > macro wouldn't work either. I'm changing it to a hexadecimal notation,
> > which hopefully improves readability. I'm leaving the DT2821_CHANCSR_PRESLA
> > alone because it seems wrong.
>
> BIT() should work for the ones pointed out by checpatch.pl.
>
> I would argue that the hexadecimal notation is still rather unreadable.
> These ones make my head hurt...
>
> -#define DT2821_ADCSR_GS(x) (((x) & 0x3) << 4)
> +#define DT2821_ADCSR_GS(x) (0x0030u & ((x) << 4))
>
> -#define DT2821_DACSR_YSEL(x) ((x) << 9)
> +#define DT2821_DACSR_YSEL(x) (0x7e00u & (x) << 9)
>
> -#define DT2821_SUPCSR_DS_PIO (0 << 10)
> -#define DT2821_SUPCSR_DS_AD_CLK (1 << 10)
> -#define DT2821_SUPCSR_DS_DA_CLK (2 << 10)
> -#define DT2821_SUPCSR_DS_AD_TRIG (3 << 10)
> +#define DT2821_SUPCSR_DS_PIO (0x0c00u & (0u << 10))
> +#define DT2821_SUPCSR_DS_AD_CLK (0x0c00u & (1u << 10))
> +#define DT2821_SUPCSR_DS_DA_CLK (0x0c00u & (2u << 10))
> +#define DT2821_SUPCSR_DS_AD_TRIG (0x0c00u & (3u << 10))
Feel free to come up with a different patch. I've put the patch on
my 'submitted' stack for now and will get back to it after 4.7-rc1 if
the warning remains.
> Also, most of the comedi drivers use the BIT() macro. Are you planning on
> changing all of them to use hexadecimal notation?
No.
Arnd
next prev parent reply other threads:[~2016-03-17 16:08 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-03-16 20:51 Arnd Bergmann
2016-03-17 10:21 ` Ian Abbott
2016-03-17 15:47 ` Hartley Sweeten
2016-03-17 16:08 ` Arnd Bergmann [this message]
2016-03-17 16:59 ` Hartley Sweeten
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=3053856.pfRJflhkJ8@wuerfel \
--to=arnd@arndb.de \
--cc=HartleyS@visionengravers.com \
--cc=abbotti@mev.co.uk \
--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
all inboxes | Powered by JetHome®