lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Wed, 16 Mar 2016 17:04:15 +0000
From:	Hartley Sweeten <HartleyS@...ionengravers.com>
To:	Arnd Bergmann <arnd@...db.de>
CC:	Ian Abbott <abbotti@....co.uk>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Amitoj Kaur Chawla <amitoj1606@...il.com>,
	Bhaktipriya Shridhar <bhaktipriya96@...il.com>,
	"devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: RE: [PATCH] staging/comedi/dt282x: avoid integer overflow warning

On Tuesday, March 15, 2016 2:50 PM, Arnd Bergmann wrote:
> 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@...db.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)

Use a helper macro for those bits:

#define DT2821_SUPCSR_DS(x)		(((x) & 0x3) << 10)
#define DT2821_SUPCSR_DS_PIO		DT2821_SUPCSR_DS(0)
#define DT2821_SUPCSR_DS_AD_CLK		DT2821_SUPCSR_DS(1)
#define DT2821_SUPCSR_DS_DA_CLK		DT2821_SUPCSR_DS(2)
#define DT2821_SUPCSR_DS_AD_TRIG		DT2821_SUPCSR_DS(3)

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

Your change may fix the gcc-6 issue but it doesn't fix the 28 checkpatch.pl
issues:
CHECK: Prefer using the BIT macro

Regards,
Hartley

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ