lkml.org 
[lkml]   [2009]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [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.


\
 
 \ /
  Last update: 2009-12-01 03:01    [W:0.076 / U:0.208 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site