shithub: scc

Download patch

ref: 802fc685de68e0b4ef93de81a8270f9b3642085b
parent: 137fa07a5497bf9394dea69c263f651695c900f9
author: Roberto E. Vargas Caballero <[email protected]>
date: Fri Dec 15 06:50:45 EST 2017

[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.

--- a/lib/c/vfprintf.c
+++ b/lib/c/vfprintf.c
@@ -44,26 +44,26 @@
 	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;
 	}