staging: comedi: non working tests on unsigned cmd->convert_arg
vi drivers/staging/comedi/comedi.h +342
and note that cmd->convert_arg in s626_ai_cmdtest() is unsigned. Should there maybe be a test:
if (cmd->convert_src == TRIG_EXT && cmd->convert_arg > MAX)
(and what should MAX be then?)
Otherwise you may want to apply the cleanup patch below
Roel ------------------------------>8-------------8<--------------------------------- Remove redundant tests on unsigned
---
drivers/staging/comedi/drivers/s626.c +1 -1
@@ -1906,7 +1906,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { +if (cmd->convert_src ==TRIG_EXT ) { cmd->convert_arg =0 ; err++; }
Quoted 8 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
The same question for cmd->scan_begin_arg and cmd->start_arg.
Otherwise you may want to apply the cleanup patch below ------------------------------>8-------------8<--------------------------------- Remove redundant tests on unsigned
---
drivers/staging/comedi/drivers/s626.c +3 -3
@@ -1886,7 +1886,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->start_src ==TRIG_EXT && cmd->start_arg <0 ) { +if (cmd->start_src ==TRIG_EXT ) { cmd->start_arg =0 ; err++; }
@@ -1896,7 +1896,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->scan_begin_src ==TRIG_EXT && cmd->scan_begin_arg <0 ) { +if (cmd->scan_begin_src ==TRIG_EXT ) { cmd->scan_begin_arg =0 ; err++; }
@@ -1906,7 +1906,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { +if (cmd->convert_src ==TRIG_EXT ) { cmd->convert_arg =0 ; err++; }
Quoted 8 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
I don't know. Let's ask the comedi developers :)
Frank, what do you think about this?
Quoted 21 lines
Otherwise you may want to apply the cleanup patch below
Roel ------------------------------>8-------------8<--------------------------------- Remove redundant tests on unsigned
Signed-off-by Roel Kluin <[email protected]>---
drivers/staging/comedi/drivers/s626.c +1
-1@@ -1906,7 +1906,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { +if (cmd->convert_src ==TRIG_EXT ) { cmd->convert_arg =0 ; err++; }
Quoted 6 lines · Greg KH
Quoted 5 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:
Quoted 7 lines
Quoted 3 lines
if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
I don't know. Let's ask the comedi developers :)
Frank, what do you think about this?
Ian here. I'd just delete that 'if' statement entirely as the test is never true and it is followed by another 'if' statement that tests the maximum value.
The similar 'if' statements that test cmd->start_arg < 0, and cmd->scan_begin_arg < 0 can also be removed.
Quoted 16 lines
Quoted 16 lines
Otherwise you may want to apply the cleanup patch below
Roel ------------------------------>8-------------8<--------------------------------- Remove redundant tests on unsigned
Signed-off-by Roel Kluin <[email protected]>---
drivers/staging/comedi/drivers/s626.c +0
-0@@ -1906,7 +1906,7 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; }
Quoted 5 lines
drivers/staging/comedi/drivers/s626.c static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s · line 1912
Quoted 5 lines
drivers/staging/comedi/drivers/s626.c +1
-1-if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { +if (cmd->convert_src ==TRIG_EXT ) { cmd->convert_arg =0 ; err++; }
That should be:
- if (cmd->convert_src == TRIG_EXT && cmd->convert_arg < 0) {
- cmd->convert_arg = 0;
- err++;
- }
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Frank Mori Hess
Quoted 10 lines · Greg KH
Quoted 8 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
Quoted 7 lines
Quoted 3 lines
I don't know. Let's ask the comedi developers :)
Frank, what do you think about this?
It looks like there already is such a test, right below the useless one the patch removes.
Ok, thanks for checking. Roel, care to resend these patches then?
thanks,
greg k-h
Quoted 15 lines · Greg KH
Quoted 14 lines · Frank Mori Hess
Quoted 12 lines · Greg KH
Quoted 8 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
I don't know. Let's ask the comedi developers :)
Frank, what do you think about this?
Quoted 9 lines
Quoted 2 lines
It looks like there already is such a test, right below the useless one the patch removes.
Ok, thanks for checking. Roel, care to resend these patches then?
thanks,
greg k-h
So you don't want to set cmd->*_arg to 0 when beyond 39 or below 0? ------------------------------>8-------------8<--------------------------------- Remove tests for negative unsigned.
---
drivers/staging/comedi/drivers/s626.c +0 -15
@@ -1886,31 +1886,16 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->start_src ==TRIG_EXT && cmd->start_arg <0 ) { - cmd->start_arg =0 ; - err++; - } -if (cmd->start_src ==TRIG_EXT && cmd->start_arg >39 ) { cmd->start_arg =39 ; err++; } -if (cmd->scan_begin_src ==TRIG_EXT && cmd->scan_begin_arg <0 ) { - cmd->scan_begin_arg =0 ; - err++; - } -if (cmd->scan_begin_src ==TRIG_EXT && cmd->scan_begin_arg >39 ) { cmd->scan_begin_arg =39 ; err++; } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { - cmd->convert_arg =0 ; - err++; - } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg >39 ) { cmd->convert_arg =39 ; err++;
Quoted 17 lines · Roel Kluin
Quoted 16 lines · Greg KH
Quoted 15 lines · Frank Mori Hess
Quoted 6 lines · Greg KH
Quoted 5 lines · Roel Kluin
vi
drivers/staging/comedi/comedi.h+342and note that
cmd->convert_argins626_ai_cmdtest()is unsigned. Should there maybe be a test:Quoted 6 lines
Quoted 3 lines
if (
cmd->convert_src==TRIG_EXT&&cmd->convert_arg> MAX)(and what should MAX be then?)
I don't know. Let's ask the comedi developers :)
Frank, what do you think about this?
It looks like there already is such a test, right below the useless one the patch removes.
Quoted 7 lines
Quoted 6 lines
Ok, thanks for checking. Roel, care to resend these patches then?
thanks,
greg k-h
So you don't want to set cmd->*_arg to 0 when beyond 39 or below 0?
Well setting cmd->*_arg to 0 when beyond 39 would be a change of functionality, so that's a no-no for a cleanup patch. And it would never be below 0 because it's unsigned, so those 'if' statements in the original were redundant.
Quoted 41 lines
------------------------------>8-------------8<--------------------------------- Remove tests for negative unsigned.
Signed-off-by Roel Kluin <[email protected]>---
drivers/staging/comedi/drivers/s626.c +0
-15@@ -1886,31 +1886,16 @@ static int s626_ai_cmdtest(struct comedi_device *dev, struct comedi_subdevice *s err++; } -if (cmd->start_src ==TRIG_EXT && cmd->start_arg <0 ) { - cmd->start_arg =0 ; - err++; - } -if (cmd->start_src ==TRIG_EXT && cmd->start_arg >39 ) { cmd->start_arg =39 ; err++; } -if (cmd->scan_begin_src ==TRIG_EXT && cmd->scan_begin_arg <0 ) { - cmd->scan_begin_arg =0 ; - err++; - } -if (cmd->scan_begin_src ==TRIG_EXT && cmd->scan_begin_arg >39 ) { cmd->scan_begin_arg =39 ; err++; } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg <0 ) { - cmd->convert_arg =0 ; - err++; - } -if (cmd->convert_src ==TRIG_EXT && cmd->convert_arg >39 ) { cmd->convert_arg =39 ; err++;
Signature · 2 lines
-=( Ian Abbott @ MEV Ltd. E-mail: <[email protected]> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=-