diff --git a/include/grub/script_sh.h b/include/grub/script_sh.h index 5455fc763..9199a539e 100644 --- a/include/grub/script_sh.h +++ b/include/grub/script_sh.h @@ -66,7 +66,7 @@ struct grub_script_arg /* An argument vector. */ struct grub_script_argv { - int argc; + unsigned argc; char **args; }; diff --git a/script/argv.c b/script/argv.c index 4974178cc..56274f263 100644 --- a/script/argv.c +++ b/script/argv.c @@ -29,6 +29,7 @@ round_up_exp (unsigned v) v |= v >> 4; v |= v >> 8; v |= v >> 16; + if (sizeof (v) > 4) v |= v >> 32; @@ -41,7 +42,7 @@ round_up_exp (unsigned v) void grub_script_argv_free (struct grub_script_argv *argv) { - int i; + unsigned i; if (argv->args) { diff --git a/script/execute.c b/script/execute.c index 2040be13c..6a755a040 100644 --- a/script/execute.c +++ b/script/execute.c @@ -77,7 +77,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) } else if (grub_strcmp (name, "*") == 0) { - int i; + unsigned i; for (i = 0; ! errors && i < scope->argv.argc; i++) if (type == GRUB_SCRIPT_ARG_TYPE_VAR) @@ -97,7 +97,7 @@ grub_script_env_get (const char *name, grub_script_arg_type_t type) } else if (grub_strcmp (name, "@") == 0) { - int i; + unsigned i; for (i = 0; ! errors && i < scope->argv.argc; i++) { @@ -287,6 +287,7 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd) grub_snprintf (errnobuf, sizeof (errnobuf), "%d", grub_errno); grub_env_set ("?", errnobuf); + grub_script_argv_free (&argv); grub_print_error (); return 0; @@ -353,8 +354,8 @@ grub_script_execute_cmdif (struct grub_script_cmd *cmd) grub_err_t grub_script_execute_cmdfor (struct grub_script_cmd *cmd) { - int i; - int result; + unsigned i; + grub_err_t result; struct grub_script_argv argv; struct grub_script_cmdfor *cmdfor = (struct grub_script_cmdfor *) cmd;