Werner Zeh has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/31854
Change subject: commonlib/bubblesort: Do not try to sort less than two entries ......................................................................
commonlib/bubblesort: Do not try to sort less than two entries
Before start sorting check for the number of entries in the data set. If there are less than two entries, sorting makes no sense.
Change-Id: Ib9d5522cdebb6559a025217f7faf318589d55a2c Signed-off-by: Werner Zeh werner.zeh@siemens.com --- M src/commonlib/sort.c 1 file changed, 4 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/54/31854/1
diff --git a/src/commonlib/sort.c b/src/commonlib/sort.c index 4099939..350138e 100644 --- a/src/commonlib/sort.c +++ b/src/commonlib/sort.c @@ -23,6 +23,10 @@ size_t i, j; int swapped;
+ /* Make sure there are at least two entries to sort. */ + if (num_entries < 2) + return; + for (j = 0; j < num_entries - 1; j++) { swapped = 0; for (i = 0; i < num_entries - j - 1; i++) {