* [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
@ 2013-08-21 8:27 Dan Carpenter
2013-08-21 10:50 ` Ian Abbott
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Dan Carpenter @ 2013-08-21 8:27 UTC (permalink / raw)
To: kernel-janitors
We set this using:
devs_closed |= (0x1 << bdev->minor)
Since 0x1 is an int then only the lower 32 bits are usable before we hit
a shift wrapping bug. There are some static checkers which complain
about this. I've silenced the warning by making devs_closed a 32 bit
number.
32 bits should be enough for anybody.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
index 7e20bf0..8f6c942 100644
--- a/drivers/staging/comedi/drivers/comedi_bond.c
+++ b/drivers/staging/comedi/drivers/comedi_bond.c
@@ -335,7 +335,7 @@ static int bonding_attach(struct comedi_device *dev,
static void bonding_detach(struct comedi_device *dev)
{
struct comedi_bond_private *devpriv = dev->private;
- unsigned long devs_closed = 0;
+ unsigned int devs_closed = 0;
if (devpriv) {
while (devpriv->ndevs-- && devpriv->devs) {
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
@ 2013-08-21 10:50 ` Ian Abbott
2013-08-21 12:45 ` Dan Carpenter
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Ian Abbott @ 2013-08-21 10:50 UTC (permalink / raw)
To: kernel-janitors
On 2013-08-21 09:27, Dan Carpenter wrote:
> We set this using:
>
> devs_closed |= (0x1 << bdev->minor)
>
> Since 0x1 is an int then only the lower 32 bits are usable before we hit
> a shift wrapping bug. There are some static checkers which complain
> about this. I've silenced the warning by making devs_closed a 32 bit
> number.
>
> 32 bits should be enough for anybody.
Not really, as bdev->minor will be in the range 0 to 47 inclusive (0 to
COMEDI_NUM_BOARD_MINORS-1). Of course, an unsigned long is insufficient
too on a 32-bit system.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/drivers/staging/comedi/drivers/comedi_bond.c b/drivers/staging/comedi/drivers/comedi_bond.c
> index 7e20bf0..8f6c942 100644
> --- a/drivers/staging/comedi/drivers/comedi_bond.c
> +++ b/drivers/staging/comedi/drivers/comedi_bond.c
> @@ -335,7 +335,7 @@ static int bonding_attach(struct comedi_device *dev,
> static void bonding_detach(struct comedi_device *dev)
> {
> struct comedi_bond_private *devpriv = dev->private;
> - unsigned long devs_closed = 0;
> + unsigned int devs_closed = 0;
>
> if (devpriv) {
> while (devpriv->ndevs-- && devpriv->devs) {
>
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
2013-08-21 10:50 ` Ian Abbott
@ 2013-08-21 12:45 ` Dan Carpenter
2013-08-21 16:44 ` Ian Abbott
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2013-08-21 12:45 UTC (permalink / raw)
To: kernel-janitors
On Wed, Aug 21, 2013 at 11:50:22AM +0100, Ian Abbott wrote:
> On 2013-08-21 09:27, Dan Carpenter wrote:
> >We set this using:
> >
> > devs_closed |= (0x1 << bdev->minor)
> >
> >Since 0x1 is an int then only the lower 32 bits are usable before we hit
> >a shift wrapping bug. There are some static checkers which complain
> >about this. I've silenced the warning by making devs_closed a 32 bit
> >number.
> >
> >32 bits should be enough for anybody.
>
> Not really, as bdev->minor will be in the range 0 to 47 inclusive (0
> to COMEDI_NUM_BOARD_MINORS-1). Of course, an unsigned long is
> insufficient too on a 32-bit system.
Ok. I'll make it a u64 in a v2 patch.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
2013-08-21 10:50 ` Ian Abbott
2013-08-21 12:45 ` Dan Carpenter
@ 2013-08-21 16:44 ` Ian Abbott
2013-08-21 20:08 ` Dan Carpenter
2013-08-22 19:21 ` Ian Abbott
4 siblings, 0 replies; 6+ messages in thread
From: Ian Abbott @ 2013-08-21 16:44 UTC (permalink / raw)
To: kernel-janitors
On 2013-08-21 13:45, Dan Carpenter wrote:
> On Wed, Aug 21, 2013 at 11:50:22AM +0100, Ian Abbott wrote:
>> On 2013-08-21 09:27, Dan Carpenter wrote:
>>> We set this using:
>>>
>>> devs_closed |= (0x1 << bdev->minor)
>>>
>>> Since 0x1 is an int then only the lower 32 bits are usable before we hit
>>> a shift wrapping bug. There are some static checkers which complain
>>> about this. I've silenced the warning by making devs_closed a 32 bit
>>> number.
>>>
>>> 32 bits should be enough for anybody.
>>
>> Not really, as bdev->minor will be in the range 0 to 47 inclusive (0
>> to COMEDI_NUM_BOARD_MINORS-1). Of course, an unsigned long is
>> insufficient too on a 32-bit system.
>
> Ok. I'll make it a u64 in a v2 patch.
If you want, we could drop that, and I could rework it to use
DECLARE_BITMAP() and the functions in <linux/bitmap.h> to avoid assuming
COMEDI_NUM_BOARD_MINORS is <= 64. The devs_opened[] in doDevConfig()
could also be replaced by a bitmap (it's currently an array of pointers!).
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
` (2 preceding siblings ...)
2013-08-21 16:44 ` Ian Abbott
@ 2013-08-21 20:08 ` Dan Carpenter
2013-08-22 19:21 ` Ian Abbott
4 siblings, 0 replies; 6+ messages in thread
From: Dan Carpenter @ 2013-08-21 20:08 UTC (permalink / raw)
To: kernel-janitors
On Wed, Aug 21, 2013 at 05:44:34PM +0100, Ian Abbott wrote:
> On 2013-08-21 13:45, Dan Carpenter wrote:
> >On Wed, Aug 21, 2013 at 11:50:22AM +0100, Ian Abbott wrote:
> >>On 2013-08-21 09:27, Dan Carpenter wrote:
> >>>We set this using:
> >>>
> >>> devs_closed |= (0x1 << bdev->minor)
> >>>
> >>>Since 0x1 is an int then only the lower 32 bits are usable before we hit
> >>>a shift wrapping bug. There are some static checkers which complain
> >>>about this. I've silenced the warning by making devs_closed a 32 bit
> >>>number.
> >>>
> >>>32 bits should be enough for anybody.
> >>
> >>Not really, as bdev->minor will be in the range 0 to 47 inclusive (0
> >>to COMEDI_NUM_BOARD_MINORS-1). Of course, an unsigned long is
> >>insufficient too on a 32-bit system.
> >
> >Ok. I'll make it a u64 in a v2 patch.
>
> If you want, we could drop that, and I could rework it to use
> DECLARE_BITMAP() and the functions in <linux/bitmap.h> to avoid
> assuming COMEDI_NUM_BOARD_MINORS is <= 64. The devs_opened[] in
> doDevConfig() could also be replaced by a bitmap (it's currently an
> array of pointers!).
>
Sure. Let's drop it then.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
` (3 preceding siblings ...)
2013-08-21 20:08 ` Dan Carpenter
@ 2013-08-22 19:21 ` Ian Abbott
4 siblings, 0 replies; 6+ messages in thread
From: Ian Abbott @ 2013-08-22 19:21 UTC (permalink / raw)
To: kernel-janitors
On 2013-08-21 21:08, Dan Carpenter wrote:
> On Wed, Aug 21, 2013 at 05:44:34PM +0100, Ian Abbott wrote:
>> On 2013-08-21 13:45, Dan Carpenter wrote:
>>> On Wed, Aug 21, 2013 at 11:50:22AM +0100, Ian Abbott wrote:
>>>> On 2013-08-21 09:27, Dan Carpenter wrote:
>>>>> We set this using:
>>>>>
>>>>> devs_closed |= (0x1 << bdev->minor)
>>>>>
>>>>> Since 0x1 is an int then only the lower 32 bits are usable before we hit
>>>>> a shift wrapping bug. There are some static checkers which complain
>>>>> about this. I've silenced the warning by making devs_closed a 32 bit
>>>>> number.
>>>>>
>>>>> 32 bits should be enough for anybody.
>>>>
>>>> Not really, as bdev->minor will be in the range 0 to 47 inclusive (0
>>>> to COMEDI_NUM_BOARD_MINORS-1). Of course, an unsigned long is
>>>> insufficient too on a 32-bit system.
>>>
>>> Ok. I'll make it a u64 in a v2 patch.
>>
>> If you want, we could drop that, and I could rework it to use
>> DECLARE_BITMAP() and the functions in <linux/bitmap.h> to avoid
>> assuming COMEDI_NUM_BOARD_MINORS is <= 64. The devs_opened[] in
>> doDevConfig() could also be replaced by a bitmap (it's currently an
>> array of pointers!).
>>
>
> Sure. Let's drop it then.
Okay, let's drop it. I have a series of 13 patches to apply to this
driver to tidy it up a bit and fix various bugs. I'll send them
tomorrow after a bit of testing.
--
-=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@mev.co.uk> )=-
-=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-08-22 19:21 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-21 8:27 [patch] staging: comedi: comedi_bond: silence a shift wrapping warning Dan Carpenter
2013-08-21 10:50 ` Ian Abbott
2013-08-21 12:45 ` Dan Carpenter
2013-08-21 16:44 ` Ian Abbott
2013-08-21 20:08 ` Dan Carpenter
2013-08-22 19:21 ` Ian Abbott
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox