grub2/0208-grub-core-lib-arg.c-grub_arg_list_alloc-Use-shifts-r.patch
2013-06-07 14:03:56 -04:00

60 lines
1.8 KiB
Diff

From 2b7ba382e92e9e62d51b3dd630046982b83c8e99 Mon Sep 17 00:00:00 2001
From: Vladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Date: Sun, 10 Mar 2013 20:08:15 +0100
Subject: [PATCH 208/471] * grub-core/lib/arg.c (grub_arg_list_alloc):
Use shifts rather than divisions.
---
ChangeLog | 5 +++++
grub-core/lib/arg.c | 6 +++---
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c2821c9..8f8de8b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2013-03-10 Vladimir Serbinenko <phcoder@gmail.com>
+ * grub-core/lib/arg.c (grub_arg_list_alloc): Use shifts rather
+ than divisions.
+
+2013-03-10 Vladimir Serbinenko <phcoder@gmail.com>
+
* grub-core/commands/verify.c (grub_verify_signature): Use unsigned
operations to have intended shifts and not divisions.
diff --git a/grub-core/lib/arg.c b/grub-core/lib/arg.c
index da44e30..7492ac6 100644
--- a/grub-core/lib/arg.c
+++ b/grub-core/lib/arg.c
@@ -428,7 +428,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
{
int i;
char **args;
- unsigned argcnt;
+ grub_size_t argcnt;
struct grub_arg_list *list;
const struct grub_arg_option *options;
@@ -440,7 +440,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
for (i = 0; options[i].doc; i++)
{
if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
- argcnt += (argc + 1) / 2 + 1; /* max possible for any option */
+ argcnt += ((grub_size_t) argc + 1) / 2 + 1; /* max possible for any option */
}
list = grub_zalloc (sizeof (*list) * i + sizeof (char*) * argcnt);
@@ -456,7 +456,7 @@ grub_arg_list_alloc(grub_extcmd_t extcmd, int argc,
if (options[i].flags & GRUB_ARG_OPTION_REPEATABLE)
{
list[i].args = args;
- args += argc / 2 + 1;
+ args += (grub_size_t) argc / 2 + 1;
}
}
return list;
--
1.8.2.1