Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ef124960 authored by Jason Gunthorpe's avatar Jason Gunthorpe Committed by Linus Torvalds
Browse files

lib/vsprintf.c: fix handling of %zd when using ssize_t



Documentation/printk-formats.txt says to use %zd for a ssize_t argument
and some drivers do.  Unfortunately this prints a positive number for
negative values eg:

  tpm_tis 70030000.tpm_tis: tpm_transmit: tpm_send: error 4294967234

Add a case to va_args a ssize_t type if the interpretation should be
signed.

Tested on PPC32.

Signed-off-by: default avatarJason Gunthorpe <jgunthorpe@obsidianresearch.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 2fa72c8f
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1485,6 +1485,9 @@ int vsnprintf(char *buf, size_t size, const char *fmt, va_list args)
				num = va_arg(args, long);
				break;
			case FORMAT_TYPE_SIZE_T:
				if (spec.flags & SIGN)
					num = va_arg(args, ssize_t);
				else
					num = va_arg(args, size_t);
				break;
			case FORMAT_TYPE_PTRDIFF: