Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1584797

Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple line dereference

From Ian Abbott <abbotti@mev.co.uk>
Newsgroups linux.kernel
Subject Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple line dereference
Date 2017-02-20 18:40 +0100
Message-ID <td06m-7EN-27@gated-at.bofh.it> (permalink)
References <tcRFM-2hh-15@gated-at.bofh.it> <tcT4T-3ij-37@gated-at.bofh.it> <tcYHf-6QY-9@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On 20/02/17 16:02, Cheah Kok Cheong wrote:
> On Mon, Feb 20, 2017 at 10:03:39AM +0000, Ian Abbott wrote:
>> On 20/02/17 08:28, Cheah Kok Cheong wrote:
>>> Fix checkpatch warning "Avoid multiple line dereference"
>>> using a local variable to avoid line wrap.
>>>
>>> Signed-off-by: Cheah Kok Cheong <thrust73@gmail.com>
>>> ---
>>> drivers/staging/comedi/drivers/comedi_test.c | 6 ++----
>>> 1 file changed, 2 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/drivers/staging/comedi/drivers/comedi_test.c b/drivers/staging/comedi/drivers/comedi_test.c
>>> index 2a063f0..fde83e0 100644
>>> --- a/drivers/staging/comedi/drivers/comedi_test.c
>>> +++ b/drivers/staging/comedi/drivers/comedi_test.c
>>> @@ -480,11 +480,9 @@ static void waveform_ao_timer(unsigned long arg)
>>> 			/* output the last scan */
>>> 			for (i = 0; i < cmd->scan_end_arg; i++) {
>>> 				unsigned int chan = CR_CHAN(cmd->chanlist[i]);
>>> +				unsigned short d = devpriv->ao_loopbacks[chan];
>>>
>>> -				if (comedi_buf_read_samples(s,
>>> -							    &devpriv->
>>> -							     ao_loopbacks[chan],
>>> -							    1) == 0) {
>>> +				if (!comedi_buf_read_samples(s, &d, 1)) {
>>> 					/* unexpected underrun! (cancelled?) */
>>> 					async->events |= COMEDI_CB_OVERFLOW;
>>> 					goto underrun;
>>>
>>
>> NAK.  This leaves devpriv->ao_loopbacks[chan] unchanged.
>>
>
> Thanks for pointing this out. In that case will assigning the variable to
> devpriv->ao_loopbacks[chan] be acceptable? Please review below snippet.
>
> Otherwise I'll just drop the variable and adjust the lines to avoid
> checkpatch warning.
>
> Sorry for the inconvenience caused.
>
> [ Snip ]
>
> 			/* output the last scan */
> 			for (i = 0; i < cmd->scan_end_arg; i++) {
> 				unsigned int chan = CR_CHAN(cmd->chanlist[i]);
> 				unsigned short data;
>
> 				if (!comedi_buf_read_samples(s, &data, 1)) {
> 					/* unexpected underrun! (cancelled?) */
> 					async->events |= COMEDI_CB_OVERFLOW;
> 					goto underrun;
> 				}
>
> 				devpriv->ao_loopbacks[chan] = data;
> 			}
> 			/* advance time of last scan */
>
> [ Snip ]

It will work, but you could just use a pointer variable set to 
&devpriv->ao_loopbacks[chan] and pass that to comedi_buf_read_samples().

-- 
-=( Ian Abbott @ MEV Ltd.    E-mail: <abbotti@mev.co.uk> )=-
-=(                          Web: http://www.mev.co.uk/  )=-

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple line dereference Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-20 09:40 +0100
  Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Ian Abbott <abbotti@mev.co.uk> - 2017-02-20 11:10 +0100
    Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-20 17:10 +0100
      Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Ian Abbott <abbotti@mev.co.uk> - 2017-02-20 18:40 +0100
        Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-21 10:40 +0100
          Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Ian Abbott <abbotti@mev.co.uk> - 2017-02-21 11:20 +0100
            Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Valentin Rothberg <valentinrothberg@gmail.com> - 2017-02-21 11:30 +0100
              Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Cheah Kok Cheong <thrust73@gmail.com> - 2017-02-21 17:40 +0100
                Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Joe Perches <joe@perches.com> - 2017-02-21 18:30 +0100
                Re: [PATCH] Staging: comedi: drivers: comedi_test: Avoid multiple  line dereference Valentin Rothberg <valentinrothberg@gmail.com> - 2017-02-22 09:40 +0100

csiph-web