util/string: additional errno check after strtol()
Without this check valgrind complains that we are using uninitialized variable. Change-Id: I5cb73d10e167004f6e4df9e3621ec3b35ec2448d Signed-off-by: Wojciech Malikowski <wojciech.malikowski@intel.com> Reviewed-on: https://review.gerrithub.io/c/442519 Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
parent
6903c407a5
commit
f0e6bbea0a
@ -425,7 +425,7 @@ spdk_strtol(const char *nptr, int base)
|
||||
|
||||
val = strtol(nptr, &endptr, base);
|
||||
|
||||
if (*endptr != '\0') {
|
||||
if (!errno && *endptr != '\0') {
|
||||
/* Non integer character was found. */
|
||||
return -EINVAL;
|
||||
} else if (errno == ERANGE && (val == LONG_MAX || val == LONG_MIN)) {
|
||||
@ -456,7 +456,7 @@ spdk_strtoll(const char *nptr, int base)
|
||||
|
||||
val = strtoll(nptr, &endptr, base);
|
||||
|
||||
if (*endptr != '\0') {
|
||||
if (!errno && *endptr != '\0') {
|
||||
/* Non integer character was found. */
|
||||
return -EINVAL;
|
||||
} else if (errno == ERANGE && (val == LLONG_MAX || val == LLONG_MIN)) {
|
||||
|
Loading…
Reference in New Issue
Block a user