From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1MTSKK-0000WX-Jd for mharc-grub-devel@gnu.org; Tue, 21 Jul 2009 23:17:08 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MTSKJ-0000WF-Fq for grub-devel@gnu.org; Tue, 21 Jul 2009 23:17:07 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MTSKF-0000V0-Rv for grub-devel@gnu.org; Tue, 21 Jul 2009 23:17:07 -0400 Received: from [199.232.76.173] (port=43972 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MTSKF-0000Ut-IP for grub-devel@gnu.org; Tue, 21 Jul 2009 23:17:03 -0400 Received: from c60.cesmail.net ([216.154.195.49]:36352) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.60) (envelope-from ) id 1MTSKF-0007ka-4B for grub-devel@gnu.org; Tue, 21 Jul 2009 23:17:03 -0400 Received: from unknown (HELO smtprelay2.cesmail.net) ([192.168.1.112]) by c60.cesmail.net with ESMTP; 21 Jul 2009 23:17:01 -0400 Received: from mj.roinet.com (static-72-92-88-10.phlapa.fios.verizon.net [72.92.88.10]) by smtprelay2.cesmail.net (Postfix) with ESMTPSA id 59B9534C6A for ; Tue, 21 Jul 2009 23:27:29 -0400 (EDT) To: grub-devel@gnu.org From: Pavel Roskin Date: Tue, 21 Jul 2009 23:16:59 -0400 Message-ID: <20090722031659.6348.7591.stgit@mj.roinet.com> In-Reply-To: <20090722031638.6348.79007.stgit@mj.roinet.com> References: <20090722031638.6348.79007.stgit@mj.roinet.com> User-Agent: StGit/0.15-rc1-9-gd8846 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH 4/4] Fix ALIGN_UP cutting upper bits X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 22 Jul 2009 03:17:07 -0000 If align is unsigned int, ~(align - 1) will also be unsigned int and will cut addr to 32 bits. Cast align to the type of addr. This also avoid 64-bit calculations if addr is 32-bit. ChangeLog: * include/grub/misc.h (ALIGN_UP): Cast align to the type of addr to avoid loss of upper bits if align is unsigned and shorter than addr. --- include/grub/misc.h | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/include/grub/misc.h b/include/grub/misc.h index e229062..769ec5c 100644 --- a/include/grub/misc.h +++ b/include/grub/misc.h @@ -25,7 +25,8 @@ #include #include -#define ALIGN_UP(addr, align) (((grub_uint64_t)addr + align - 1) & ~(align - 1)) +#define ALIGN_UP(addr, align) \ + ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1)) #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0])) #define grub_dprintf(condition, fmt, args...) grub_real_dprintf(__FILE__, __LINE__, condition, fmt, ## args)