Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Aug 2015 19:40:17 +0300
From:      Konstantin Belousov <kostikbel@gmail.com>
To:        Baptiste Daroussin <bapt@freebsd.org>
Cc:        Bruce Evans <brde@optusnet.com.au>, Bruce Simpson <bms@fastmail.net>, Davide Italiano <davide@freebsd.org>, "src-committers@freebsd.org" <src-committers@freebsd.org>, svn-src-projects@freebsd.org
Subject:   Re: svn commit: r286484 - projects/collation/usr.bin/localedef
Message-ID:  <20150813164017.GK2072@kib.kiev.ua>
In-Reply-To: <20150813061802.GA62875@ivaldir.etoilebsd.net>
References:  <201508082257.t78MvIT1000841@repo.freebsd.org> <CACYV=-GnOpPddd-x_J0yW4g4QFsdcEVXaVc9CER9JD7iObGzAg@mail.gmail.com> <20150812182739.GB51754@ivaldir.etoilebsd.net> <55CB91FD.8000004@fastmail.net> <20150813114425.X996@besplex.bde.org> <20150813061802.GA62875@ivaldir.etoilebsd.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 13, 2015 at 08:18:02AM +0200, Baptiste Daroussin wrote:
> FYI the version proposed for tree(3):
> 
> #define RB_COUNT(x, name, head, cnt) do {	\
> 	(cnt) = 0;				\
> 	RB_FOREACH((x), name, (head)) {		\
> 		(cnt)++;			\
> 	}					\
> } while (0)

Please use some local var for count and assign the result to cnt once,
to avoid multiple evaluations for the argument.

Same issue exists for head, but it usually unimportant due to way
the head is used.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20150813164017.GK2072>