From c3a7e0c565c5d41e7d9b910a45c2248c2f3d5152 Mon Sep 17 00:00:00 2001 From: Viktor Dukhovni Date: Sun, 3 Apr 2016 15:21:34 -0400 Subject: [PATCH] After saving errno clear it before calls to strtol et. al. Reviewed-by: Richard Levitte --- apps/opt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/opt.c b/apps/opt.c index 462894a938..63d32150cc 100644 --- a/apps/opt.c +++ b/apps/opt.c @@ -373,6 +373,7 @@ int opt_long(const char *value, long *result) long l; char *endp; + errno = 0; l = strtol(value, &endp, 0); if (*endp || endp == value @@ -398,6 +399,7 @@ int opt_imax(const char *value, intmax_t *result) intmax_t m; char *endp; + errno = 0; m = strtoimax(value, &endp, 0); if (*endp || endp == value @@ -420,6 +422,7 @@ int opt_umax(const char *value, uintmax_t *result) uintmax_t m; char *endp; + errno = 0; m = strtoumax(value, &endp, 0); if (*endp || endp == value @@ -445,6 +448,7 @@ int opt_ulong(const char *value, unsigned long *result) char *endptr; unsigned long l; + errno = 0; l = strtoul(value, &endptr, 0); if (*endptr || endptr == value -- 2.25.1