Re: [patch] staging: comedi: comedi_bond: silence a shift wrapping warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

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@xxxxxxxxx>        )=-
-=( Tel: +44 (0)161 477 1898   FAX: +44 (0)161 718 3587         )=-
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux