json_config: do not attempt to resolve JSON that failed decode

When config entry fails spdk_json_decode_object(),
that basically means incorrectly formatted JSON config.
Decode object is simple enough here - 'method' and optional 'params'.

Before this change SPDK_ERRLOG printed garbage, rather than JSON
object that failed the decode.

We actually should not do it at all:
- the object is not formatted right already
- it might be the last object, so spdk_json_next() won't work

It was not usefull, so this patch removes it.

Signed-off-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
Change-Id: Ife67ac0d9a1a66d567bfbdd5896e893f3e8cb3ca
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3257
Community-CI: Mellanox Build Bot
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Tomasz Zawadzki 2020-07-08 13:10:19 -04:00
parent cebf307b61
commit 241f290794

View File

@ -367,10 +367,7 @@ app_json_config_load_subsystem_config_entry(void *_ctx)
if (spdk_json_decode_object(ctx->config_it, jsonrpc_cmd_decoders,
SPDK_COUNTOF(jsonrpc_cmd_decoders), &cfg)) {
params_end = spdk_json_next(ctx->config_it);
assert(params_end != NULL);
params_len = params_end->start - ctx->config->start + 1;
SPDK_ERRLOG("Failed to decode config entry: %.*s!\n", (int)params_len, (char *)ctx->config_it);
SPDK_ERRLOG("Failed to decode config entry\n");
app_json_config_load_done(ctx, -EINVAL);
goto out;
}