Re: Linux kernel, possible useless continue



On Mar 20, 2:03 am, Rainer Weikusat <rainer.weiku...@xxxxxxxxx> wrote:
Iwo Mergler <Iwo.Merg...@xxxxxxxxxxxxxxxxxxxx> writes:

[...]

pgd_idx = pgd_index(PAGE_OFFSET);
pgd = pgd_base + pgd_idx;
pfn = 0;

for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
pmd = one_md_table_init(pgd);
if (pfn >= max_low_pfn)
continue;

/* Some code which modifies pfn */
}
}

[ ../arch/i386/mm/init.c ]

[...]

All it does is to save an additional level of indentation
and thus making the code more readable IMHO.

A better way to express this would be (IMO more readable and probably
slightly faster):

pgd = pgd_base + pgd_index(PAGE_OFFSET);
pgd_end = pgd_base + PTRS_PER_PGD;
pfn = 0;
do {
pmd = one_md_table_init(pgd);
pmd_end = pmd + PTRS_PER_PMD;
do {
/* pte_t init code */
} while (pfn < max_low_pfn && ++pmd < pmd_end);
} while (++pgd < pgd_end && pfn < max_low_pfn);

while (pgd < pgd_end) one_md_table_init(pgd++);

OTOH, that would trigger several political correctness alerts ...

So in conclusion, the author's purpose is still to avoid another
indention?

.



Relevant Pages