[PATCH] powerpc: LMB bogus loop conditional removal
Michael Neuling
mikey at neuling.org
Tue Mar 14 16:17:39 EST 2006
In lmb_add_region in mm/lmb.c we have:
/* Couldn't coalesce the LMB, so add it to the sorted table. */
for (i = rgn->cnt-1; i >= 0; i--) {
if (base < rgn->region[i].base) {
rgn->region[i+1].size = rgn->region[i].size;
} else {
rgn->region[i+1].base = base;
rgn->region[i+1].size = size;
break;
}
}
but i is an unsigned long, so i >= 0 is always true. This is OK since
in lmb_init we have an entry where base == 0 and hence we'll always hit
the break.
Patch below removes the bogus i >= 0 and updates the comment.
Signed-off-by: Michael Neuling <mikey at neuling.org>
---
arch/powerpc/mm/lmb.c | 7 +++++--
1 files changed, 5 insertions(+), 2 deletions(-)
Index: linux-2.6-powerpc-merge/arch/powerpc/mm/lmb.c
===================================================================
--- linux-2.6-powerpc-merge.orig/arch/powerpc/mm/lmb.c
+++ linux-2.6-powerpc-merge/arch/powerpc/mm/lmb.c
@@ -164,8 +164,11 @@ static long __init lmb_add_region(struct
if (rgn->cnt >= MAX_LMB_REGIONS)
return -1;
- /* Couldn't coalesce the LMB, so add it to the sorted table. */
- for (i = rgn->cnt-1; i >= 0; i--) {
+ /* Couldn't coalesce the LMB, so add it to the sorted table.
+ * lmb_init ensures we have a region with base == 0, so we'll
+ * always hit the break eventually.
+ */
+ for (i = rgn->cnt - 1; ; i--) {
if (base < rgn->region[i].base) {
rgn->region[i+1].base = rgn->region[i].base;
rgn->region[i+1].size = rgn->region[i].size;
More information about the Linuxppc64-dev
mailing list