From: Andreas Vogel <Andreas.Vogel@anvo-it.de>
To: grub-devel@gnu.org
Subject: [PATCH] Using enum symbols as indices into menuentry options
Date: Sat, 03 Mar 2012 21:50:17 +0100 [thread overview]
Message-ID: <4F528409.2010901@anvo-it.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 349 bytes --]
Here is another tiny patch which uses a enum to reference the options
array when dealing with command line options for a menuentry.
This method is already used by some other modules. I have some more
patches which are adding more options for the menuentry command so
finally readabilty will be improved using these symbols.
Any comments?
Andreas
[-- Attachment #2: 02-menuentry_options_enum.patch --]
[-- Type: text/plain, Size: 2131 bytes --]
------------------------------------------------------------
revno: 4099
committer: Andreas Vogel <Andreas.F.Vogel@gmail.com>
branch nick: 02-menuentry_options_enum
timestamp: Thu 2012-03-01 22:40:25 +0100
message:
* grub-core/commands/menuentry.c: use enum symbols for indexing
the options array in order to improve readability
diff:
=== 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-01 21:40:25 +0000
@@ -25,6 +25,14 @@
#include <grub/i18n.h>
#include <grub/normal.h>
+enum options
+ {
+ 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;
next reply other threads:[~2012-03-03 20:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-03 20:50 Andreas Vogel [this message]
2012-03-03 21:03 ` [PATCH] Using enum symbols as indices into menuentry options 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
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=4F528409.2010901@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.