From nobody Tue Jul 30 14:29:18 2024 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4WYHfk41S7z5S4Fb; Tue, 30 Jul 2024 14:29:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WYHfk34w8z4ykv; Tue, 30 Jul 2024 14:29:18 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722349758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EgbgVWOGsqidNi8E1yoZyJ4XNTLLujfrh73+qzFm+BA=; b=WQHX2bSvCELTiHj3cTdMNzmnEktKLgtU5nFIfB9rLL0gFD8nsFFz72HOc+YK1GM0YdeSDw p3WMrf/aZ96qmZx4lctxSJVgik8hczYKu3NlrukayS5tHSd5ExLwMKJeWdFjmq2Pmz4iQn VAzYDKdLRtOPAJ83wt6QZfChJd09YmCY+ODCikWpK2XFL0aQ/kqIX2HIhggb49Hg75mPVl EFDfjgq7OBPWFPN1DEUL5G90vpBV6zIbBuzkUfxBlsLvcvG9TsQn2LyhGvEYdSdCH+wE8L MKD7sdRUNX4TtukKZbdKSWT0dLISOP0Y0pJKl9QxzSbF33jNGCIL/bChn7a8iw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1722349758; a=rsa-sha256; cv=none; b=SAsNpJhknHj3bvB7nFrAKmCCJGy959gKYUfIWwt6mM84ji6/cxhJZO0NV7svEKH8wF2Cr+ MRDVVdcpwXzPcBYIege1NNwpYxH1ycd1bIVcIDtGGsU/mMorosOJ61qdgtj9146b5X7vDg Om7M3JukGTwbhMwVk6DnZlYHfrha8Y8BpXWdD3y84N8e5bDLmkehBz1xjvsJBG6CMIduHS wMREGf8OIfkTWJci8gTDvd5XrjUAE9pEeC5YmGSo8iJeI8y42Vg0M8BVnE2pbmb/Qopvu2 /yi5pOnu1Boin2/Kk3eCqx1ed6Ucvoy64zE1PKtSwbDMt/+TEgYDOMKkRbeeYQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1722349758; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=EgbgVWOGsqidNi8E1yoZyJ4XNTLLujfrh73+qzFm+BA=; b=bHfDrx+xlOxsFUheQuT1dn3mUsLaSE9Vq4TPmUbBbi76+SoSbP+CgJE/LLMUOC5CRA5FCy 6eVmSBBpFLuvu0EKyFxVV//0+L+wCrUHLrBiKkP6iVb26N62DWN0Gi0eqCtslogz/eUasd 1uVK3D8GD+8VGHaTjybgNAC023qZQKl4bTnP9rD79eucv4p2Qx0c4RrGCQgRlib6rZDzzG bn3Vf9g3fQdybKijAVWmJEFRVH4ymna86jJivdBCVtFU7W2x4wiz1/qe5tAYs0B1aqbAiu 8lNCQpnZJZ/VX1ES1tGrLkctBzZn+bKyF/9vx6kg0SJ+G+k/czNsAmTrW8JgRg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4WYHfk2hDSzLsl; Tue, 30 Jul 2024 14:29:18 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46UETIbc029563; Tue, 30 Jul 2024 14:29:18 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46UETIY7029560; Tue, 30 Jul 2024 14:29:18 GMT (envelope-from git) Date: Tue, 30 Jul 2024 14:29:18 GMT Message-Id: <202407301429.46UETIY7029560@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John Baldwin Subject: git: a14de491e031 - main - nvmf_tcp: Use min() to simplify a few statements List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jhb X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a14de491e031338c6b939e31c423078b36b8c2f3 Auto-Submitted: auto-generated The branch main has been updated by jhb: URL: https://cgit.FreeBSD.org/src/commit/?id=a14de491e031338c6b939e31c423078b36b8c2f3 commit a14de491e031338c6b939e31c423078b36b8c2f3 Author: John Baldwin AuthorDate: 2024-07-30 14:26:14 +0000 Commit: John Baldwin 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;