[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1346944293.1680.26.camel@gandalf.local.home>
Date: Thu, 06 Sep 2012 11:11:33 -0400
From: Steven Rostedt <rostedt@...dmis.org>
To: Josh Triplett <josh@...htriplett.org>
Cc: Sasha Levin <levinsasha928@...il.com>,
Mathieu Desnoyers <mathieu.desnoyers@...icios.com>,
Pedro Alves <palves@...hat.com>, Tejun Heo <tj@...nel.org>,
torvalds@...ux-foundation.org, akpm@...ux-foundation.org,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
paul.gortmaker@...driver.com, davem@...emloft.net, mingo@...e.hu,
ebiederm@...ssion.com, aarcange@...hat.com, ericvh@...il.com,
netdev@...r.kernel.org, eric.dumazet@...il.com, axboe@...nel.dk,
agk@...hat.com, dm-devel@...hat.com, neilb@...e.de,
ccaulfie@...hat.com, teigland@...hat.com,
Trond.Myklebust@...app.com, bfields@...ldses.org,
fweisbec@...il.com, jesse@...ira.com,
venkat.x.venkatsubra@...cle.com, ejt@...hat.com,
snitzer@...hat.com, edumazet@...gle.com, linux-nfs@...r.kernel.org,
dev@...nvswitch.org, rds-devel@....oracle.com, lw@...fujitsu.com
Subject: Re: [PATCH v3 01/17] hashtable: introduce a small and naive
hashtable
On Thu, 2012-09-06 at 07:55 -0700, Josh Triplett wrote:
> > My solution to making 'break' work in the iterator is:
> >
> > for (bkt = 0, node = NULL; bkt < HASH_SIZE(name) && node == NULL; bkt++)
> > hlist_for_each_entry(obj, node, &name[bkt], member)
> >
>
> Looks reasonable. However, it would break (or rather, not break) on
> code like this:
>
> hash_for_each_entry(...) {
> if (...) {
> foo(node);
> node = NULL;
> break;
> }
> }
>
> Hiding the double loop still seems error-prone.
We've already had this conversation ;-) A guess a big comment is in
order:
/*
* NOTE! Although this is a double loop, 'break' still works because of
* the 'node == NULL' condition in the outer loop. On break of
* the inner loop, node will be !NULL, and the outer loop will
* exit as well.
*/
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists