Re: Linux kernel, possible useless continue
- From: Ulrich Eckhardt <doomster@xxxxxxxx>
- Date: Mon, 19 Mar 2007 12:22:05 +0100
Bin Chen wrote:
Below code I am curious in (A)'s continue will bring flow to (B) but
from (B) to (A) no code updates the value of both pfn and max_low_pfn.
So the condition of 'if' will always true. Is it useless?
Yes it is useless.
(B) for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {[...]
pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn)
(A) continue;
for (pmd_idx = 0;
pmd_idx < PTRS_PER_PMD && pfn < max_low_pfn;
pmd++, pmd_idx++) {
}
}
The if-comparison before (A) is the same as the second predicate for the
loop. The only thing this does additionally is set pmd_idx to zero, but if
that code relied on this side-effect of a loop variable it is broken
anyways and either needs to be rewritten or accurately documented.
However, it doesn't. Question is if the comparison in the loop is better
removed (i.e. if the comparison's outcome could change with an inner
iteration) or the outer.
Other than that, Iwo Mergler's comment that one_md_table_init() is called
with the next index indeed applies, and since max_low_pfn is not a local
variable to that function it could indeed be modified.
Uli
.
- Follow-Ups:
- Re: Linux kernel, possible useless continue
- From: Iwo Mergler
- Re: Linux kernel, possible useless continue
- From: Rainer Weikusat
- Re: Linux kernel, possible useless continue
- References:
- Linux kernel, possible useless continue
- From: Bin Chen
- Linux kernel, possible useless continue
- Prev by Date: Re: Adding a new OSI layer
- Next by Date: Re: Linux kernel, possible useless continue
- Previous by thread: Re: Linux kernel, possible useless continue
- Next by thread: Re: Linux kernel, possible useless continue
- Index(es):
Relevant Pages
|