[PATCH kvm-unit-tests] libcflat: add support for %zd and %td

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

 



These are useful to avoid warnings from the compiler.

Signed-off-by: Paolo Bonzini <pbonzini@xxxxxxxxxx>
---
 lib/printf.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/printf.c b/lib/printf.c
index 063a1ed..a96faee 100644
--- a/lib/printf.c
+++ b/lib/printf.c
@@ -176,6 +176,15 @@ int vsnprintf(char *buf, int size, const char *fmt, va_list va)
 	case 'l':
 	    ++nlong;
 	    goto morefmt;
+	case 't':
+	case 'z':
+	    /* Here we only care that sizeof(size_t) == sizeof(long).
+	     * On a 32-bit platform it doesn't matter that size_t is
+	     * typedef'ed to int or long; va_arg will work either way.
+	     * Same for ptrdiff_t (%td).
+	     */
+	    nlong = 1;
+	    goto morefmt;
 	case 'd':
 	    switch (nlong) {
 	    case 0:
-- 
2.12.2




[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