git: a14de491e031 - main - nvmf_tcp: Use min() to simplify a few statements
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 30 Jul 2024 14:29:18 UTC
The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a14de491e031338c6b939e31c423078b36b8c2f3 commit a14de491e031338c6b939e31c423078b36b8c2f3 Author: John Baldwin <jhb@FreeBSD.org> AuthorDate: 2024-07-30 14:26:14 +0000 Commit: John Baldwin <jhb@FreeBSD.org> CommitDate: 2024-07-30 14:26:14 +0000 nvmf_tcp: Use min() to simplify a few statements Sponsored by: Chelsio Communications --- sys/dev/nvmf/nvmf_tcp.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/sys/dev/nvmf/nvmf_tcp.c b/sys/dev/nvmf/nvmf_tcp.c index 8f1b3bf01e39..6c84a40611c3 100644 --- a/sys/dev/nvmf/nvmf_tcp.c +++ b/sys/dev/nvmf/nvmf_tcp.c @@ -623,10 +623,7 @@ mbuf_copyto_io(struct mbuf *m, u_int skip, u_int len, while (len != 0) { MPASS((m->m_flags & M_EXTPG) == 0); - todo = m->m_len - skip; - if (todo > len) - todo = len; - + todo = min(m->m_len - skip, len); memdesc_copyback(&io->io_mem, io_offset, todo, mtodo(m, skip)); skip = 0; io_offset += todo; @@ -1000,9 +997,7 @@ nvmf_tcp_handle_r2t(struct nvmf_tcp_qpair *qp, struct nvmf_tcp_rxpdu *pdu) struct mbuf *m; uint32_t sent, todo; - todo = data_len; - if (todo > qp->max_tx_data) - todo = qp->max_tx_data; + todo = min(data_len, qp->max_tx_data); m = nvmf_tcp_command_buffer_mbuf(cb, data_offset, todo, &sent, todo < data_len); tcp_send_h2c_pdu(qp, r2t->cccid, r2t->ttag, data_offset, m, @@ -1458,8 +1453,7 @@ tcp_allocate_qpair(bool controller, qp->maxh2cdata = params->tcp.maxh2cdata; qp->max_tx_data = tcp_max_transmit_data; if (!controller) { - if (qp->max_tx_data > params->tcp.maxh2cdata) - qp->max_tx_data = params->tcp.maxh2cdata; + qp->max_tx_data = min(qp->max_tx_data, params->tcp.maxh2cdata); } qp->max_icd = params->tcp.max_icd;