Blame SOURCES/0004-include-grub-list.h-FOR_LIST_ELEMENTS_SAFE-New-macro.patch

f96e0b
From d2ccb3209c62de4292107df4207c02ee59dc11a9 Mon Sep 17 00:00:00 2001
f96e0b
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
f96e0b
Date: Mon, 2 Jul 2012 11:19:22 +0200
f96e0b
Subject: [PATCH 004/482] 	* include/grub/list.h
f96e0b
 (FOR_LIST_ELEMENTS_SAFE): New macro. 	* include/grub/command.h
f96e0b
 (FOR_COMMANDS_SAFE): Likewise. 	* grub-core/commands/help.c
f96e0b
 (grub_cmd_help): Use FOR_COMMANDS_SAFE.
f96e0b
f96e0b
---
f96e0b
 grub-core/commands/help.c | 5 +++--
f96e0b
 include/grub/command.h    | 1 +
f96e0b
 include/grub/list.h       | 1 +
f96e0b
 3 files changed, 5 insertions(+), 2 deletions(-)
f96e0b
f96e0b
diff --git a/grub-core/commands/help.c b/grub-core/commands/help.c
f96e0b
index d64c289..f0be89b 100644
f96e0b
--- a/grub-core/commands/help.c
f96e0b
+++ b/grub-core/commands/help.c
f96e0b
@@ -99,12 +99,13 @@ grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
f96e0b
   else
f96e0b
     {
f96e0b
       int i;
f96e0b
-      grub_command_t cmd_iter, cmd;
f96e0b
+      grub_command_t cmd_iter, cmd, cmd_next;
f96e0b
 
f96e0b
       for (i = 0; i < argc; i++)
f96e0b
 	{
f96e0b
 	  currarg = args[i];
f96e0b
-	  FOR_COMMANDS(cmd_iter)
f96e0b
+
f96e0b
+	  FOR_COMMANDS_SAFE (cmd_iter, cmd_next)
f96e0b
 	  {
f96e0b
 	    if (!(cmd_iter->prio & GRUB_COMMAND_FLAG_ACTIVE))
f96e0b
 	      continue;
f96e0b
diff --git a/include/grub/command.h b/include/grub/command.h
f96e0b
index 6d43499..8705a63 100644
f96e0b
--- a/include/grub/command.h
f96e0b
+++ b/include/grub/command.h
f96e0b
@@ -121,6 +121,7 @@ grub_command_execute (const char *name, int argc, char **argv)
f96e0b
 }
f96e0b
 
f96e0b
 #define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list)
f96e0b
+#define FOR_COMMANDS_SAFE(var, next) FOR_LIST_ELEMENTS_SAFE((var), (next), grub_command_list)
f96e0b
 
f96e0b
 void grub_register_core_commands (void);
f96e0b
 
f96e0b
diff --git a/include/grub/list.h b/include/grub/list.h
f96e0b
index cadb2d9..6f6dec0 100644
f96e0b
--- a/include/grub/list.h
f96e0b
+++ b/include/grub/list.h
f96e0b
@@ -35,6 +35,7 @@ void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
f96e0b
 void EXPORT_FUNC(grub_list_remove) (grub_list_t item);
f96e0b
 
f96e0b
 #define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
f96e0b
+#define FOR_LIST_ELEMENTS_SAFE(var, nxt, list) for ((var) = (list), (nxt) = ((var) ? (var)->next : 0); (var); (var) = (nxt), (nxt) = (var)->next)
f96e0b
 
f96e0b
 static inline void *
f96e0b
 grub_bad_type_cast_real (int line, const char *file)
f96e0b
-- 
f96e0b
1.8.2.1
f96e0b