[2440] 2009-07-23 Pavel Roskin <[email protected]>

Pavel Roskin <[email protected]> Thu, 23 Jul 2009 16:41:29 +0000
Newsgroups gmane.comp.boot-loaders.grub.cvs
Message-ID <[email protected]>
Revision: 2440
          http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2440
Author:   proski
Date:     2009-07-23 16:41:29 +0000 (Thu, 23 Jul 2009)
Log Message:
-----------
2009-07-23  Pavel Roskin  <[email protected]>

	* 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.

Modified Paths:
--------------
    trunk/grub2/ChangeLog
    trunk/grub2/include/grub/misc.h

Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog	2009-07-22 11:16:11 UTC (rev 2439)
+++ trunk/grub2/ChangeLog	2009-07-23 16:41:29 UTC (rev 2440)
@@ -1,3 +1,9 @@
+2009-07-23  Pavel Roskin  <[email protected]>
+
+	* 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.
+
 2009-07-21  Vladimir Serbinenko  <[email protected]>
 
 	UUID support for UFS

Modified: trunk/grub2/include/grub/misc.h
===================================================================
--- trunk/grub2/include/grub/misc.h	2009-07-22 11:16:11 UTC (rev 2439)
+++ trunk/grub2/include/grub/misc.h	2009-07-23 16:41:29 UTC (rev 2440)
@@ -25,7 +25,8 @@
 #include <grub/symbol.h>
 #include <grub/err.h>
 
-#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)