Merge pull request #11933 from keszybz/coverity

Minor tweaks to boot/efi code inspired by coverity
This commit is contained in:
Lennart Poettering
2019-03-13 09:36:57 +01:00
committed by GitHub
3 changed files with 53 additions and 24 deletions
+8 -6
View File
@@ -584,6 +584,12 @@ static int boot_entries_select_default(const BootConfig *config) {
int i;
assert(config);
assert(config->entries || config->n_entries == 0);
if (config->n_entries == 0) {
log_debug("Found no default boot entry :(");
return -1; /* -1 means "no default" */
}
if (config->entry_oneshot)
for (i = config->n_entries - 1; i >= 0; i--)
@@ -609,12 +615,8 @@ static int boot_entries_select_default(const BootConfig *config) {
return i;
}
if (config->n_entries > 0)
log_debug("Found default: last entry \"%s\"", config->entries[config->n_entries - 1].id);
else
log_debug("Found no default boot entry :(");
return config->n_entries - 1; /* -1 means "no default" */
log_debug("Found default: last entry \"%s\"", config->entries[config->n_entries - 1].id);
return config->n_entries - 1;
}
int boot_entries_load_config(