From 5838493a3aaa7be688e56b65d13b343cc1336d8c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 7 Dec 2017 14:21:13 +0900 Subject: [PATCH 1/2] bootspec: fix debug message about default entry When no entries matches with entry_oneshot, entry_default and default_pattern, then log message shows a wrong entry. Moreover, if none of entry_oneshot, entry_default and default_pattern are set, then the index `i` is uninitialized. This fixes such problem. --- src/shared/bootspec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index 0481293a50..f71205de5b 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -374,7 +374,7 @@ int boot_entries_select_default(const BootConfig *config) { } if (config->n_entries > 0) - log_debug("Found default: last entry \"%s\"", config->entries[i].filename); + log_debug("Found default: last entry \"%s\"", config->entries[config->n_entries - 1].filename); else log_debug("Found no default boot entry :("); return config->n_entries - 1; /* -1 means "no default" */ From ad1afd60d4cf70c2f2d61c35b345f748f9073654 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Thu, 7 Dec 2017 14:23:11 +0900 Subject: [PATCH 2/2] bootspec: make boot_entries_select_default() static The function is used only in bootspec.c. So, let's make the function static. --- src/shared/bootspec.c | 2 +- src/shared/bootspec.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/shared/bootspec.c b/src/shared/bootspec.c index f71205de5b..dea3c5212a 100644 --- a/src/shared/bootspec.c +++ b/src/shared/bootspec.c @@ -346,7 +346,7 @@ static int boot_entries_uniquify(BootEntry *entries, size_t n_entries) { return 0; } -int boot_entries_select_default(const BootConfig *config) { +static int boot_entries_select_default(const BootConfig *config) { int i; if (config->entry_oneshot) diff --git a/src/shared/bootspec.h b/src/shared/bootspec.h index 391c4a49af..fb8c10a69a 100644 --- a/src/shared/bootspec.h +++ b/src/shared/bootspec.h @@ -52,7 +52,6 @@ typedef struct BootConfig { void boot_entry_free(BootEntry *entry); int boot_entry_load(const char *path, BootEntry *entry); int boot_entries_find(const char *dir, BootEntry **entries, size_t *n_entries); -int boot_entries_select_default(const BootConfig *config); int boot_loader_read_conf(const char *path, BootConfig *config); void boot_config_free(BootConfig *config);