[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <4B147918.3000503@redhat.com>
Date: Tue, 01 Dec 2009 10:02:00 +0800
From: Cong Wang <amwang@...hat.com>
To: Tejun Heo <tj@...nel.org>
CC: Christoph Lameter <cl@...ux-foundation.org>,
linux-kernel@...r.kernel.org, akpm@...ux-foundation.org
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@...nel.org>
> Reported-by: Amerigo Wang <amwang@...hat.com>
> Cc: Christoph Lameter <cl@...ux-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.
--
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