From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.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: Tue, 13 Nov 2012 00:03:10 -0800 [thread overview]
Message-ID: <1352793790.24230.18.camel@joe-AO722> (raw)
In-Reply-To: <20121113074454.GB13198@elgon.mountain>
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.
Moving the close parentheses is a pretty common style too
return (val & STR_DATA ? TEA575X_DATA : 0) |
(val & STR_MOST ? TEA575X_MOST : 0);
next prev parent reply other threads:[~2012-11-13 8:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-13 7:44 Dan Carpenter
2012-11-13 7:53 ` Takashi Iwai
2012-11-13 8:03 ` Joe Perches [this message]
2012-11-14 8:27 ` Dan Carpenter
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=1352793790.24230.18.camel@joe-AO722 \
--to=joe@perches.com \
--cc=alsa-devel@alsa-project.org \
--cc=dan.carpenter@oracle.com \
--cc=hdegoede@redhat.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
all inboxes | Powered by JetHome®