diff --git a/libc/stdlib/lib_strtod.c b/libc/stdlib/lib_strtod.c index 9b7462368b..bd2a55e996 100644 --- a/libc/stdlib/lib_strtod.c +++ b/libc/stdlib/lib_strtod.c @@ -115,6 +115,8 @@ double_t strtod(FAR const char *str, FAR char **endptr) negative = 1; /* Fall through to increment position */ case '+': p++; + default: + break; } number = 0.; @@ -151,7 +153,8 @@ double_t strtod(FAR const char *str, FAR char **endptr) if (num_digits == 0) { set_errno(ERANGE); - return 0.0; + number = 0.0; + goto errout; } /* Correct for sign */ @@ -174,6 +177,8 @@ double_t strtod(FAR const char *str, FAR char **endptr) negative = 1; /* Fall through to increment pos */ case '+': p++; + default: + break; } /* Process string of digits */ @@ -199,7 +204,8 @@ double_t strtod(FAR const char *str, FAR char **endptr) exponent > __DBL_MAX_EXP__) { set_errno(ERANGE); - return infinite; + number = infinite; + goto errout; } /* Scale the result */ @@ -220,6 +226,7 @@ double_t strtod(FAR const char *str, FAR char **endptr) number *= p10; } } + n >>= 1; p10 *= p10; } @@ -229,6 +236,7 @@ double_t strtod(FAR const char *str, FAR char **endptr) set_errno(ERANGE); } +errout: if (endptr) { *endptr = p;