Blame SOURCES/0075-Remove-several-trivially-unnecessary-uses-of-nested-.patch

f96e0b
From 78def2574a02429cb43d5f6a44a607315cdcee68 Mon Sep 17 00:00:00 2001
f96e0b
From: Colin Watson <cjwatson@ubuntu.com>
f96e0b
Date: Mon, 31 Dec 2012 17:31:38 +0000
f96e0b
Subject: [PATCH 075/482] Remove several trivially-unnecessary uses of nested
f96e0b
 functions.
f96e0b
f96e0b
* grub-core/commands/i386/pc/sendkey.c
f96e0b
(grub_cmd_sendkey: find_key_code, find_ascii_code): Make static
f96e0b
instead of nested.
f96e0b
* grub-core/commands/legacycfg.c (legacy_file: getline): Likewise.
f96e0b
Rename to ...
f96e0b
(legacy_file_getline): ... this.
f96e0b
* grub-core/commands/loadenv.c (grub_cmd_load_env: set_var):
f96e0b
Likewise.
f96e0b
* grub-core/kern/corecmd.c (grub_core_cmd_set: print_env): Likewise.
f96e0b
* grub-core/kern/fs.c (grub_fs_probe: dummy_func): Likewise.  Rename
f96e0b
to ...
f96e0b
(probe_dummy_iter): ... this.
f96e0b
* grub-core/kern/i386/coreboot/mmap.c
f96e0b
(grub_linuxbios_table_iterate: check_signature): Likewise.
f96e0b
* grub-core/kern/parser.c (grub_parser_split_cmdline:
f96e0b
check_varstate): Likewise.  Mark inline.
f96e0b
* grub-core/lib/arg.c (find_short: fnd_short): Likewise.  Pass
f96e0b
an additional parameter.
f96e0b
(find_long: fnd_long): Likewise.  Pass two additional parameters.
f96e0b
* grub-core/lib/crc.c (init_crc32c_table: reflect): Likewise.
f96e0b
* grub-core/lib/crc64.c (init_crc64_table: reflect): Likewise.
f96e0b
* grub-core/lib/ieee1275/cmos.c (grub_cmos_find_port: hook):
f96e0b
Likewise.  Rename to ...
f96e0b
(grub_cmos_find_port_iter): ... this.
f96e0b
* grub-core/lib/ieee1275/datetime.c (find_rtc: hook): Likewise.
f96e0b
Rename to ...
f96e0b
(find_rtc_iter): ... this.
f96e0b
f96e0b
* grub-core/normal/menu_entry.c (run): Fold nested editor_getsource
f96e0b
function directly into the function body, since it is only called
f96e0b
once.
f96e0b
---
f96e0b
 ChangeLog                            | 36 ++++++++++++++++
f96e0b
 grub-core/commands/i386/pc/sendkey.c | 65 ++++++++++++++--------------
f96e0b
 grub-core/commands/legacycfg.c       | 20 ++++-----
f96e0b
 grub-core/commands/loadenv.c         | 15 ++++---
f96e0b
 grub-core/kern/corecmd.c             | 16 +++----
f96e0b
 grub-core/kern/fs.c                  | 20 ++++-----
f96e0b
 grub-core/kern/i386/coreboot/mmap.c  | 19 +++++----
f96e0b
 grub-core/kern/parser.c              | 20 ++++-----
f96e0b
 grub-core/lib/arg.c                  | 58 +++++++++++++------------
f96e0b
 grub-core/lib/crc.c                  | 31 +++++++-------
f96e0b
 grub-core/lib/crc64.c                | 31 +++++++-------
f96e0b
 grub-core/lib/ieee1275/cmos.c        | 82 ++++++++++++++++++------------------
f96e0b
 grub-core/lib/ieee1275/datetime.c    | 27 ++++++------
f96e0b
 grub-core/normal/menu_entry.c        | 50 +++++++++-------------
f96e0b
 14 files changed, 264 insertions(+), 226 deletions(-)
f96e0b
f96e0b
diff --git a/ChangeLog b/ChangeLog
f96e0b
index 36f1bff..8723bfa 100644
f96e0b
--- a/ChangeLog
f96e0b
+++ b/ChangeLog
f96e0b
@@ -1,3 +1,39 @@
f96e0b
+2012-12-31  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
+
f96e0b
+	Remove several trivially-unnecessary uses of nested functions.
f96e0b
+
f96e0b
+	* grub-core/commands/i386/pc/sendkey.c
f96e0b
+	(grub_cmd_sendkey: find_key_code, find_ascii_code): Make static
f96e0b
+	instead of nested.
f96e0b
+	* grub-core/commands/legacycfg.c (legacy_file: getline): Likewise.
f96e0b
+	Rename to ...
f96e0b
+	(legacy_file_getline): ... this.
f96e0b
+	* grub-core/commands/loadenv.c (grub_cmd_load_env: set_var):
f96e0b
+	Likewise.
f96e0b
+	* grub-core/kern/corecmd.c (grub_core_cmd_set: print_env): Likewise.
f96e0b
+	* grub-core/kern/fs.c (grub_fs_probe: dummy_func): Likewise.  Rename
f96e0b
+	to ...
f96e0b
+	(probe_dummy_iter): ... this.
f96e0b
+	* grub-core/kern/i386/coreboot/mmap.c
f96e0b
+	(grub_linuxbios_table_iterate: check_signature): Likewise.
f96e0b
+	* grub-core/kern/parser.c (grub_parser_split_cmdline:
f96e0b
+	check_varstate): Likewise.  Mark inline.
f96e0b
+	* grub-core/lib/arg.c (find_short: fnd_short): Likewise.  Pass
f96e0b
+	an additional parameter.
f96e0b
+	(find_long: fnd_long): Likewise.  Pass two additional parameters.
f96e0b
+	* grub-core/lib/crc.c (init_crc32c_table: reflect): Likewise.
f96e0b
+	* grub-core/lib/crc64.c (init_crc64_table: reflect): Likewise.
f96e0b
+	* grub-core/lib/ieee1275/cmos.c (grub_cmos_find_port: hook):
f96e0b
+	Likewise.  Rename to ...
f96e0b
+	(grub_cmos_find_port_iter): ... this.
f96e0b
+	* grub-core/lib/ieee1275/datetime.c (find_rtc: hook): Likewise.
f96e0b
+	Rename to ...
f96e0b
+	(find_rtc_iter): ... this.
f96e0b
+
f96e0b
+	* grub-core/normal/menu_entry.c (run): Fold nested editor_getsource
f96e0b
+	function directly into the function body, since it is only called
f96e0b
+	once.
f96e0b
+
f96e0b
 2012-12-30  Colin Watson  <cjwatson@ubuntu.com>
f96e0b
 
f96e0b
 	* grub-core/bus/usb/ehci.c (grub_ehci_pci_iter): Remove incorrect
f96e0b
diff --git a/grub-core/commands/i386/pc/sendkey.c b/grub-core/commands/i386/pc/sendkey.c
f96e0b
index 17f648d..d985cb3 100644
f96e0b
--- a/grub-core/commands/i386/pc/sendkey.c
f96e0b
+++ b/grub-core/commands/i386/pc/sendkey.c
f96e0b
@@ -286,47 +286,48 @@ grub_sendkey_preboot (int noret __attribute__ ((unused)))
f96e0b
   return GRUB_ERR_NONE;
f96e0b
 }
f96e0b
 
f96e0b
-static grub_err_t
f96e0b
-grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
f96e0b
+/* Helper for grub_cmd_sendkey.  */
f96e0b
+static int
f96e0b
+find_key_code (char *key)
f96e0b
 {
f96e0b
-  struct grub_arg_list *state = ctxt->state;
f96e0b
-
f96e0b
-  auto int find_key_code (char *key); 
f96e0b
-  auto int find_ascii_code (char *key);
f96e0b
+  unsigned i;
f96e0b
 
f96e0b
-  int find_key_code (char *key)
f96e0b
+  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
f96e0b
     {
f96e0b
-      unsigned i;
f96e0b
+      if (keysym_table[i].unshifted_name 
f96e0b
+	  && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
f96e0b
+	return keysym_table[i].keycode;
f96e0b
+      else if (keysym_table[i].shifted_name 
f96e0b
+	       && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
f96e0b
+	return keysym_table[i].keycode;
f96e0b
+    }
f96e0b
 
f96e0b
-      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
f96e0b
-	{
f96e0b
-	  if (keysym_table[i].unshifted_name 
f96e0b
-	      && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
f96e0b
-	    return keysym_table[i].keycode;
f96e0b
-	  else if (keysym_table[i].shifted_name 
f96e0b
-		   && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
f96e0b
-	    return keysym_table[i].keycode;
f96e0b
-	}
f96e0b
+  return 0;
f96e0b
+}
f96e0b
 
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
+/* Helper for grub_cmd_sendkey.  */
f96e0b
+static int
f96e0b
+find_ascii_code (char *key)
f96e0b
+{
f96e0b
+  unsigned i;
f96e0b
 
f96e0b
-  int find_ascii_code (char *key)
f96e0b
+  for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
f96e0b
     {
f96e0b
-      unsigned i;
f96e0b
+      if (keysym_table[i].unshifted_name 
f96e0b
+	  && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
f96e0b
+	return keysym_table[i].unshifted_ascii;
f96e0b
+      else if (keysym_table[i].shifted_name 
f96e0b
+	       && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
f96e0b
+	return keysym_table[i].shifted_ascii;
f96e0b
+    }
f96e0b
 
f96e0b
-      for (i = 0; i < sizeof (keysym_table) / sizeof (keysym_table[0]); i++)
f96e0b
-	{
f96e0b
-	  if (keysym_table[i].unshifted_name 
f96e0b
-	      && grub_strcmp (key, keysym_table[i].unshifted_name) == 0)
f96e0b
-	    return keysym_table[i].unshifted_ascii;
f96e0b
-	  else if (keysym_table[i].shifted_name 
f96e0b
-		   && grub_strcmp (key, keysym_table[i].shifted_name) == 0)
f96e0b
-	    return keysym_table[i].shifted_ascii;
f96e0b
-	}
f96e0b
+  return 0;
f96e0b
+}
f96e0b
 
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
+static grub_err_t
f96e0b
+grub_cmd_sendkey (grub_extcmd_context_t ctxt, int argc, char **args)
f96e0b
+{
f96e0b
+  struct grub_arg_list *state = ctxt->state;
f96e0b
 
f96e0b
   andmask = 0xffffffff;
f96e0b
   ormask = 0;
f96e0b
diff --git a/grub-core/commands/legacycfg.c b/grub-core/commands/legacycfg.c
f96e0b
index 5293acc..e34eed4 100644
f96e0b
--- a/grub-core/commands/legacycfg.c
f96e0b
+++ b/grub-core/commands/legacycfg.c
f96e0b
@@ -35,6 +35,14 @@
f96e0b
 
f96e0b
 GRUB_MOD_LICENSE ("GPLv3+");
f96e0b
 
f96e0b
+/* Helper for legacy_file.  */
f96e0b
+static grub_err_t
f96e0b
+legacy_file_getline (char **line, int cont __attribute__ ((unused)))
f96e0b
+{
f96e0b
+  *line = 0;
f96e0b
+  return GRUB_ERR_NONE;
f96e0b
+}
f96e0b
+
f96e0b
 static grub_err_t
f96e0b
 legacy_file (const char *filename)
f96e0b
 {
f96e0b
@@ -43,14 +51,6 @@ legacy_file (const char *filename)
f96e0b
   grub_menu_t menu;
f96e0b
   char *suffix = grub_strdup ("");
f96e0b
 
f96e0b
-  auto grub_err_t getline (char **line, int cont);
f96e0b
-  grub_err_t getline (char **line, 
f96e0b
-		      int cont __attribute__ ((unused)))
f96e0b
-  {
f96e0b
-    *line = 0;
f96e0b
-    return GRUB_ERR_NONE;
f96e0b
-  }
f96e0b
-
f96e0b
   if (!suffix)
f96e0b
     return grub_errno;
f96e0b
 
f96e0b
@@ -134,7 +134,7 @@ legacy_file (const char *filename)
f96e0b
 
f96e0b
       if (parsed && !entryname)
f96e0b
 	{
f96e0b
-	  grub_normal_parse_line (parsed, getline);
f96e0b
+	  grub_normal_parse_line (parsed, legacy_file_getline);
f96e0b
 	  grub_print_error ();
f96e0b
 	  grub_free (parsed);
f96e0b
 	  parsed = NULL;
f96e0b
@@ -180,7 +180,7 @@ legacy_file (const char *filename)
f96e0b
       grub_free (args);
f96e0b
     }
f96e0b
 
f96e0b
-  grub_normal_parse_line (suffix, getline);
f96e0b
+  grub_normal_parse_line (suffix, legacy_file_getline);
f96e0b
   grub_print_error ();
f96e0b
   grub_free (suffix);
f96e0b
   grub_free (entrysrc);
f96e0b
diff --git a/grub-core/commands/loadenv.c b/grub-core/commands/loadenv.c
f96e0b
index 18ebb7e..9a35550 100644
f96e0b
--- a/grub-core/commands/loadenv.c
f96e0b
+++ b/grub-core/commands/loadenv.c
f96e0b
@@ -114,6 +114,14 @@ read_envblk_file (grub_file_t file)
f96e0b
   return envblk;
f96e0b
 }
f96e0b
 
f96e0b
+/* Helper for grub_cmd_load_env.  */
f96e0b
+static int
f96e0b
+set_var (const char *name, const char *value)
f96e0b
+{
f96e0b
+  grub_env_set (name, value);
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
 static grub_err_t
f96e0b
 grub_cmd_load_env (grub_extcmd_context_t ctxt,
f96e0b
 		   int argc __attribute__ ((unused)),
f96e0b
@@ -123,13 +131,6 @@ grub_cmd_load_env (grub_extcmd_context_t ctxt,
f96e0b
   grub_file_t file;
f96e0b
   grub_envblk_t envblk;
f96e0b
 
f96e0b
-  auto int set_var (const char *name, const char *value);
f96e0b
-  int set_var (const char *name, const char *value)
f96e0b
-  {
f96e0b
-    grub_env_set (name, value);
f96e0b
-    return 0;
f96e0b
-  }
f96e0b
-
f96e0b
   file = open_envblk_file ((state[0].set) ? state[0].arg : 0);
f96e0b
   if (! file)
f96e0b
     return grub_errno;
f96e0b
diff --git a/grub-core/kern/corecmd.c b/grub-core/kern/corecmd.c
f96e0b
index eec575c..43240e9 100644
f96e0b
--- a/grub-core/kern/corecmd.c
f96e0b
+++ b/grub-core/kern/corecmd.c
f96e0b
@@ -28,6 +28,14 @@
f96e0b
 #include <grub/command.h>
f96e0b
 #include <grub/i18n.h>
f96e0b
 
f96e0b
+/* Helper for grub_core_cmd_set.  */
f96e0b
+static int
f96e0b
+print_env (struct grub_env_var *env)
f96e0b
+{
f96e0b
+  grub_printf ("%s=%s\n", env->name, env->value);
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
 /* set ENVVAR=VALUE */
f96e0b
 static grub_err_t
f96e0b
 grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
f96e0b
@@ -36,14 +44,6 @@ grub_core_cmd_set (struct grub_command *cmd __attribute__ ((unused)),
f96e0b
   char *var;
f96e0b
   char *val;
f96e0b
 
f96e0b
-  auto int print_env (struct grub_env_var *env);
f96e0b
-
f96e0b
-  int print_env (struct grub_env_var *env)
f96e0b
-    {
f96e0b
-      grub_printf ("%s=%s\n", env->name, env->value);
f96e0b
-      return 0;
f96e0b
-    }
f96e0b
-
f96e0b
   if (argc < 1)
f96e0b
     {
f96e0b
       grub_env_iterate (print_env);
f96e0b
diff --git a/grub-core/kern/fs.c b/grub-core/kern/fs.c
f96e0b
index 51d89d1..7e150f2 100644
f96e0b
--- a/grub-core/kern/fs.c
f96e0b
+++ b/grub-core/kern/fs.c
f96e0b
@@ -32,18 +32,18 @@ grub_fs_t grub_fs_list = 0;
f96e0b
 
f96e0b
 grub_fs_autoload_hook_t grub_fs_autoload_hook = 0;
f96e0b
 
f96e0b
+/* Helper for grub_fs_probe.  */
f96e0b
+static int
f96e0b
+probe_dummy_iter (const char *filename __attribute__ ((unused)),
f96e0b
+		  const struct grub_dirhook_info *info __attribute__ ((unused)))
f96e0b
+  {
f96e0b
+    return 1;
f96e0b
+  }
f96e0b
+
f96e0b
 grub_fs_t
f96e0b
 grub_fs_probe (grub_device_t device)
f96e0b
 {
f96e0b
   grub_fs_t p;
f96e0b
-  auto int dummy_func (const char *filename,
f96e0b
-		       const struct grub_dirhook_info *info);
f96e0b
-
f96e0b
-  int dummy_func (const char *filename __attribute__ ((unused)),
f96e0b
-		  const struct grub_dirhook_info *info  __attribute__ ((unused)))
f96e0b
-    {
f96e0b
-      return 1;
f96e0b
-    }
f96e0b
 
f96e0b
   if (device->disk)
f96e0b
     {
f96e0b
@@ -69,7 +69,7 @@ grub_fs_probe (grub_device_t device)
f96e0b
 	    }
f96e0b
 	  else
f96e0b
 #endif
f96e0b
-	    (p->dir) (device, "/", dummy_func);
f96e0b
+	    (p->dir) (device, "/", probe_dummy_iter);
f96e0b
 	  if (grub_errno == GRUB_ERR_NONE)
f96e0b
 	    return p;
f96e0b
 
f96e0b
@@ -93,7 +93,7 @@ grub_fs_probe (grub_device_t device)
f96e0b
 	    {
f96e0b
 	      p = grub_fs_list;
f96e0b
 
f96e0b
-	      (p->dir) (device, "/", dummy_func);
f96e0b
+	      (p->dir) (device, "/", probe_dummy_iter);
f96e0b
 	      if (grub_errno == GRUB_ERR_NONE)
f96e0b
 		{
f96e0b
 		  count--;
f96e0b
diff --git a/grub-core/kern/i386/coreboot/mmap.c b/grub-core/kern/i386/coreboot/mmap.c
f96e0b
index 8b0b202..8e15683 100644
f96e0b
--- a/grub-core/kern/i386/coreboot/mmap.c
f96e0b
+++ b/grub-core/kern/i386/coreboot/mmap.c
f96e0b
@@ -22,21 +22,22 @@
f96e0b
 #include <grub/err.h>
f96e0b
 #include <grub/misc.h>
f96e0b
 
f96e0b
+/* Helper for grub_linuxbios_table_iterate.  */
f96e0b
+static int
f96e0b
+check_signature (grub_linuxbios_table_header_t tbl_header)
f96e0b
+{
f96e0b
+  if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
f96e0b
+    return 1;
f96e0b
+
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
 static grub_err_t
f96e0b
 grub_linuxbios_table_iterate (int (*hook) (grub_linuxbios_table_item_t))
f96e0b
 {
f96e0b
   grub_linuxbios_table_header_t table_header;
f96e0b
   grub_linuxbios_table_item_t table_item;
f96e0b
 
f96e0b
-  auto int check_signature (grub_linuxbios_table_header_t);
f96e0b
-  int check_signature (grub_linuxbios_table_header_t tbl_header)
f96e0b
-  {
f96e0b
-    if (! grub_memcmp (tbl_header->signature, "LBIO", 4))
f96e0b
-      return 1;
f96e0b
-
f96e0b
-    return 0;
f96e0b
-  }
f96e0b
-
f96e0b
   /* Assuming table_header is aligned to its size (8 bytes).  */
f96e0b
 
f96e0b
   for (table_header = (grub_linuxbios_table_header_t) 0x500;
f96e0b
diff --git a/grub-core/kern/parser.c b/grub-core/kern/parser.c
f96e0b
index 9213caa..d1be53e 100644
f96e0b
--- a/grub-core/kern/parser.c
f96e0b
+++ b/grub-core/kern/parser.c
f96e0b
@@ -96,6 +96,16 @@ grub_parser_cmdline_state (grub_parser_state_t state, char c, char *result)
f96e0b
 }
f96e0b
 
f96e0b
 
f96e0b
+/* Helper for grub_parser_split_cmdline.  */
f96e0b
+static inline int
f96e0b
+check_varstate (grub_parser_state_t s)
f96e0b
+{
f96e0b
+  return (s == GRUB_PARSER_STATE_VARNAME
f96e0b
+	  || s == GRUB_PARSER_STATE_VARNAME2
f96e0b
+	  || s == GRUB_PARSER_STATE_QVARNAME
f96e0b
+	  || s == GRUB_PARSER_STATE_QVARNAME2);
f96e0b
+}
f96e0b
+
f96e0b
 grub_err_t
f96e0b
 grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
f96e0b
 			   int *argc, char ***argv)
f96e0b
@@ -111,16 +121,6 @@ grub_parser_split_cmdline (const char *cmdline, grub_reader_getline_t getline,
f96e0b
   char *args;
f96e0b
   int i;
f96e0b
 
f96e0b
-  auto int check_varstate (grub_parser_state_t s);
f96e0b
-
f96e0b
-  int check_varstate (grub_parser_state_t s)
f96e0b
-  {
f96e0b
-    return (s == GRUB_PARSER_STATE_VARNAME
f96e0b
-	    || s == GRUB_PARSER_STATE_VARNAME2
f96e0b
-	    || s == GRUB_PARSER_STATE_QVARNAME
f96e0b
-	    || s == GRUB_PARSER_STATE_QVARNAME2);
f96e0b
-  }
f96e0b
-
f96e0b
   auto void add_var (grub_parser_state_t newstate);
f96e0b
 
f96e0b
   void add_var (grub_parser_state_t newstate)
f96e0b
diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
f96e0b
index b341885..a2d9416 100644
f96e0b
--- a/grub-core/lib/arg.c
f96e0b
+++ b/grub-core/lib/arg.c
f96e0b
@@ -34,25 +34,26 @@ static const struct grub_arg_option help_options[] =
f96e0b
     {0, 0, 0, 0, 0, 0}
f96e0b
   };
f96e0b
 
f96e0b
+/* Helper for find_short.  */
f96e0b
 static struct grub_arg_option *
f96e0b
-find_short (const struct grub_arg_option *options, char c)
f96e0b
+fnd_short (const struct grub_arg_option *opt, char c)
f96e0b
 {
f96e0b
-  struct grub_arg_option *found = 0;
f96e0b
-  auto struct grub_arg_option *fnd_short (const struct grub_arg_option *opt);
f96e0b
-
f96e0b
-  struct grub_arg_option *fnd_short (const struct grub_arg_option *opt)
f96e0b
+  while (opt->doc)
f96e0b
     {
f96e0b
-      while (opt->doc)
f96e0b
-	{
f96e0b
-	  if (opt->shortarg == c)
f96e0b
-	    return (struct grub_arg_option *) opt;
f96e0b
-	  opt++;
f96e0b
-	}
f96e0b
-      return 0;
f96e0b
+      if (opt->shortarg == c)
f96e0b
+	return (struct grub_arg_option *) opt;
f96e0b
+      opt++;
f96e0b
     }
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+static struct grub_arg_option *
f96e0b
+find_short (const struct grub_arg_option *options, char c)
f96e0b
+{
f96e0b
+  struct grub_arg_option *found = 0;
f96e0b
 
f96e0b
   if (options)
f96e0b
-    found = fnd_short (options);
f96e0b
+    found = fnd_short (options, c);
f96e0b
 
f96e0b
   if (! found)
f96e0b
     {
f96e0b
@@ -74,29 +75,30 @@ find_short (const struct grub_arg_option *options, char c)
f96e0b
   return found;
f96e0b
 }
f96e0b
 
f96e0b
+/* Helper for find_long.  */
f96e0b
 static struct grub_arg_option *
f96e0b
-find_long (const struct grub_arg_option *options, const char *s, int len)
f96e0b
+fnd_long (const struct grub_arg_option *opt, const char *s, int len)
f96e0b
 {
f96e0b
-  struct grub_arg_option *found = 0;
f96e0b
-  auto struct grub_arg_option *fnd_long (const struct grub_arg_option *opt);
f96e0b
-
f96e0b
-  struct grub_arg_option *fnd_long (const struct grub_arg_option *opt)
f96e0b
+  while (opt->doc)
f96e0b
     {
f96e0b
-      while (opt->doc)
f96e0b
-	{
f96e0b
-	  if (opt->longarg && ! grub_strncmp (opt->longarg, s, len) &&
f96e0b
-	      opt->longarg[len] == '\0')
f96e0b
-	    return (struct grub_arg_option *) opt;
f96e0b
-	  opt++;
f96e0b
-	}
f96e0b
-      return 0;
f96e0b
+      if (opt->longarg && ! grub_strncmp (opt->longarg, s, len) &&
f96e0b
+	  opt->longarg[len] == '\0')
f96e0b
+	return (struct grub_arg_option *) opt;
f96e0b
+      opt++;
f96e0b
     }
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+static struct grub_arg_option *
f96e0b
+find_long (const struct grub_arg_option *options, const char *s, int len)
f96e0b
+{
f96e0b
+  struct grub_arg_option *found = 0;
f96e0b
 
f96e0b
   if (options)
f96e0b
-    found = fnd_long (options);
f96e0b
+    found = fnd_long (options, s, len);
f96e0b
 
f96e0b
   if (! found)
f96e0b
-    found = fnd_long (help_options);
f96e0b
+    found = fnd_long (help_options, s, len);
f96e0b
 
f96e0b
   return found;
f96e0b
 }
f96e0b
diff --git a/grub-core/lib/crc.c b/grub-core/lib/crc.c
f96e0b
index ffc3ef3..bf97cc6 100644
f96e0b
--- a/grub-core/lib/crc.c
f96e0b
+++ b/grub-core/lib/crc.c
f96e0b
@@ -22,25 +22,26 @@
f96e0b
 
f96e0b
 static grub_uint32_t crc32c_table [256];
f96e0b
 
f96e0b
-static void
f96e0b
-init_crc32c_table (void)
f96e0b
+/* Helper for init_crc32c_table.  */
f96e0b
+static grub_uint32_t
f96e0b
+reflect (grub_uint32_t ref, int len)
f96e0b
 {
f96e0b
-  auto grub_uint32_t reflect (grub_uint32_t ref, int len);
f96e0b
-  grub_uint32_t reflect (grub_uint32_t ref, int len)
f96e0b
-    {
f96e0b
-      grub_uint32_t result = 0;
f96e0b
-      int i;
f96e0b
-
f96e0b
-      for (i = 1; i <= len; i++)
f96e0b
-        {
f96e0b
-          if (ref & 1)
f96e0b
-            result |= 1 << (len - i);
f96e0b
-          ref >>= 1;
f96e0b
-        }
f96e0b
+  grub_uint32_t result = 0;
f96e0b
+  int i;
f96e0b
 
f96e0b
-      return result;
f96e0b
+  for (i = 1; i <= len; i++)
f96e0b
+    {
f96e0b
+      if (ref & 1)
f96e0b
+	result |= 1 << (len - i);
f96e0b
+      ref >>= 1;
f96e0b
     }
f96e0b
 
f96e0b
+  return result;
f96e0b
+}
f96e0b
+
f96e0b
+static void
f96e0b
+init_crc32c_table (void)
f96e0b
+{
f96e0b
   grub_uint32_t polynomial = 0x1edc6f41;
f96e0b
   int i, j;
f96e0b
 
f96e0b
diff --git a/grub-core/lib/crc64.c b/grub-core/lib/crc64.c
f96e0b
index 4b1c92c..4960f3f 100644
f96e0b
--- a/grub-core/lib/crc64.c
f96e0b
+++ b/grub-core/lib/crc64.c
f96e0b
@@ -25,25 +25,26 @@ GRUB_MOD_LICENSE ("GPLv3+");
f96e0b
 
f96e0b
 static grub_uint64_t crc64_table [256];
f96e0b
 
f96e0b
-static void
f96e0b
-init_crc64_table (void)
f96e0b
+/* Helper for init_crc64_table.  */
f96e0b
+static grub_uint64_t
f96e0b
+reflect (grub_uint64_t ref, int len)
f96e0b
 {
f96e0b
-  auto grub_uint64_t reflect (grub_uint64_t ref, int len);
f96e0b
-  grub_uint64_t reflect (grub_uint64_t ref, int len)
f96e0b
-    {
f96e0b
-      grub_uint64_t result = 0;
f96e0b
-      int i;
f96e0b
+  grub_uint64_t result = 0;
f96e0b
+  int i;
f96e0b
 
f96e0b
-      for (i = 1; i <= len; i++)
f96e0b
-        {
f96e0b
-          if (ref & 1)
f96e0b
-            result |= 1ULL << (len - i);
f96e0b
-          ref >>= 1;
f96e0b
-        }
f96e0b
-
f96e0b
-      return result;
f96e0b
+  for (i = 1; i <= len; i++)
f96e0b
+    {
f96e0b
+      if (ref & 1)
f96e0b
+	result |= 1ULL << (len - i);
f96e0b
+      ref >>= 1;
f96e0b
     }
f96e0b
 
f96e0b
+  return result;
f96e0b
+}
f96e0b
+
f96e0b
+static void
f96e0b
+init_crc64_table (void)
f96e0b
+{
f96e0b
   grub_uint64_t polynomial = 0x42f0e1eba9ea3693ULL;
f96e0b
   int i, j;
f96e0b
 
f96e0b
diff --git a/grub-core/lib/ieee1275/cmos.c b/grub-core/lib/ieee1275/cmos.c
f96e0b
index fa57db9..328d70a 100644
f96e0b
--- a/grub-core/lib/ieee1275/cmos.c
f96e0b
+++ b/grub-core/lib/ieee1275/cmos.c
f96e0b
@@ -23,51 +23,53 @@
f96e0b
 #include <grub/misc.h>
f96e0b
 
f96e0b
 volatile grub_uint8_t *grub_cmos_port = 0;
f96e0b
-grub_err_t
f96e0b
-grub_cmos_find_port (void)
f96e0b
+
f96e0b
+/* Helper for grub_cmos_find_port.  */
f96e0b
+static int
f96e0b
+grub_cmos_find_port_iter (struct grub_ieee1275_devalias *alias)
f96e0b
 {
f96e0b
-  auto int hook (struct grub_ieee1275_devalias *alias);
f96e0b
-  int hook (struct grub_ieee1275_devalias *alias)
f96e0b
-  {
f96e0b
-    grub_ieee1275_phandle_t dev;
f96e0b
-    grub_uint32_t addr[2];
f96e0b
-    grub_ssize_t actual;
f96e0b
-    /* Enough to check if it's "m5819" */
f96e0b
-    char compat[100];
f96e0b
-    if (grub_ieee1275_finddevice (alias->path, &dev))
f96e0b
-      return 0;
f96e0b
-    if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
f96e0b
-				    0))
f96e0b
-      return 0;
f96e0b
-    if (grub_strcmp (compat, "m5819") != 0)
f96e0b
-      return 0;
f96e0b
-    if (grub_ieee1275_get_integer_property (dev, "address",
f96e0b
-					    addr, sizeof (addr), &actual))
f96e0b
-      return 0;
f96e0b
-    if (actual == 4)
f96e0b
-      {
f96e0b
-	grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
f96e0b
-	return 1;
f96e0b
-      }
f96e0b
+  grub_ieee1275_phandle_t dev;
f96e0b
+  grub_uint32_t addr[2];
f96e0b
+  grub_ssize_t actual;
f96e0b
+  /* Enough to check if it's "m5819" */
f96e0b
+  char compat[100];
f96e0b
+  if (grub_ieee1275_finddevice (alias->path, &dev))
f96e0b
+    return 0;
f96e0b
+  if (grub_ieee1275_get_property (dev, "compatible", compat, sizeof (compat),
f96e0b
+				  0))
f96e0b
+    return 0;
f96e0b
+  if (grub_strcmp (compat, "m5819") != 0)
f96e0b
+    return 0;
f96e0b
+  if (grub_ieee1275_get_integer_property (dev, "address",
f96e0b
+					  addr, sizeof (addr), &actual))
f96e0b
+    return 0;
f96e0b
+  if (actual == 4)
f96e0b
+    {
f96e0b
+      grub_cmos_port = (volatile grub_uint8_t *) (grub_addr_t) addr[0];
f96e0b
+      return 1;
f96e0b
+    }
f96e0b
 
f96e0b
 #if GRUB_CPU_SIZEOF_VOID_P == 8
f96e0b
-    if (actual == 8)
f96e0b
-      {
f96e0b
-	grub_cmos_port = (volatile grub_uint8_t *) 
f96e0b
-	  ((((grub_addr_t) addr[0]) << 32) | addr[1]);
f96e0b
-	return 1;
f96e0b
-      }
f96e0b
+  if (actual == 8)
f96e0b
+    {
f96e0b
+      grub_cmos_port = (volatile grub_uint8_t *) 
f96e0b
+	((((grub_addr_t) addr[0]) << 32) | addr[1]);
f96e0b
+      return 1;
f96e0b
+    }
f96e0b
 #else
f96e0b
-    if (actual == 8 && addr[0] == 0)
f96e0b
-      {
f96e0b
-	grub_cmos_port = (volatile grub_uint8_t *) addr[1];
f96e0b
-	return 1;
f96e0b
-      }
f96e0b
+  if (actual == 8 && addr[0] == 0)
f96e0b
+    {
f96e0b
+      grub_cmos_port = (volatile grub_uint8_t *) addr[1];
f96e0b
+      return 1;
f96e0b
+    }
f96e0b
 #endif
f96e0b
-    return 0;
f96e0b
-  }
f96e0b
-  
f96e0b
-  grub_ieee1275_devices_iterate (hook);
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
+grub_err_t
f96e0b
+grub_cmos_find_port (void)
f96e0b
+{
f96e0b
+  grub_ieee1275_devices_iterate (grub_cmos_find_port_iter);
f96e0b
   if (!grub_cmos_port)
f96e0b
     return grub_error (GRUB_ERR_IO, "no cmos found");
f96e0b
   
f96e0b
diff --git a/grub-core/lib/ieee1275/datetime.c b/grub-core/lib/ieee1275/datetime.c
f96e0b
index 8792429..74578f1 100644
f96e0b
--- a/grub-core/lib/ieee1275/datetime.c
f96e0b
+++ b/grub-core/lib/ieee1275/datetime.c
f96e0b
@@ -30,22 +30,23 @@ GRUB_MOD_LICENSE ("GPLv3+");
f96e0b
 static char *rtc = 0;
f96e0b
 static int no_ieee1275_rtc = 0;
f96e0b
 
f96e0b
+/* Helper for find_rtc.  */
f96e0b
+static int
f96e0b
+find_rtc_iter (struct grub_ieee1275_devalias *alias)
f96e0b
+{
f96e0b
+  if (grub_strcmp (alias->type, "rtc") == 0)
f96e0b
+    {
f96e0b
+      grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
f96e0b
+      rtc = grub_strdup (alias->path);
f96e0b
+      return 1;
f96e0b
+    }
f96e0b
+  return 0;
f96e0b
+}
f96e0b
+
f96e0b
 static void
f96e0b
 find_rtc (void)
f96e0b
 {
f96e0b
-  auto int hook (struct grub_ieee1275_devalias *alias);
f96e0b
-  int hook (struct grub_ieee1275_devalias *alias)
f96e0b
-  {
f96e0b
-    if (grub_strcmp (alias->type, "rtc") == 0)
f96e0b
-      {
f96e0b
-	grub_dprintf ("datetime", "Found RTC %s\n", alias->path);
f96e0b
-	rtc = grub_strdup (alias->path);
f96e0b
-	return 1;
f96e0b
-      }
f96e0b
-    return 0;
f96e0b
-  }
f96e0b
-  
f96e0b
-  grub_ieee1275_devices_iterate (hook);
f96e0b
+  grub_ieee1275_devices_iterate (find_rtc_iter);
f96e0b
   if (!rtc)
f96e0b
     no_ieee1275_rtc = 1;
f96e0b
 }
f96e0b
diff --git a/grub-core/normal/menu_entry.c b/grub-core/normal/menu_entry.c
f96e0b
index 8e2b4da..33b644b 100644
f96e0b
--- a/grub-core/normal/menu_entry.c
f96e0b
+++ b/grub-core/normal/menu_entry.c
f96e0b
@@ -1205,32 +1205,6 @@ run (struct screen *screen)
f96e0b
   grub_menu_t menu = NULL;
f96e0b
   char *dummy[1] = { NULL };
f96e0b
 
f96e0b
-  auto char * editor_getsource (void);
f96e0b
-  char * editor_getsource (void)
f96e0b
-  {
f96e0b
-    int i;
f96e0b
-    grub_size_t size = 0, tot_size = 0;
f96e0b
-    char *source;
f96e0b
-
f96e0b
-    for (i = 0; i < screen->num_lines; i++)
f96e0b
-      tot_size += grub_get_num_of_utf8_bytes (screen->lines[i].buf,
f96e0b
-					      screen->lines[i].len) + 1;
f96e0b
-
f96e0b
-    source = grub_malloc (tot_size + 1);
f96e0b
-    if (! source)
f96e0b
-      return NULL;
f96e0b
-
f96e0b
-    for (i = 0; i < screen->num_lines; i++)
f96e0b
-      {
f96e0b
-	size += grub_ucs4_to_utf8 (screen->lines[i].buf, screen->lines[i].len,
f96e0b
-				   (grub_uint8_t *) source + size,
f96e0b
-				   tot_size - size);
f96e0b
-	source[size++] = '\n';
f96e0b
-      }
f96e0b
-    source[size] = '\0';
f96e0b
-    return source;
f96e0b
-  }
f96e0b
-
f96e0b
   grub_cls ();
f96e0b
   grub_printf ("  ");
f96e0b
   grub_printf_ (N_("Booting a command list"));
f96e0b
@@ -1248,9 +1222,27 @@ run (struct screen *screen)
f96e0b
     }
f96e0b
 
f96e0b
   /* Execute the script, line for line.  */
f96e0b
-  script = editor_getsource ();
f96e0b
-  if (! script)
f96e0b
-    return 0;
f96e0b
+  {
f96e0b
+    int i;
f96e0b
+    grub_size_t size = 0, tot_size = 0;
f96e0b
+
f96e0b
+    for (i = 0; i < screen->num_lines; i++)
f96e0b
+      tot_size += grub_get_num_of_utf8_bytes (screen->lines[i].buf,
f96e0b
+					      screen->lines[i].len) + 1;
f96e0b
+
f96e0b
+    script = grub_malloc (tot_size + 1);
f96e0b
+    if (! script)
f96e0b
+      return 0;
f96e0b
+
f96e0b
+    for (i = 0; i < screen->num_lines; i++)
f96e0b
+      {
f96e0b
+	size += grub_ucs4_to_utf8 (screen->lines[i].buf, screen->lines[i].len,
f96e0b
+				   (grub_uint8_t *) script + size,
f96e0b
+				   tot_size - size);
f96e0b
+	script[size++] = '\n';
f96e0b
+      }
f96e0b
+    script[size] = '\0';
f96e0b
+  }
f96e0b
   grub_script_execute_sourcecode (script, 0, dummy);
f96e0b
   grub_free (script);
f96e0b
 
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b