Curent implementation in test_memzone.c has bugs in finding the
second smallest memory segment. It's the last smallest memory segment,
but it's not the second smallest memory segment. This bug may cause test
failure in some cases. This patch fixes this bug.
Signed-off-by: Chao Zhu <chaozhu@linux.vnet.ibm.com>
Acked-by: David Marchand <david.marchand@6wind.com>
/* set new smallest */
min_ms = ms;
- }
- else if (prev_min_ms == NULL) {
+ } else if ((prev_min_ms == NULL)
+ || (prev_min_ms->len > ms->len))
prev_min_ms = ms;
- }
}
if (min_ms == NULL || prev_min_ms == NULL) {
/* set new smallest */
min_ms = ms;
- }
- else if (prev_min_ms == NULL) {
+ } else if ((prev_min_ms == NULL)
+ || (prev_min_ms->len > ms->len)) {
prev_min_ms = ms;
}
}