libc: printf: Add support for 'z' length specifier

The 'z' length specifier is the appropriate one to be used with size_t
(%zu) and ssize_t (%zd) types. Having support for this in our libc
means that we can utilize the compiler format string checks
(__printf_like) without getting warnings of incorrect format
specifiers for size_t and ssize_t variables.

Change-Id: I73fec0145692e0a59934cab548caf24c1c16a3df
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
Johan Hedberg 2016-09-07 11:25:18 +03:00 committed by Andrew Boie
commit 65a8e3c1c9

View file

@ -615,10 +615,11 @@ int _prf(int (*func)(), void *dest, char *format, va_list vargs)
* h: short
* l: long
* L: long double
* z: size_t or ssize_t
* No further special processing is done for them.
*/
if (strchr("hlL", c) != NULL) {
if (strchr("hlLz", c) != NULL) {
i = c;
c = *format++;
switch (i) {
@ -636,6 +637,12 @@ int _prf(int (*func)(), void *dest, char *format, va_list vargs)
if (strchr("eEfgG", c) == NULL)
break;
break;
case 'z':
if (strchr("diouxX", c) == NULL)
break;
break;
}
}