Re: [PATCH 09/11] staging: comedi: comedi_buf: clarify comedi_buf_read_alloc()

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

 



On 2013-01-03 20:02, H Hartley Sweeten wrote:
On Thursday, January 03, 2013 5:02 AM, Dan Carpenter wrote:
On Wed, Jan 02, 2013 at 01:12:15PM -0600, H Hartley Sweeten wrote:
On Wednesday, January 02, 2013 12:03 PM, Ian Abbott wrote:
On 02/01/2013 18:10, H Hartley Sweeten wrote:
Will the munge_count always be larger, or equal, to the buf_read_alloc_count?
The original code had the (int) cast so I wasn't sure. If so, then yes the variable
should be an unsigned int.

Well the value it is being compared to (nbytes) is an unsigned int, so
the int value (available) will be converted to unsigned int before the
comparison anyway.  So making 'available' an unsigned int to begin with
shouldn't break anything that isn't already broke!

Not so. Simple test:


Uh...  Ian is correct.  In the new code it doesn't matter if
"available" is signed or unsigned because the comparison is always
promoted to unsigned.

Ah.. you are correct.

Hmmm.. Is the current code actually correct? I need to take a closer
look at it.

I vaguely remember doing that a few years ago to satisfy my curiosity because the code looked a bit unusual. It may be a false memory though!

--
-=( 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/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