summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Georgi <patrick@georgi-clan.de>2014-08-09 19:42:08 +0200
committerPatrick Georgi <patrick@georgi-clan.de>2014-08-10 08:19:44 +0200
commitb6239b81aa3a3ac9cb08aa70d1f1179e1619f429 (patch)
tree32e1b451615c0a928777d50bf37326070553ed9f
parentf17c58b415219d889fe57a06be63f826f7a7c1b7 (diff)
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@georgi-clan.de> Reviewed-on: http://review.coreboot.org/6568 Tested-by: build bot (Jenkins) Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--util/romcc/romcc.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c
index 84270bb985..49b4dd4720 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')) {