Commit 841cd8b9 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Jim Harris
Browse files

module/blobfs: Use error_response() rather than bool_response(false) for JSON RPCs



For JSON RPC, boolean response with false value may not be regarded as error.
Previously many cases were replaced to use
spdk_jsonrpc_send_error_response() explicitly. Replace one of the
remaining cases in this patch.

rpc_blobfs_detect() uses boolean response for not only true but also
false, but it had a memory leak bug. Fix it together in this patch.

Signed-off-by: default avatarShuhei Matsumoto <smatsumoto@nvidia.com>
Change-Id: Iaff21115282f638038345daa986b5c743ba9a3ed
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16621


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarAleksey Marchuk <alexeymar@nvidia.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent c77bc554
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
/*   SPDX-License-Identifier: BSD-3-Clause
 *   Copyright (C) 2019 Intel Corporation.
 *   Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
 *   All rights reserved.
 */

@@ -54,7 +55,11 @@ rpc_blobfs_set_cache_size(struct spdk_jsonrpc_request *request,

	rc = spdk_fs_set_cache_size(req.size_in_mb);

	spdk_jsonrpc_send_bool_response(request, rc == 0);
	if (rc == 0) {
		spdk_jsonrpc_send_bool_response(request, true);
	} else {
		spdk_jsonrpc_send_error_response(request, rc, spdk_strerror(-rc));
	}
}

SPDK_RPC_REGISTER("blobfs_set_cache_size", rpc_blobfs_set_cache_size,
@@ -89,7 +94,7 @@ _rpc_blobfs_detect_done(void *cb_arg, int fserrno)
	} else if (fserrno != 0) {
		spdk_jsonrpc_send_error_response(req->request, SPDK_JSONRPC_ERROR_INTERNAL_ERROR,
						 spdk_strerror(-fserrno));

		free_rpc_blobfs_detect(req);
		return;
	}