All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] oxygen: clean up. make precedence explicit
Date: Fri, 19 Feb 2010 13:10:47 +0300	[thread overview]
Message-ID: <20100219101047.GB17130@bicker> (raw)
In-Reply-To: <4B7E4BD1.3040106@ladisch.de>

On Fri, Feb 19, 2010 at 09:29:05AM +0100, Clemens Ladisch wrote:
> > This doesn't change anything, but I think it makes the code clearer.
> > It silences a smatch warning:
> > sound/pci/oxygen/oxygen_mixer.c +91 dac_mute_put(7) warn: add some parenthesis here?
> 
> That message doesn't say why some parentheses should be added.
> And it's a question; how do I give it the answer "no"?  :-)
> 
> > -	changed = !value->value.integer.value[0] != chip->dac_mute;
> > +	changed = (!value->value.integer.value[0]) != chip->dac_mute;
> 
> This doesn't look any clearer to me; I don't think that the unary
> negation operator could be thought to have lower precedence than "!=".
> 

Well, it's hard to argue that it's more ambiguous.  :P

> Why does smatch warn about this combination?  Do such errors actually
> happen?
> 

Yep.  I have made some myself when writing smatch.

For example here are some related bugs in the current kernel.

drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
   721          if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
   722              ext->alg != IW_ENCODE_ALG_WEP)
   723                  if (idx != 0 || ieee->iw_mode != IW_MODE_INFRA)
   724                          return -EINVAL;

                        if (!j->dsp.low != 0x20) {

drivers/telephony/ixj.c
  6834                          if (!j->dsp.low != 0x20) {

Mostly the real bugs have been fixed now.  Roel Kluin fixed quite a 
few of these before and I've fixed a couple.

regards,
dan carpenter

> 
> Regards,
> Clemens
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Clemens Ladisch <clemens@ladisch.de>
Cc: Takashi Iwai <tiwai@suse.de>,
	alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] oxygen: clean up. make precedence explicit
Date: Fri, 19 Feb 2010 10:10:47 +0000	[thread overview]
Message-ID: <20100219101047.GB17130@bicker> (raw)
In-Reply-To: <4B7E4BD1.3040106@ladisch.de>

On Fri, Feb 19, 2010 at 09:29:05AM +0100, Clemens Ladisch wrote:
> > This doesn't change anything, but I think it makes the code clearer.
> > It silences a smatch warning:
> > sound/pci/oxygen/oxygen_mixer.c +91 dac_mute_put(7) warn: add some parenthesis here?
> 
> That message doesn't say why some parentheses should be added.
> And it's a question; how do I give it the answer "no"?  :-)
> 
> > -	changed = !value->value.integer.value[0] != chip->dac_mute;
> > +	changed = (!value->value.integer.value[0]) != chip->dac_mute;
> 
> This doesn't look any clearer to me; I don't think that the unary
> negation operator could be thought to have lower precedence than "!=".
> 

Well, it's hard to argue that it's more ambiguous.  :P

> Why does smatch warn about this combination?  Do such errors actually
> happen?
> 

Yep.  I have made some myself when writing smatch.

For example here are some related bugs in the current kernel.

drivers/staging/rtl8192u/ieee80211/ieee80211_wx.c
   721          if (!ext->ext_flags & IW_ENCODE_EXT_GROUP_KEY &&
   722              ext->alg != IW_ENCODE_ALG_WEP)
   723                  if (idx != 0 || ieee->iw_mode != IW_MODE_INFRA)
   724                          return -EINVAL;

                        if (!j->dsp.low != 0x20) {

drivers/telephony/ixj.c
  6834                          if (!j->dsp.low != 0x20) {

Mostly the real bugs have been fixed now.  Roel Kluin fixed quite a 
few of these before and I've fixed a couple.

regards,
dan carpenter

> 
> Regards,
> Clemens
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

  reply	other threads:[~2010-02-19 10:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-19  8:29 [patch] oxygen: clean up. make precedence explicit Clemens Ladisch
2010-02-19  8:29 ` Clemens Ladisch
2010-02-19 10:10 ` Dan Carpenter [this message]
2010-02-19 10:10   ` Dan Carpenter
2010-02-19 10:33 ` Bernd Petrovitsch
2010-02-19 11:29   ` Dan Carpenter
2010-02-19 11:29     ` Dan Carpenter
2010-02-19 16:58     ` Dan Carpenter
2010-02-19 16:58       ` Dan Carpenter
2010-02-19 13:09 ` Bernd Petrovitsch
2010-02-19 17:24   ` Clemens Ladisch
2010-02-19 17:24     ` Clemens Ladisch
2010-02-19 20:08     ` Dan Carpenter
2010-02-19 20:08       ` Dan Carpenter
  -- strict thread matches above, loose matches on Subject: below --
2010-02-19  6:58 Dan Carpenter
2010-02-19  6:58 ` Dan Carpenter

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=20100219101047.GB17130@bicker \
    --to=error27@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=kernel-janitors@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.