summaryrefslogtreecommitdiffstats
path: root/discover/grub2/script.c
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javierm@redhat.com>2019-06-20 18:09:55 +0200
committerSamuel Mendoza-Jonas <sam@mendozajonas.com>2019-06-21 13:42:15 +1000
commit53e0f3ef35ac694220dce135f01a4f736cbd1c19 (patch)
tree719881f0d1ef1bd0b8ab9dfc44f897ee83f592f4 /discover/grub2/script.c
parentcd95d81c16bd7f312214e2800bf0600f96f9307c (diff)
downloadtalos-petitboot-53e0f3ef35ac694220dce135f01a4f736cbd1c19.tar.gz
talos-petitboot-53e0f3ef35ac694220dce135f01a4f736cbd1c19.zip
discover/grub2: Allow using title for default even if id was defined
A default menu entry can be chosen using any of the following attributes: index, title or id (if the entry was defined with the --id option). But Petitboot doesn't honor this correctly and only compares the default with the menu entry title if the entry doesn't have an id defined. This is wrong since an index or title can be used even if an id was defined. This issue wasn't covered by the test that sets a default using a title because the menu entries didn't have an id defined. Add an id to them. Signed-off-by: Javier Martinez Canillas <javierm@redhat.com> Signed-off-by: Samuel Mendoza-Jonas <sam@mendozajonas.com>
Diffstat (limited to 'discover/grub2/script.c')
-rw-r--r--discover/grub2/script.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/discover/grub2/script.c b/discover/grub2/script.c
index 902df90..c910bf8 100644
--- a/discover/grub2/script.c
+++ b/discover/grub2/script.c
@@ -117,12 +117,10 @@ static bool option_is_default(struct grub2_script *script,
if (end != var && *end == '\0')
return default_idx == script->n_options;
- /* if we don't have an explicit id for this option, fall back to
- * the name */
- if (!id)
- id = opt->option->name;
+ if (id && !strcmp(id, var))
+ return true;
- return !strcmp(id, var);
+ return !strcmp(opt->option->name, var);
}
static void append_text_to_current_arg(struct grub2_argv *argv,
OpenPOWER on IntegriCloud