commit 418c9185f05e6f5f03ae39d95378c3724554b7f7
parent 3d8d5b6c54023328aaf6b2a4646f14d40ba3153c
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date: Thu, 8 Nov 2018 13:18:16 +0000
[debuglang] Tighten error checks for estrtoull()
Change-Id: I5a85241d016cc31f3b0d10cae44e5343f785e658
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>
Diffstat:
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/src/debuglang/debuglang.c b/src/debuglang/debuglang.c
@@ -85,11 +85,12 @@ estrtoull(char *str, int base)
unsigned long long val;
char *endptr;
- endptr = NULL;
errno = 0;
val = strtoull(str, &endptr, base);
- if (str == endptr || errno != 0)
- error("strtoull error with '%s' in base %d", str, base);
+ if (*str == '\0' || *endptr != '\0')
+ error("estrtoull: %s: not an integer", str);
+ if (errno)
+ error("estrtoull: %s: %s", strerror(errno));
return val;
}
@@ -318,7 +319,7 @@ debug(void)
}
/*
- * definintion of arrays
+ * definition of arrays
*/
static const struct cmd cmds[] = {
{