public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Joe Perches <joe@perches.com>
Cc: Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
	Mauro Carvalho Chehab <mchehab@redhat.com>,
	Ondrej Zary <linux@rainbow-software.org>,
	Hans de Goede <hdegoede@redhat.com>,
	Rusty Russell <rusty@rustcorp.com.au>,
	alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: Re: [patch] ALSA: es1968: precedence bug in snd_es1968_tea575x_get_pins()
Date: Wed, 14 Nov 2012 11:27:39 +0300	[thread overview]
Message-ID: <20121114082739.GF11566@mwanda> (raw)
In-Reply-To: <1352793790.24230.18.camel@joe-AO722>

On Tue, Nov 13, 2012 at 12:03:10AM -0800, Joe Perches wrote:
> On Tue, 2012-11-13 at 10:44 +0300, Dan Carpenter wrote:
> > I don't think this works as intended.  '|' higher precedence than ?: so
> > the bitwize OR "0 | (val & STR_MOST)" is a no-op.
> > 
> > I have re-written it to be more clear.
> []
> > diff --git a/sound/pci/es1968.c b/sound/pci/es1968.c
> []
> > @@ -2581,9 +2581,14 @@ static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
> >  	struct es1968 *chip = tea->private_data;
> >  	unsigned long io = chip->io_port + GPIO_DATA;
> >  	u16 val = inw(io);
> > -
> > -	return  (val & STR_DATA) ? TEA575X_DATA : 0 |
> > -		(val & STR_MOST) ? TEA575X_MOST : 0;
> > +	u8 ret;
> > +
> > +	ret = 0;
> > +	if (val & STR_DATA)
> > +		ret |= TEA575X_DATA;
> > +	if (val & STR_MOST)
> > +		ret |= TEA575X_MOST;
> > +	return ret;
> 
> Cute.  smatch I presume?  Tools are useful.

Yep.  This is a smatch thing.

> 
> Moving the close parentheses is a pretty common style too
> 
> 	return  (val & STR_DATA ? TEA575X_DATA : 0) |
> 		(val & STR_MOST ? TEA575X_MOST : 0);

That would work as well, of course.  I don't have a strong
preference either way.

regards,
dan carpenter


  reply	other threads:[~2012-11-14  8:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-13  7:44 [patch] ALSA: es1968: precedence bug in snd_es1968_tea575x_get_pins() Dan Carpenter
2012-11-13  7:53 ` Takashi Iwai
2012-11-13  8:03 ` Joe Perches
2012-11-14  8:27   ` Dan Carpenter [this message]
2012-11-14 21:24 ` Ondrej Zary

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=20121114082739.GF11566@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=hdegoede@redhat.com \
    --cc=joe@perches.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rainbow-software.org \
    --cc=mchehab@redhat.com \
    --cc=perex@perex.cz \
    --cc=rusty@rustcorp.com.au \
    --cc=tiwai@suse.de \
    /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