[kvm-unit-tests PATCH 2/4] lib/alloc: fix format warnings, add/use PRIx64

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Andrew Jones <drjones@xxxxxxxxxx>
---
 lib/alloc.c    | 13 +++++++------
 lib/libcflat.h | 12 ++++++++++++
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/lib/alloc.c b/lib/alloc.c
index 34f71a337d868..e345843b7fe53 100644
--- a/lib/alloc.c
+++ b/lib/alloc.c
@@ -28,13 +28,13 @@ void phys_alloc_show(void)
 	int i;
 
 	spin_lock(&lock);
-	printf("phys_alloc minimum alignment: 0x%llx\n", align_min);
+	printf("phys_alloc minimum alignment: 0x%" PRIx64 "\n", align_min);
 	for (i = 0; i < nr_regions; ++i)
-		printf("%016llx-%016llx [%s]\n",
+		printf("%016" PRIx64 "-%016" PRIx64 " [%s]\n",
 			regions[i].base,
 			regions[i].base + regions[i].size - 1,
 			"USED");
-	printf("%016llx-%016llx [%s]\n", base, top - 1, "FREE");
+	printf("%016" PRIx64 "-%016" PRIx64 " [%s]\n", base, top - 1, "FREE");
 	spin_unlock(&lock);
 }
 
@@ -76,9 +76,10 @@ static phys_addr_t phys_alloc_aligned_safe(phys_addr_t size,
 	size += addr - base;
 
 	if ((top_safe - base) < size) {
-		printf("phys_alloc: requested=0x%llx (align=0x%llx), "
-		       "need=0x%llx, but free=0x%llx. "
-		       "top=0x%llx, top_safe=0x%llx\n",
+		printf("phys_alloc: requested=0x%" PRIx64
+		       " (align=0x%" PRIx64 "), "
+		       "need=0x%" PRIx64 ", but free=0x%" PRIx64 ". "
+		       "top=0x%" PRIx64 ", top_safe=0x%" PRIx64 "\n",
 		       size_orig, align, size, top_safe - base,
 		       top, top_safe);
 		spin_unlock(&lock);
diff --git a/lib/libcflat.h b/lib/libcflat.h
index ce09d34e658b3..36e300bf4d0ff 100644
--- a/lib/libcflat.h
+++ b/lib/libcflat.h
@@ -48,6 +48,18 @@ typedef _Bool		bool;
 #define false 0
 #define true  1
 
+#if __SIZEOF_LONG__ == 8
+#  define __PRI64_PREFIX	"l"
+#  define __PRIPTR_PREFIX	"l"
+#else
+#  define __PRI64_PREFIX	"ll"
+#  define __PRIPTR_PREFIX
+#endif
+#define PRId64  __PRI64_PREFIX	"d"
+#define PRIu64  __PRI64_PREFIX	"u"
+#define PRIx64  __PRI64_PREFIX	"x"
+#define PRIxPTR __PRIPTR_PREFIX	"x"
+
 extern void puts(const char *s);
 extern void exit(int code);
 extern void abort(void);
-- 
2.4.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux