staging: comedi: comedi_bond: silence a shift wrapping warning
Subsystems (2)
PATCH 1/1 staging: comedi: comedi_bond: silence a shift wrapping warning
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.
drivers/staging/comedi/drivers/comedi_bond.c +1 -1
@@ -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) {
Quoted 10 lines · Dan Carpenter
We set this using:
devs_closed |= (0x1 << bdev->minor)Since
0x1is 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 makingdevs_closeda 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.
Quoted 17 lines
Signed-off-by Dan Carpenter <[email protected]>drivers/staging/comedi/drivers/comedi_bond.c +1
-1@@ -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) {
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 10 lines · Ian Abbott
Quoted 9 lines · Dan Carpenter
We set this using:
devs_closed |= (0x1 << bdev->minor)Since
0x1is 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 makingdevs_closeda 32 bit number.
Quoted 5 lines
Quoted 1 line
32 bits should be enough for anybody.
Not really, as
bdev->minorwill 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
Quoted 11 lines · Dan Carpenter
Quoted 10 lines · Ian Abbott
Quoted 9 lines · Dan Carpenter
We set this using:
devs_closed |= (0x1 << bdev->minor)Since
0x1is 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 makingdevs_closeda 32 bit number.
Quoted 7 lines
Quoted 5 lines
Quoted 1 line
32 bits should be enough for anybody.
Not really, as
bdev->minorwill 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!).
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
Quoted 18 lines · Ian Abbott
Quoted 17 lines · Dan Carpenter
Quoted 15 lines · Ian Abbott
Quoted 10 lines · Dan Carpenter
We set this using:
devs_closed |= (0x1 << bdev->minor)Since
0x1is 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 makingdevs_closeda 32 bit number.32 bits should be enough for anybody.
Not really, as
bdev->minorwill 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.
Quoted 8 lines
Quoted 1 line
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 assumingCOMEDI_NUM_BOARD_MINORSis <= 64. The devs_opened[] indoDevConfig()could also be replaced by a bitmap (it's currently an array of pointers!).
Sure. Let's drop it then.
regards,
dan carpenter
Quoted 21 lines · Dan Carpenter
Quoted 20 lines · Ian Abbott
Quoted 18 lines · Dan Carpenter
Quoted 10 lines · Ian Abbott
Quoted 9 lines · Dan Carpenter
We set this using:
devs_closed |= (0x1 << bdev->minor)Since
0x1is 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 makingdevs_closeda 32 bit number.Quoted 5 lines
Quoted 1 line
32 bits should be enough for anybody.
Not really, as
bdev->minorwill 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.
Quoted 8 lines
Quoted 6 lines
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 assumingCOMEDI_NUM_BOARD_MINORSis <= 64. The devs_opened[] indoDevConfig()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.
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-