kernel-janitors.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: walter harms <wharms@bfs.de>
To: kernel-janitors@vger.kernel.org
Subject: Re: [patch] staging: comedi: dt2811: fix a precedence bug
Date: Tue, 21 Jun 2016 15:40:13 +0000	[thread overview]
Message-ID: <57695FDD.2020609@bfs.de> (raw)
In-Reply-To: <20160621114621.GB16941@mwanda>



Am 21.06.2016 15:56, schrieb Ian Abbott:
> On 21/06/16 12:46, Dan Carpenter wrote:
>> Bitwise | has higher precedence than ?: so we need to add some
>> parenthesis for this to work as intended.
>>
>> Fixes: 7c9574090d30 ('staging: comedi: dt2811: simplify A/D reference
>> configuration')
>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>
>> diff --git a/drivers/staging/comedi/drivers/dt2811.c
>> b/drivers/staging/comedi/drivers/dt2811.c
>> index 904f6377..8bbd938 100644
>> --- a/drivers/staging/comedi/drivers/dt2811.c
>> +++ b/drivers/staging/comedi/drivers/dt2811.c
>> @@ -588,8 +588,8 @@ static int dt2811_attach(struct comedi_device
>> *dev, struct comedi_devconfig *it)
>>      s = &dev->subdevices[0];
>>      s->type        = COMEDI_SUBD_AI;
>>      s->subdev_flags    = SDF_READABLE |
>> -              (it->options[2] = 1) ? SDF_DIFF :
>> -              (it->options[2] = 2) ? SDF_COMMON : SDF_GROUND;
>> +              ((it->options[2] = 1) ? SDF_DIFF :
>> +               (it->options[2] = 2) ? SDF_COMMON : SDF_GROUND);
>>      s->n_chan    = (it->options[2] = 1) ? 8 : 16;
>>      s->maxdata    = 0x0fff;
>>      s->range_table    = board->is_pgh ? &dt2811_pgh_ai_ranges
>>
> 

perhaps we can improve readability with something like that (untested):

switch(it->options[2]) {
case 1:
     s->subdev_flags= SDF_READABLE|SDF_DIFF;
     break;
case 2:
     s->subdev_flags= SDF_READABLE|SDF_COMMON;
     break;
default:
     s->subdev_flags=SDF_READABLE|SDF_GROUND;
}

so everyone has a chance to see what is going on.

just my 2 cents,

re,
 wh


> Nice catch, thanks!
> 
> Reviewed-by: Ian Abbott <abbotti@mev.co.uk>
> 

      parent reply	other threads:[~2016-06-21 15:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21 11:46 [patch] staging: comedi: dt2811: fix a precedence bug Dan Carpenter
2016-06-21 13:56 ` Ian Abbott
2016-06-21 15:40 ` walter harms [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=57695FDD.2020609@bfs.de \
    --to=wharms@bfs.de \
    --cc=kernel-janitors@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).