Commit 1bc2c5ab authored by Pawel Wodkowski's avatar Pawel Wodkowski Committed by Jim Harris
Browse files

rpc: add bool-type decoder



Allow passing booleans in JSON.

Change-Id: I0b8f6c1579d8382b5b19a987ef5d913b4423c954
Signed-off-by: default avatarPawel Wodkowski <pawelx.wodkowski@intel.com>
parent fb87f80c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -146,6 +146,7 @@ int spdk_json_decode_object(const struct spdk_json_val *values,
int spdk_json_decode_array(const struct spdk_json_val *values, spdk_json_decode_fn decode_func,
			   void *out, size_t max_size, size_t *out_size, size_t stride);

int spdk_json_decode_bool(const struct spdk_json_val *val, void *out);
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_string(const struct spdk_json_val *val, void *out);
+13 −0
Original line number Diff line number Diff line
@@ -249,6 +249,19 @@ spdk_json_decode_array(const struct spdk_json_val *values, spdk_json_decode_fn d
	return 0;
}

int
spdk_json_decode_bool(const struct spdk_json_val *val, void *out)
{
	bool *f = out;

	if (val->type != SPDK_JSON_VAL_TRUE && val->type != SPDK_JSON_VAL_FALSE) {
		return -1;
	}

	*f = val->type == SPDK_JSON_VAL_TRUE;
	return 0;
}

int
spdk_json_decode_int32(const struct spdk_json_val *val, void *out)
{