scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit dabd4e4777ed3de63147b169229d5e3d262069b8
parent 5dd3570c988cbd1b3dc314bd3766e2b458116c97
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Fri, 15 Dec 2017 11:50:45 +0000

[lib/c] Simplify getnum() in vfprintf()

We don't need the val value in unsigned types,
and there isn't any reason to do a double assignation
to uval in signed types.

Diffstat:
Mlib/c/vfprintf.c | 20++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/lib/c/vfprintf.c b/lib/c/vfprintf.c @@ -44,26 +44,26 @@ getnum(va_list va, int flags, int *sign) intmax_t val; if (flags & CHAR) { - val = uval = va_arg(va, int); + val = va_arg(va, int); uval = (unsigned char) uval; } else if (flags & SHORT) { - val = uval = va_arg(va, int); - uval = (unsigned short) uval; + val = va_arg(va, int); + uval = (unsigned short) val; } else if (flags & LONG) { - val = uval = va_arg(va, long); - uval = (unsigned long) uval; + val = va_arg(va, long); + uval = (unsigned long) val; } else if (flags & LLONG) { val = uval = va_arg(va, long long); uval = (unsigned long long) uval; } else if (flags & SIZET) { - val = uval = va_arg(va, size_t); - uval = (size_t) uval; + uval = va_arg(va, size_t); } else if (flags & INTMAX) { - val = uval = va_arg(va, uintmax_t); + val = va_arg(va, intmax_t); + uval = (uintmax_t) val; } else if (flags & VOIDPTR) { - val = uval = (uintmax_t) va_arg(va, void *); + uval = (uintmax_t) va_arg(va, void *); } else { - val = uval = va_arg(va, int); + val = va_arg(va, int); uval = (unsigned) uval; }