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>
Cc: "Vladimir 'φ-coder/phcoder' Serbinenko" <phcoder@gmail.com>
Subject: Re: [PATCH] Using enum symbols as indices into menuentry options
Date: Sat, 03 Mar 2012 22:56:52 +0100	[thread overview]
Message-ID: <4F5293A4.6030402@anvo-it.de> (raw)
In-Reply-To: <4F528C11.7060409@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 443 bytes --]


> Keep list CC'ed.
> On 03.03.2012 22:13, Andreas Vogel wrote:
>>> On 03.03.2012 21:50, Andreas Vogel wrote:
>>>> +enum options
>>>> +  {
>>> Please don't define a type here, especially that a type "options" can
>>> easily conflict with something else.
>>>
>> I reused that idea from commands/search_wrap.c and basically i liked
>> that idea.
> Just use an anonymous enum.
>

Please find attached the corrected patch using an anonymous enum.

[-- Attachment #2: 02-menuentry_options_enum.patch --]
[-- Type: text/plain, Size: 1781 bytes --]

=== modified file 'grub-core/commands/menuentry.c'
--- grub-core/commands/menuentry.c	2012-03-01 21:38:32 +0000
+++ grub-core/commands/menuentry.c	2012-03-02 21:46:55 +0000
@@ -25,6 +25,14 @@
 #include <grub/i18n.h>
 #include <grub/normal.h>
 
+enum
+  {
+    O_CLASS = 0,
+    O_USERS,
+    O_HOTKEY,
+    O_SOURCE,
+ };
+
 static const struct grub_arg_option options[] =
   {
     {"class", 1, GRUB_ARG_OPTION_REPEATABLE,
@@ -324,18 +332,18 @@
   if (! argc)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "missing arguments");
 
-  if (ctxt->state[3].set && ctxt->script)
+  if (ctxt->state[O_SOURCE].set && ctxt->script)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "multiple menuentry definitions");
 
-  if (! ctxt->state[3].set && ! ctxt->script)
+  if (! ctxt->state[O_SOURCE].set && ! ctxt->script)
     return grub_error (GRUB_ERR_BAD_ARGUMENT, "no menuentry definition");
 
   if (! ctxt->script)
     return grub_normal_add_menu_entry (argc, (const char **) args,
-				       (ctxt->state[0].set ? ctxt->state[0].args
-					: NULL), ctxt->state[1].arg,
-				       ctxt->state[2].arg, 0,
-				       ctxt->state[3].arg,
+				       (ctxt->state[O_CLASS].set ? ctxt->state[O_CLASS].args
+					: NULL), ctxt->state[O_USERS].arg,
+				       ctxt->state[O_HOTKEY].arg, 0,
+				       ctxt->state[O_SOURCE].arg,
 				       ctxt->extcmd->cmd->name[0] == 's');
 
   src = args[argc - 1];
@@ -350,8 +358,8 @@
     return grub_errno;
 
   r = grub_normal_add_menu_entry (argc - 1, (const char **) args,
-				  ctxt->state[0].args, ctxt->state[1].arg,
-				  ctxt->state[2].arg, prefix, src + 1,
+				  ctxt->state[O_CLASS].args, ctxt->state[O_USERS].arg,
+				  ctxt->state[O_HOTKEY].arg, prefix, src + 1,
 				  ctxt->extcmd->cmd->name[0] == 's');
 
   src[len - 1] = ch;


      reply	other threads:[~2012-03-03 21:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-03 20:50 [PATCH] Using enum symbols as indices into menuentry options Andreas Vogel
2012-03-03 21:03 ` Vladimir 'φ-coder/phcoder' Serbinenko
     [not found]   ` <4F528960.7040308@anvo-it.de>
2012-03-03 21:24     ` Vladimir 'φ-coder/phcoder' Serbinenko
2012-03-03 21:56       ` Andreas Vogel [this message]

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=4F5293A4.6030402@anvo-it.de \
    --to=andreas.vogel@anvo-it.de \
    --cc=grub-devel@gnu.org \
    --cc=phcoder@gmail.com \
    /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.