Commit 3e449a54 authored by Konrad Sztyber's avatar Konrad Sztyber Committed by Tomasz Zawadzki
Browse files

json: add spdk_json_decode_uuid()



Similarly to spdk_json_write_uuid(), there are lots of places where we
need to decode a JSON string to spdk_uuid and each of them has to decode
and parse the string.

Signed-off-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Change-Id: Ia1e1b5e28b29b741295c318b642f533808f94296
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/20474


Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
parent 8cffbe01
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -132,6 +132,7 @@ int spdk_json_decode_int32(const struct spdk_json_val *val, void *out);
int spdk_json_decode_uint32(const struct spdk_json_val *val, void *out);
int spdk_json_decode_uint64(const struct spdk_json_val *val, void *out);
int spdk_json_decode_string(const struct spdk_json_val *val, void *out);
int spdk_json_decode_uuid(const struct spdk_json_val *val, void *out);

void spdk_json_free_object(const struct spdk_json_object_decoder *decoders, size_t num_decoders,
			   void *obj);
+18 −0
Original line number Diff line number Diff line
@@ -498,6 +498,24 @@ spdk_json_decode_string(const struct spdk_json_val *val, void *out)
	}
}

int
spdk_json_decode_uuid(const struct spdk_json_val *val, void *out)
{
	struct spdk_uuid *uuid = out;
	char *str = NULL;
	int rc;

	rc = spdk_json_decode_string(val, &str);
	if (rc != 0) {
		return rc;
	}

	rc = spdk_uuid_parse(uuid, str);
	free(str);

	return rc;
}

static struct spdk_json_val *
json_first(struct spdk_json_val *object, enum spdk_json_val_type type)
{
+1 −0
Original line number Diff line number Diff line
@@ -13,6 +13,7 @@
	spdk_json_decode_uint32;
	spdk_json_decode_uint64;
	spdk_json_decode_string;
	spdk_json_decode_uuid;

	spdk_json_free_object;