From 7c1d827f7826b06711c60c4b0fe180444c19f0e3 Mon Sep 17 00:00:00 2001 From: Daniel Verkamp Date: Mon, 5 Jun 2017 15:33:24 -0700 Subject: [PATCH] json_util: remove spdk_json_number_to_double() This function is no longer used for integer parsing, and it does not work in locales with decimal separators other than '.', which is required to be the decimal separator for JSON numbers. Change-Id: I8e97e15cc2699e647652f83b71676c11d32d29ce Signed-off-by: Daniel Verkamp Reviewed-on: https://review.gerrithub.io/364134 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker --- include/spdk/json.h | 1 - lib/json/json_util.c | 24 ------------------------ 2 files changed, 25 deletions(-) diff --git a/include/spdk/json.h b/include/spdk/json.h index 915939d70..ed5fb660e 100644 --- a/include/spdk/json.h +++ b/include/spdk/json.h @@ -176,7 +176,6 @@ bool spdk_json_strequal(const struct spdk_json_val *val, const char *str); */ char *spdk_json_strdup(const struct spdk_json_val *val); -int spdk_json_number_to_double(const struct spdk_json_val *val, double *num); int spdk_json_number_to_int32(const struct spdk_json_val *val, int32_t *num); int spdk_json_number_to_uint32(const struct spdk_json_val *val, uint32_t *num); diff --git a/lib/json/json_util.c b/lib/json/json_util.c index 18bf48d1b..edf9a83f5 100644 --- a/lib/json/json_util.c +++ b/lib/json/json_util.c @@ -199,30 +199,6 @@ spdk_json_number_split(const struct spdk_json_val *val, struct spdk_json_num *nu return 0; } -int -spdk_json_number_to_double(const struct spdk_json_val *val, double *num) -{ - char buf[32]; - char *end; - - if (val->type != SPDK_JSON_VAL_NUMBER || val->len >= sizeof(buf)) { - *num = 0.0; - return -1; - } - - memcpy(buf, val->start, val->len); - buf[val->len] = '\0'; - - errno = 0; - /* TODO: strtod() uses locale for decimal point (. is not guaranteed) */ - *num = strtod(buf, &end); - if (*end != '\0' || errno != 0) { - return -1; - } - - return 0; -} - int spdk_json_number_to_int32(const struct spdk_json_val *val, int32_t *num) {