]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Cleanup address expressions for readability and using only unsigned arithmetics
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 13 Dec 2009 17:03:46 +0000 (18:03 +0100)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Sun, 13 Dec 2009 17:03:46 +0000 (18:03 +0100)
lib/relocator.c

index 557fd4f632c4283f7857b13ef216a62c7585f16b..d10af34d412325290058d97d482002f96ec4a5f8 100644 (file)
@@ -78,10 +78,10 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
 
   /* Very unlikely condition: Relocator may risk overwrite itself.
      Just move it a bit up.  */
-  if ((grub_uint8_t *) UINT_TO_PTR (dest) - (grub_uint8_t *) relocator
-      < (signed) (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN)
-      && (grub_uint8_t *) UINT_TO_PTR (dest) - (grub_uint8_t *) relocator
-      > - (signed) (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN))
+  if ((grub_addr_t) dest < (grub_addr_t) relocator
+      + (RELOCATOR_SIZEOF (backward) + RELOCATOR_ALIGN) 
+      && (grub_addr_t) dest + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
+      > (grub_addr_t) relocator)
     {
       void *relocator_new = ((grub_uint8_t *) relocator)
        + (RELOCATOR_SIZEOF (forward) + RELOCATOR_ALIGN)
@@ -95,7 +95,7 @@ PREFIX (boot) (void *relocator, grub_uint32_t dest,
       relocator = relocator_new;
     }
 
-  if (UINT_TO_PTR (dest) >= relocator)
+  if ((grub_addr_t) dest >= (grub_addr_t) relocator)
     {
       int overhead;
       overhead = dest -