From f7e8827aa666a3a0bd5cd80d2994ccd30b7767cd Mon Sep 17 00:00:00 2001 From: "dongx.yi" Date: Thu, 2 Jan 2020 09:03:58 -0500 Subject: [PATCH] nvmf/tcp: Using spdk_min instead of multi-lines codes. We can use spdk_min to get the copy_len in spdk_nvmf_tcp_send_c2h_term_req. It confirms copy_len it's not larger than SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE Signed-off-by: dongx.yi Change-Id: Id343928e1911e4ab77fca7463f3f0cc55889db30 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/479118 Community-CI: SPDK CI Jenkins Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Shuhei Matsumoto Reviewed-by: Ben Walker --- lib/nvmf/tcp.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/lib/nvmf/tcp.c b/lib/nvmf/tcp.c index 135a5ef253..b0d23d3c27 100644 --- a/lib/nvmf/tcp.c +++ b/lib/nvmf/tcp.c @@ -1252,10 +1252,7 @@ spdk_nvmf_tcp_send_c2h_term_req(struct spdk_nvmf_tcp_qpair *tqpair, struct nvme_ DSET32(&c2h_term_req->fei, error_offset); } - copy_len = pdu->hdr->common.hlen; - if (copy_len > SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE) { - copy_len = SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE; - } + copy_len = spdk_min(pdu->hdr->common.hlen, SPDK_NVME_TCP_TERM_REQ_ERROR_DATA_MAX_SIZE); /* Copy the error info into the buffer */ memcpy((uint8_t *)rsp_pdu->hdr->raw + c2h_term_req_hdr_len, pdu->hdr->raw, copy_len);