Re: [PATCH] percpu: explain quick paths in pcpu_[de]populate_chunk()

From: Cong Wang
Date: Mon Nov 30 2009 - 20:59:46 EST


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@xxxxxxxxxx>
Reported-by: Amerigo Wang <amwang@xxxxxxxxxx>
Cc: Christoph Lameter <cl@xxxxxxxxxxxxxxxxxxxx>
---
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.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/