[coreboot-gerrit] New patch to review for coreboot: b13685f romcc: properly check out-of-range unsigned longs
Patrick Georgi (patrick@georgi-clan.de)
gerrit at coreboot.org
Sat Aug 9 19:43:49 CEST 2014
Patrick Georgi (patrick at georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6568
-gerrit
commit b13685f07234b4452e0f62615b782a6dda3cf708
Author: Patrick Georgi <patrick at georgi-clan.de>
Date: Sat Aug 9 19:42:08 2014 +0200
romcc: properly check out-of-range unsigned longs
Testing if an unsigned long is greater than ULONG_T_MAX isn't very
useful. The second half of the test checked for too small values
(ie. <= -ULONG_T_MAX).
In both cases errno is set to ERANGE, so just check for that.
Change-Id: I92bad9d1715673531bef5d5d5756feddeb7674b4
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick at georgi-clan.de>
---
util/romcc/romcc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c
index 84270bb..49b4dd4 100644
--- a/util/romcc/romcc.c
+++ b/util/romcc/romcc.c
@@ -10797,8 +10797,8 @@ static struct triple *integer_constant(struct compile_state *state)
errno = 0;
decimal = (tk->val.str[0] != '0');
val = strtoul(tk->val.str, &end, 0);
- if ((val > ULONG_T_MAX) || ((val == ULONG_MAX) && (errno == ERANGE))) {
- error(state, 0, "Integer constant to large");
+ if (errno == ERANGE) {
+ error(state, 0, "Integer constant out of range");
}
u = l = 0;
if ((*end == 'u') || (*end == 'U')) {
More information about the coreboot-gerrit
mailing list