roken: strtoull.c negation is a no-op on unsigned integer

strtoull() returns an unsigned long long.  However, then the input
string represents a negative number the return value is supposed to
be the unsigned representation of the negative value.  Before applying
the negation the value must be cast to (long long).

Change-Id: Icf9e75400ff736819b1f7e0e6fb3c8abd707a23a
This commit is contained in:
Jeffrey Altman
2019-01-21 22:28:02 -05:00
parent b10ad7eb57
commit 9ce2683f2d

View File

@@ -119,9 +119,8 @@ strtoull(const char * nptr, char ** endptr, int base)
noconv:
errno = EINVAL;
} else if (neg)
acc = -acc;
acc = -(long long)acc;
if (endptr != NULL)
*endptr = (char *)(any ? s - 1 : nptr);
return (acc);
}