public inbox for util-linux@vger.kernel.org
 help / color / mirror / Atom feed
From: Karel Zak <kzak@redhat.com>
To: "Voelker, Bernhard" <bernhard.voelker@siemens-enterprise.com>
Cc: "dave@gnu.org" <dave@gnu.org>, util-linux <util-linux@vger.kernel.org>
Subject: Re: [PATCH] whereis: move token assignment into loop syntax
Date: Mon, 30 Jan 2012 13:24:01 +0100	[thread overview]
Message-ID: <20120130122401.GB22107@x2.net.home> (raw)
In-Reply-To: <7856072A9D04C24B82DFE2B1112FE38A0D8BBA2C2D@MCHP058A.global-ad.net>

On Mon, Jan 30, 2012 at 10:08:41AM +0100, Voelker, Bernhard wrote:
> Davidlohr Bueso wrote:
> 
> > ... use for() naturally instead.
> 
> > -	for (tmp = pathcp; ; tmp = NULL) {
> > -		tok = strtok_r(tmp, ":", &key);
> > -		if (!tok)
> > -			break;
> > -
> > +	for (tmp = pathcp; tok = strtok_r(tmp, ":", &key); tmp = NULL) {
> >  		/* make sure we don't repeat the search path */
> >  		if (inpath(tok))
> >  			continue;
> 
> hmm, a repetitive assignment like "tmp = NULL" as the increment
> expression of the for-loop doesn't read too natural for me either.
> ;-)

 Yes,

    for (tok = strtok_r(pathcp, ":", &key); tok;
         tok = strtok_r(NULL, ":", &key)) {

 is more readable solution, 'tmp' is unnecessary. Fixed.

    Karel


-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

      reply	other threads:[~2012-01-30 12:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-29 14:25 [PATCH] whereis: move token assignment into loop syntax Davidlohr Bueso
2012-01-30  9:08 ` Voelker, Bernhard
2012-01-30 12:24   ` Karel Zak [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=20120130122401.GB22107@x2.net.home \
    --to=kzak@redhat.com \
    --cc=bernhard.voelker@siemens-enterprise.com \
    --cc=dave@gnu.org \
    --cc=util-linux@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