Skip to contentSkip to conversation

: Fix up a few build warnings.

PATCH New David Miller 1 participant 1 message Apr 30, 2009

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 : Fix up a few build warnings.

I noticed these in the build, and they result from the fact that grub_uint64_t is "unsigned long" and consequently grub_addr_t and grub_disk_addr_t have this type as well.

Since grub_uint64_t can be either "long long" or "long" depending on the platform, a cast is the best fix for now.

Committed.

2009-04-29 David S. Miller <[email protected]>

* commands/lsmmap.c (grub_cmd_lsmmap): Add casts to avoid printf warnings.
* kern/ieee1275/openfw.c (grub_claimmap): Likewise.
* disk/ieee1275/ofdisk.c (grub_ofdisk_open, grub_ofdisk_close, grub_ofdisk_read): Likewise, and deal similarly with the fact that ihandles have a 32-bit type but need to be stored in a "void *".

commands/lsmmap.c +1 -1
index 562ba21..4fe9a5a 100644
@@ -30,7 +30,7 @@ grub_cmd_lsmmap (grub_command_t cmd __attribute__ ((unused)),
   int NESTED_FUNC_ATTR hook (grub_uint64_t addr, grub_uint64_t size, grub_uint32_t type)
     {
       grub_printf ("base_addr = 0x%llx, length = 0x%llx, type = 0x%x\n",
-		   addr, size, type);
+		   (long long) addr, (long long) size, type);
       return 0;
     }
   grub_machine_mmap_iterate (hook);
disk/ieee1275/ofdisk.c +11 -10
index 202be24..e2c7867 100644
@@ -155,7 +155,8 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
       goto fail;
     }
 
-  grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath, (void *) dev_ihandle);
+  grub_dprintf ("disk", "Opened `%s' as handle %p.\n", op->devpath,
+		(void *) (unsigned long) dev_ihandle);
 
   if (grub_ieee1275_finddevice (op->devpath, &dev))
     {
@@ -185,7 +186,7 @@ grub_ofdisk_open (const char *name, grub_disk_t disk)
 
   /* XXX: Read this, somehow.  */
   disk->has_partitions = 1;
-  disk->data = (void *) dev_ihandle;
+  disk->data = (void *) (unsigned long) dev_ihandle;
   return 0;
 
  fail:
@@ -199,7 +200,7 @@ grub_ofdisk_close (grub_disk_t disk)
 {
   grub_dprintf ("disk", "Closing handle %p.\n",
 		(void *) disk->data);
-  grub_ieee1275_close ((grub_ieee1275_ihandle_t) disk->data);
+  grub_ieee1275_close ((grub_ieee1275_ihandle_t) (unsigned long) disk->data);
 }
 
 static grub_err_t
@@ -211,21 +212,21 @@ grub_ofdisk_read (grub_disk_t disk, grub_disk_addr_t sector,
 
   grub_dprintf ("disk",
 		"Reading handle %p: sector 0x%llx, size 0x%lx, buf %p.\n",
-		(void *) disk->data, sector, (long) size, buf);
+		(void *) disk->data, (long long) sector, (long) size, buf);
 
   pos = sector * 512UL;
 
-  grub_ieee1275_seek ((grub_ieee1275_ihandle_t) disk->data, (int) (pos >> 32),
-		      (int) pos & 0xFFFFFFFFUL, &status);
+  grub_ieee1275_seek ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
+		      (int) (pos >> 32), (int) pos & 0xFFFFFFFFUL, &status);
   if (status < 0)
     return grub_error (GRUB_ERR_READ_ERROR,
 		       "Seek error, can't seek block %llu",
-		       sector);
-  grub_ieee1275_read ((grub_ieee1275_ihandle_t) disk->data, buf,
-		      size * 512UL, &actual);
+		       (long long) sector);
+  grub_ieee1275_read ((grub_ieee1275_ihandle_t) (unsigned long) disk->data,
+		      buf, size * 512UL, &actual);
   if (actual != actual)
     return grub_error (GRUB_ERR_READ_ERROR, "Read error on block: %llu",
-		       sector);
+		       (long long) sector);
     
   return 0;
 }
kern/ieee1275/openfw.c +2 -1
index b23149e..7d65023 100644
@@ -238,7 +238,8 @@ grub_claimmap (grub_addr_t addr, grub_size_t size)
   if (! grub_ieee1275_test_flag (GRUB_IEEE1275_FLAG_REAL_MODE)
       && grub_map (addr, addr, size, 0x00))
     {
-      grub_printf ("map failed: address 0x%x, size 0x%x\n", addr, size);
+      grub_printf ("map failed: address 0x%llx, size 0x%llx\n",
+		   (long long) addr, (long long) size);
       grub_ieee1275_release (addr, size);
       return -1;
     }