From: Chao Zhu Date: Tue, 25 Nov 2014 22:17:16 +0000 (-0500) Subject: app/test: fix finding the second smallest memory segment X-Git-Tag: spdx-start~10043 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=6e8ae24ab83d475471e54916a39c00d44276a51a;p=dpdk.git app/test: fix finding the second smallest memory segment 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 Acked-by: David Marchand --- diff --git a/app/test/test_memzone.c b/app/test/test_memzone.c index 387dbbcc2e..1658006529 100644 --- a/app/test/test_memzone.c +++ b/app/test/test_memzone.c @@ -797,10 +797,9 @@ test_memzone_reserve_memory_in_smallest_segment(void) /* 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) { @@ -877,8 +876,8 @@ test_memzone_reserve_memory_with_smallest_offset(void) /* 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; } }