Re: [PATCH] whereis: move token assignment into loop syntax

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux