Messages in this thread | | | Date | Tue, 01 Dec 2009 10:02:00 +0800 | From | Cong Wang <> | Subject | Re: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk() |
| |
Tejun Heo wrote: > pcpu_[de]populate_chunk() check whether there's actually any work to > do at the beginning and exit early if not. This checking is done by > seeing whether the first iteration of pcpu_for_each_[un]pop_region() > covers the whole requested region. The resulting code is a bit > unusual in that it's loop-like but never loops which apparently > confuses people. Add comments to explain it. > > Signed-off-by: Tejun Heo <tj@kernel.org> > Reported-by: Amerigo Wang <amwang@redhat.com> > Cc: Christoph Lameter <cl@linux-foundation.org> > --- > Added to percpu#for-next. This should be clear enough, right? >
Nope, comments can never fix bad code.
Since these two break statements are intentional, why not use if? Logically, the following two are equalent.
for(a1; a2; a3){ if (a4) return; break; }
a1; if (a2) { if (a4) return; }
And the latter is much more readable than the former.
| |