* include/grub/list.h (FOR_LIST_ELEMENTS_SAFE): New macro.

* include/grub/command.h (FOR_COMMANDS_SAFE): Likewise.
	* grub-core/commands/help.c (grub_cmd_help): Use FOR_COMMANDS_SAFE.
This commit is contained in:
Vladimir 'phcoder' Serbinenko 2012-07-02 11:19:22 +02:00
parent 3569288126
commit a18f3b98c6
3 changed files with 5 additions and 2 deletions

View file

@ -99,12 +99,13 @@ grub_cmd_help (grub_extcmd_context_t ctxt __attribute__ ((unused)), int argc,
else else
{ {
int i; int i;
grub_command_t cmd_iter, cmd; grub_command_t cmd_iter, cmd, cmd_next;
for (i = 0; i < argc; i++) for (i = 0; i < argc; i++)
{ {
currarg = args[i]; currarg = args[i];
FOR_COMMANDS(cmd_iter)
FOR_COMMANDS_SAFE (cmd_iter, cmd_next)
{ {
if (!(cmd_iter->prio & GRUB_COMMAND_FLAG_ACTIVE)) if (!(cmd_iter->prio & GRUB_COMMAND_FLAG_ACTIVE))
continue; continue;

View file

@ -121,6 +121,7 @@ grub_command_execute (const char *name, int argc, char **argv)
} }
#define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list) #define FOR_COMMANDS(var) FOR_LIST_ELEMENTS((var), grub_command_list)
#define FOR_COMMANDS_SAFE(var, next) FOR_LIST_ELEMENTS_SAFE((var), (next), grub_command_list)
void grub_register_core_commands (void); void grub_register_core_commands (void);

View file

@ -35,6 +35,7 @@ void EXPORT_FUNC(grub_list_push) (grub_list_t *head, grub_list_t item);
void EXPORT_FUNC(grub_list_remove) (grub_list_t item); void EXPORT_FUNC(grub_list_remove) (grub_list_t item);
#define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next) #define FOR_LIST_ELEMENTS(var, list) for ((var) = (list); (var); (var) = (var)->next)
#define FOR_LIST_ELEMENTS_SAFE(var, nxt, list) for ((var) = (list), (nxt) = ((var) ? (var)->next : 0); (var); (var) = (nxt), (nxt) = (var)->next)
static inline void * static inline void *
grub_bad_type_cast_real (int line, const char *file) grub_bad_type_cast_real (int line, const char *file)