All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andreas Vogel <Andreas.Vogel@anvo-it.de>
To: The development of GNU GRUB <grub-devel@gnu.org>
Subject: Re: default menuentry matching similar entries is broken
Date: Sat, 03 Mar 2012 19:10:28 +0100	[thread overview]
Message-ID: <4F525E94.2080304@anvo-it.de> (raw)
In-Reply-To: <BD0AA701-E11B-4396-A7C2-8309DD7C0A61@oracle.com>


> Hi,
>
>   This code in menu.c::menuentry_eq() looks wrong:
>
> {
>   const char *ptr1, *ptr2;
>   ptr1 = title;
>   ptr2 = spec;
>   while (1)
>     {
>       if (*ptr2 == '>' && ptr2[1] != '>' && *ptr1 == 0)
>         return 1;
>       if (*ptr2 == '>' && ptr2[1] != '>')
>         return 0;
>       if (*ptr2 == '>')
>         ptr2++;
>       if (*ptr1 != *ptr2)
>         return 0;
>       if (*ptr1 == 0)   <----
>         return 1;
>       ptr1++;
>       ptr2++;
>     }
> }
>
>
>   Specifically, if there are two menuentries that differ by adding characters, this function will match the wrong one, i.e.:
>
> set default='entry a with more words'
>
> menuentry "entry a" {
> }
>
> menuentry "entry a with more words" {
> }
As far as I understand the code, using submenu references in the default
variable for automatic booting is not working at all.
This is due to the dynamic loading of submenus. When a menu is opened
and run, only the direct menu entries are known. Searching for menu
entries deeper in the menu tree is not done.

Let's consider this scenario:

set default="b>c>c1"

menuentry a { ... }
submenu b {
    submenu c {
        menuentry c1 { ... }
    }
}

When the toplevel menu is run, the code just knows about entries a and b
(entries c and c1 are not know at this moment).
Searching and booting the menu entry according to the default variable
doesn't work. Actually I didn't try this, that's just from code reading
so i might be wrong.

IMHO, right now the menuentry_eq() function is overkill as a normal
strcmp() would be sufficient.

Furthermore it's strange that calling
    menuentry_eq ("a>b", "a>b")
returns 0. I didn't expect this result.


Andreas



  parent reply	other threads:[~2012-03-03 18:10 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-03  7:33 default menuentry matching similar entries is broken Seth Goldberg
2012-03-03 11:09 ` Vladimir 'φ-coder/phcoder' Serbinenko
     [not found]   ` <31DA57F5-04BF-42DA-811D-277D5FD1E7B7@oracle.com>
2012-03-03 14:12     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-03 18:10 ` Andreas Vogel [this message]
2012-03-03 18:20   ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-03 19:04     ` Andreas Vogel
2012-03-03 19:17       ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-03 19:29         ` Andreas Vogel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F525E94.2080304@anvo-it.de \
    --to=andreas.vogel@anvo-it.de \
    --cc=grub-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.