netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Al Viro <viro@ZenIV.linux.org.uk>
To: chas3@users.sourceforge.net
Cc: Roel Kluin <roel.kluin@gmail.com>,
	netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] ATM: misplaced parentheses?
Date: Mon, 16 Feb 2009 22:30:01 +0000	[thread overview]
Message-ID: <20090216223001.GW28946@ZenIV.linux.org.uk> (raw)
In-Reply-To: <200902162202.n1GM2aI0009056@cmf.nrl.navy.mil>

On Mon, Feb 16, 2009 at 05:02:36PM -0500, Chas Williams (CONTRACTOR) wrote:
> that doesnt seem to make sense either.  the original code
> is:
> 
>  		for (i = 128; i != 0; i >>= 1) {   /* write command out */
> ...
>  			tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
> 			    (data & i) ? CONFIG1_PROMDATA : 0;
> 
> since i is always positive here, you wouldnt need the ?: if your suggested
> fix is the original intent.  it looks like setting CONFIG1_PROMDATA
> means '1' and not setting it means '0' when writing the value of data
> to the register.

What the hell does it have to do with i being positive?  || variant is,
of course, silly; it's very obvious what's going on here.  Garden-variety
bit-banging, IOW
  			tmp = (lanai->conf1 & ~CONFIG1_PROMDATA) |
 			    ((data & i) ? CONFIG1_PROMDATA : 0);
and while you technically only need parens around ?:, in this case it's
better to keep it fully parenthesised - more readable that way.

The lack of parens around ?: in the current tree is an obvious bug.

  reply	other threads:[~2009-02-16 22:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-15 16:07 [PATCH] ATM: misplaced parentheses? Roel Kluin
2009-02-16 22:02 ` Chas Williams (CONTRACTOR)
2009-02-16 22:30   ` Al Viro [this message]
2009-02-17  9:59     ` Roel Kluin
2009-02-19  1:41       ` David Miller

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=20090216223001.GW28946@ZenIV.linux.org.uk \
    --to=viro@zeniv.linux.org.uk \
    --cc=akpm@linux-foundation.org \
    --cc=chas3@users.sourceforge.net \
    --cc=netdev@vger.kernel.org \
    --cc=roel.kluin@gmail.com \
    /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).