Commit 7c1d827f authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

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: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/364134


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 7089d582
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -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);

+0 −24
Original line number Diff line number Diff line
@@ -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)
{