lib/event: fix printing non-null-terminated strings

%*s prints at least * characters and may add padding to the string.
%.*s prints at most * characters.

In a few places we used the first instead of the second and
printed some garbage to screen (in the best case...).

Change-Id: I97a862be61a5e43aa61e8230044dbd64a9db33bd
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1569
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
This commit is contained in:
Darek Stojaczyk 2020-03-30 09:44:51 +02:00 committed by Tomasz Zawadzki
parent e71e81b631
commit df9660df7b
2 changed files with 3 additions and 3 deletions

View File

@ -189,7 +189,7 @@ rpc_client_poller(void *arg)
assert(resp);
if (resp->error) {
SPDK_ERRLOG("error response: %*s", (int)resp->error->len, (char *)resp->error->start);
SPDK_ERRLOG("error response: %.*s", (int)resp->error->len, (char *)resp->error->start);
}
if (resp->error && ctx->stop_on_error) {
@ -339,7 +339,7 @@ spdk_app_json_config_load_subsystem_config_entry(void *_ctx)
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: %.*s!\n", (int)params_len, (char *)ctx->config_it);
spdk_app_json_config_load_done(ctx, -EINVAL);
goto out;
}

View File

@ -308,7 +308,7 @@ spdk_jsonrpc_client_hook_conn_close(struct spdk_jsonrpc_client *client)
/* Check for error response */
if (json_resp->error != NULL) {
SPDK_ERRLOG("Unexpected error response: %*s\n", json_resp->error->len,
SPDK_ERRLOG("Unexpected error response: %.*s\n", json_resp->error->len,
(char *)json_resp->error->start);
rc = -EIO;
goto out;