[PATCH] libpciaccess: Fix incorrect format specification

Chuck Tuffli chuck at tuffli.net
Thu Feb 6 18:09:35 PST 2014


Building libpciaccess generates a warning on versions of Linux in which
the definition of the struct mtrr_sentry has changed to __u64.

Since sentry.base is assigned from a pciaddr_t, always cast sentry.base
to be type pciaddr_t and modify the formatting string to use PRIx64
instead of %08lx

Verified on Ubuntu 10.04 and 14.04

Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=74643

Signed-off-by: Chuck Tuffli <chuck at tuffli.net>
---
 src/linux_sysfs.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/linux_sysfs.c b/src/linux_sysfs.c
index 97fcf36..8ae22b2 100644
--- a/src/linux_sysfs.c
+++ b/src/linux_sysfs.c
@@ -589,8 +589,8 @@ pci_device_linux_sysfs_map_range(struct pci_device *dev,
 	    /* FIXME: Should we report an error in this case?
 	     */
 	    fprintf(stderr, "error setting MTRR "
-		    "(base = 0x%08lx, size = 0x%08x, type = %u) %s (%d)\n",
-		    sentry.base, sentry.size, sentry.type,
+		    "(base = 0x%016" PRIx64 ", size = 0x%08x, type = %u) %s (%d)\n",
+		    (pciaddr_t)sentry.base, sentry.size, sentry.type,
 		    strerror(errno), errno);
 /*            err = errno;*/
 	}
@@ -664,8 +664,8 @@ pci_device_linux_sysfs_unmap_range(struct pci_device *dev,
 	    /* FIXME: Should we report an error in this case?
 	     */
 	    fprintf(stderr, "error setting MTRR "
-		    "(base = 0x%08lx, size = 0x%08x, type = %u) %s (%d)\n",
-		    sentry.base, sentry.size, sentry.type,
+		    "(base = 0x%016" PRIx64 ", size = 0x%08x, type = %u) %s (%d)\n",
+		    (pciaddr_t)sentry.base, sentry.size, sentry.type,
 		    strerror(errno), errno);
 /*            err = errno;*/
 	}
-- 
1.7.0.4



More information about the xorg-devel mailing list