On 2012-12-21 16:42, H Hartley Sweeten wrote:
Clarify the check to make sure the number of bytes to allocate is available. Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx> Cc: Ian Abbott <abbobbi@xxxxxxxxx> Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/comedi/comedi_buf.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/staging/comedi/comedi_buf.c b/drivers/staging/comedi/comedi_buf.c index 1ec5aaa..5be9930 100644 --- a/drivers/staging/comedi/comedi_buf.c +++ b/drivers/staging/comedi/comedi_buf.c @@ -182,13 +182,10 @@ static unsigned int __comedi_buf_write_alloc(struct comedi_async *async, int strict) { unsigned int free_end = async->buf_read_count + async->prealloc_bufsz; + int available = free_end - async->buf_write_alloc_count;
Should preferably be unsigned int.
- if ((int)(async->buf_write_alloc_count + nbytes - free_end) > 0) { - if (strict) - nbytes = 0; - else - nbytes = free_end - async->buf_write_alloc_count; - } + if (nbytes > available) + nbytes = strict ? 0 : available; async->buf_write_alloc_count += nbytes; /* barrier insures the read of buf_read_count above occurs before
-- -=( 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