Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1359963
| Path | csiph.com!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | Hartley Sweeten <HartleyS@visionengravers.com> |
| Newsgroups | linux.kernel |
| Subject | RE: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning |
| Date | Thu, 17 Mar 2016 16:50:01 +0100 |
| Message-ID | <rdIlr-MU-3@gated-at.bofh.it> (permalink) |
| References | <rdqHT-5Ja-11@gated-at.bofh.it> |
| Thread-Topic | [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning |
| Thread-Index | AQHRf8Wrp8TTHLyDSEGX7TkInjYrEp9dxbXg |
| Accept-Language | en-US |
| Content-Language | en-US |
| Authentication-Results | arndb.de; dkim=none (message not signed) header.d=none;arndb.de; dmarc=none action=none header.from=visionengravers.com; |
| X-Originating-IP | [184.183.19.121] |
| X-Ms-Office365-Filtering-Correlation-ID | bd41836d-ac5d-45b3-adbe-08d34e7b838a |
| X-Microsoft-Exchange-Diagnostics | 1;BN3PR0101MB1060;5:cZbfu/EWayPzzLKnOBM6B9LQalvX41fHQ0dot+GeaagWz/CJHgaNbNaQTteB1Ciktp0kSGwhdfLpZhyLQw3hGjioHBt0J62EyEVkg1ooXdOiVXQyASuF9dyZodZjLMCzKfZHzW+uiRNLyo2Qpjt9EA==;24:ap5MmQfhkKeAjOWDChG4sRUUWfvXsy+ilNLzsSPqU/OMh6mzHKYBaQF9O20WZCxHPMAiAXgI897E3CDWDgeCLcNAiqIIMex76w1rlNkgCI0= |
| X-Microsoft-Antispam | UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0101MB1060; |
| X-Microsoft-Antispam-Prvs | <BN3PR0101MB1060C3A075D676CCE4072913D08B0@BN3PR0101MB1060.prod.exchangelabs.com> |
| X-Exchange-Antispam-Report-Test | UriScan:; |
| X-Exchange-Antispam-Report-Cfa-Test | BCL:0;PCL:0;RULEID:(6040046)(2401047)(8121501046)(5005006)(10201501046)(3002001)(6041046)(6043046);SRVR:BN3PR0101MB1060;BCL:0;PCL:0;RULEID:;SRVR:BN3PR0101MB1060; |
| X-Forefront-Prvs | 0884AAA693 |
| X-Forefront-Antispam-Report | SFV:NSPM;SFS:(10019020)(6009001)(377454003)(24454002)(77096005)(5003600100002)(2900100001)(2950100001)(106116001)(10400500002)(87936001)(5004730100002)(19580395003)(5002640100001)(122556002)(11100500001)(76176999)(66066001)(3280700002)(86362001)(575784001)(4326007)(189998001)(102836003)(5008740100001)(586003)(3846002)(54356999)(1096002)(6116002)(110136002)(2906002)(81166005)(80792005)(1220700001)(33656002)(92566002)(74316001)(50986999)(3660700001);DIR:OUT;SFP:1102;SCL:1;SRVR:BN3PR0101MB1060;H:BN3PR0101MB1057.prod.exchangelabs.com;FPR:;SPF:None;MLV:sfv;LANG:en; |
| Spamdiagnosticoutput | 1:23 |
| Spamdiagnosticmetadata | NSPM |
| Content-Type | text/plain; charset="us-ascii" |
| Content-Transfer-Encoding | 8BIT |
| MIME-Version | 1.0 |
| X-Originatororg | visionengravers.com |
| X-Ms-Exchange-Crosstenant-Originalarrivaltime | 17 Mar 2016 15:47:57.9926 (UTC) |
| X-Ms-Exchange-Crosstenant-Fromentityheader | Hosted |
| X-Ms-Exchange-Crosstenant-ID | d698601f-af92-4269-8099-fd6f11636477 |
| X-Ms-Exchange-Transport-Crosstenantheadersstamped | BN3PR0101MB1060 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 67 |
| Organization | linux.* mail to news gateway |
| X-Original-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> |
| X-Original-Date | Thu, 17 Mar 2016 15:47:57 +0000 |
| X-Original-Message-ID | <BN3PR0101MB1057257A9A9915F22A8DF0ABD08B0@BN3PR0101MB1057.prod.exchangelabs.com> |
| X-Original-References | <1458161501-283680-1-git-send-email-arnd@arndb.de> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1359963 |
Show key headers only | View raw
On Wednesday, March 16, 2016 1:51 PM, Arnd Bergmann wrote: > > gcc-6 warns about passing negative signed integer into swab16() > in the dt282x driver: > > drivers/staging/comedi/drivers/dt282x.c: In function 'dt282x_load_changain': > include/uapi/linux/swab.h:14:33: warning: integer overflow in expression [-Woverflow] > (((__u16)(x) & (__u16)0xff00U) >> 8))) > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ > include/uapi/linux/swab.h:107:2: note: in expansion of macro '___constant_swab16' > ___constant_swab16(x) : \ > ^~~~~~~~~~~~~~~~~~ > include/uapi/linux/byteorder/big_endian.h:34:43: note: in expansion of macro '__swab16' > #define __cpu_to_le16(x) ((__force __le16)__swab16((x))) > ^~~~~~~~ > include/linux/byteorder/generic.h:89:21: note: in expansion of macro '__cpu_to_le16' > #define cpu_to_le16 __cpu_to_le16 > ^~~~~~~~~~~~~ > arch/arm/include/asm/io.h:250:6: note: in expansion of macro 'cpu_to_le16' > cpu_to_le16(v),__io(p)); }) > ^~~~~~~~~~~ > drivers/staging/comedi/drivers/dt282x.c:566:2: note: in expansion of macro 'outw' > outw(DT2821_CHANCSR_LLE | DT2821_CHANCSR_NUMB(n), > ^~~~ Arnd, Is this a gcc-6 specific issue? Seems line this warning should be showing up in a lot of drivers. > 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)) Also, most of the comedi drivers use the BIT() macro. Are you planning on changing all of them to use hexadecimal notation? Regards, Hartley
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2] staging/comedi/dt282x: avoid integer overflow warning Arnd Bergmann <arnd@arndb.de> - 2016-03-16 22:00 +0100
Re: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning Ian Abbott <abbotti@mev.co.uk> - 2016-03-17 11:30 +0100
RE: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning Hartley Sweeten <HartleyS@visionengravers.com> - 2016-03-17 16:50 +0100
Re: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning Arnd Bergmann <arnd@arndb.de> - 2016-03-17 17:10 +0100
RE: [PATCH v2] staging/comedi/dt282x: avoid integer overflow warning Hartley Sweeten <HartleyS@visionengravers.com> - 2016-03-17 18:00 +0100
csiph-web