From 02a42a3ff1468e8d04abccba1cc1da46b8a1cfe3 Mon Sep 17 00:00:00 2001 From: Daniel Fullmer Date: Thu, 23 Apr 2020 14:47:56 -0400 Subject: sd-boot: fix menu ordering with boot counting systemd-boot selects the last valid entry by default, not the first. Fixes: #15256 (cherry picked from commit e6190e2882e1d6772a9e586fcc65c91d406e52fb) (cherry picked from commit c5883bc08877d8bad10110434037a3c21950a71a) (cherry picked from commit f047b0706c01f99c1b781f44b7b4d95ecdb8abe2) --- src/boot/efi/boot.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/boot/efi/boot.c b/src/boot/efi/boot.c index ef7ad66eb9..2a84abe131 100644 --- a/src/boot/efi/boot.c +++ b/src/boot/efi/boot.c @@ -1512,11 +1512,11 @@ static VOID config_load_entries( static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) { INTN r; - /* Order entries that have no tries left to the end of the list */ + /* Order entries that have no tries left to the beginning of the list */ if (a->tries_left != 0 && b->tries_left == 0) - return -1; - if (a->tries_left == 0 && b->tries_left != 0) return 1; + if (a->tries_left == 0 && b->tries_left != 0) + return -1; r = str_verscmp(a->id, b->id); if (r != 0) @@ -1526,17 +1526,17 @@ static INTN config_entry_compare(ConfigEntry *a, ConfigEntry *b) { b->tries_left == (UINTN) -1) return 0; - /* If both items have boot counting, and otherwise are identical, put the entry with more tries left first */ + /* If both items have boot counting, and otherwise are identical, put the entry with more tries left last */ if (a->tries_left > b->tries_left) - return -1; - if (a->tries_left < b->tries_left) return 1; + if (a->tries_left < b->tries_left) + return -1; /* If they have the same number of tries left, then let the one win which was tried fewer times so far */ if (a->tries_done < b->tries_done) - return -1; - if (a->tries_done > b->tries_done) return 1; + if (a->tries_done > b->tries_done) + return -1; return 0; } -- cgit v1.2.1