From nobody Mon Apr 10 05:08:01 2023 X-Original-To: dev-commits-src-all@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 4PvxnF5zHFz44mlc; Mon, 10 Apr 2023 05:08:01 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PvxnF3yx5z3Q3N; Mon, 10 Apr 2023 05:08:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681103281; 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=LA0VP0L0c9OxM8KX4zxSwm5h+cPKiHrSI/O2qoXBM7w=; b=m1iqjs/QpyqZq8bRRwdI2i50NO1kKK9JSHuE/yTt7rZ9Zc1ttm2GvyBvMbvd5WEwwPX0SP IrVNcd80uTZw3dUXZeEebTeiJeiJ9HMPTYExUCx0aZ/9cIMNLwSxTGR+5bhb1eaPGL+Kla ClmFAKlpjHmmynDEAPNGCGBYZtD9T4hxtlVFr/ErLIVXE2T/oSasgbXmpb3InSmJBpaBXu APvpJ5wWViTF7mG5oV5FLeYguotBv805rLXwI+GJVNqjGOSMWsmzpjKLl6EFQjdeq6e9W9 43FF/f4LSnuysqqbalPiIaRpz1jyYbWd6sK6Cw5vzAc8rWqlZoL0NDls1chALw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1681103281; 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=LA0VP0L0c9OxM8KX4zxSwm5h+cPKiHrSI/O2qoXBM7w=; b=BkWAfBpW8r1k7mD4vQLCpFuqZFrKqXboxaWeI7Mmw4ZqUIGkwb8433jUnLEzWXv8TMuhON YJIZyMxs6GW4Z7RofX0OIhDBpJ0tNcPkFj/4FHTJNf2j8W8hNGUlbyVNKkvVTBbY/qo5HV OvFYimZW/vSLIJ1m5+9Z8W+QxGHtapPVVOjb3JgNI97HpOcfANqVu0chpKCYsBCNGVOp8H 5Pjukb5XJ5VEFzC6rQFcEXEjWFwd/luwFvCBFbqvcMZ8viBQHUjwTJezz6LOCC10yEsPIW Kxp/Usi1e5aU4SMiw9b1EEHQH5ze9q1DSGiKt964C8ex1GeEQTPEoBJP9WQ+EA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1681103281; a=rsa-sha256; cv=none; b=dsYxCLCy76oIEOzYTIQDtlp4fTn/auAm2TvVOuZ6VhKycD6jESO+r8IEKgoHbGyoU0zNtE hwRBgSerdbAw6IfJ/IGcpX8+6AKfDCi0KSNBa+5jyRqe3kiJHvAHbPJPSIRc3JrxO903CW jpSGqIhHe9jf7/bZ0aIdWAahk+MgUmsDGqmTChFWswHiPgVByCniXF3ByaYitEqkM39LIO QST7zz8uUMzMgojhgi+SLv4wX/iP7lBg27sSb+Wx5NydML3++7M1UCOofMu9qZG1EfMiNu N2js5je/emkBx82Pdwep7KQMJNqBu2eSJEJTDEVP4fISFrPoRHm6M0S220a7gA== 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 4PvxnF2HXGzd3m; Mon, 10 Apr 2023 05:08:01 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 33A581EJ022201; Mon, 10 Apr 2023 05:08:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 33A581cp022200; Mon, 10 Apr 2023 05:08:01 GMT (envelope-from git) Date: Mon, 10 Apr 2023 05:08:01 GMT Message-Id: <202304100508.33A581cp022200@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: d7dd3c8274aa - stable/12 - lacp: Use C99 bool for boolean return value List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/12 X-Git-Reftype: branch X-Git-Commit: d7dd3c8274aa48e1e29f1232773ef88ff4baf73c Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=d7dd3c8274aa48e1e29f1232773ef88ff4baf73c commit d7dd3c8274aa48e1e29f1232773ef88ff4baf73c Author: Zhenlei Huang AuthorDate: 2023-03-31 17:48:36 +0000 Commit: Zhenlei Huang CommitDate: 2023-04-10 05:06:22 +0000 lacp: Use C99 bool for boolean return value This improves readability. No functional change intended. MFC after: 1 week (cherry picked from commit 5a8abd0a298e6e7a8bf938a7eb171b647b1860cd) (cherry picked from commit d1d5d8f69659c4d3573e64a62a9306ee944d9e4d) --- sys/net/ieee8023ad_lacp.c | 38 +++++++++++++++++--------------------- sys/net/ieee8023ad_lacp.h | 15 ++++++--------- sys/net/if_lagg.c | 2 +- 3 files changed, 24 insertions(+), 31 deletions(-) diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index 61cd94e5ce2f..2160baf18351 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -115,9 +115,9 @@ static void lacp_fill_aggregator_id(struct lacp_aggregator *, const struct lacp_port *); static void lacp_fill_aggregator_id_peer(struct lacp_peerinfo *, const struct lacp_peerinfo *); -static int lacp_aggregator_is_compatible(const struct lacp_aggregator *, +static bool lacp_aggregator_is_compatible(const struct lacp_aggregator *, const struct lacp_port *); -static int lacp_peerinfo_is_compatible(const struct lacp_peerinfo *, +static bool lacp_peerinfo_is_compatible(const struct lacp_peerinfo *, const struct lacp_peerinfo *); static struct lacp_aggregator *lacp_aggregator_get(struct lacp_softc *, @@ -1337,44 +1337,40 @@ lacp_fill_aggregator_id_peer(struct lacp_peerinfo *lpi_aggr, * lacp_aggregator_is_compatible: check if a port can join to an aggregator. */ -static int +static bool lacp_aggregator_is_compatible(const struct lacp_aggregator *la, const struct lacp_port *lp) { if (!(lp->lp_state & LACP_STATE_AGGREGATION) || !(lp->lp_partner.lip_state & LACP_STATE_AGGREGATION)) { - return (0); + return (false); } - if (!(la->la_actor.lip_state & LACP_STATE_AGGREGATION)) { - return (0); - } + if (!(la->la_actor.lip_state & LACP_STATE_AGGREGATION)) + return (false); - if (!lacp_peerinfo_is_compatible(&la->la_partner, &lp->lp_partner)) { - return (0); - } + if (!lacp_peerinfo_is_compatible(&la->la_partner, &lp->lp_partner)) + return (false); - if (!lacp_peerinfo_is_compatible(&la->la_actor, &lp->lp_actor)) { - return (0); - } + if (!lacp_peerinfo_is_compatible(&la->la_actor, &lp->lp_actor)) + return (false); - return (1); + return (true); } -static int +static bool lacp_peerinfo_is_compatible(const struct lacp_peerinfo *a, const struct lacp_peerinfo *b) { if (memcmp(&a->lip_systemid, &b->lip_systemid, - sizeof(a->lip_systemid))) { - return (0); + sizeof(a->lip_systemid)) != 0) { + return (false); } - if (memcmp(&a->lip_key, &b->lip_key, sizeof(a->lip_key))) { - return (0); - } + if (memcmp(&a->lip_key, &b->lip_key, sizeof(a->lip_key)) != 0) + return (false); - return (1); + return (true); } static void diff --git a/sys/net/ieee8023ad_lacp.h b/sys/net/ieee8023ad_lacp.h index 10c6a2c9f892..858500d12b33 100644 --- a/sys/net/ieee8023ad_lacp.h +++ b/sys/net/ieee8023ad_lacp.h @@ -300,7 +300,7 @@ void lacp_linkstate(struct lagg_port *); void lacp_req(struct lagg_softc *, void *); void lacp_portreq(struct lagg_port *, void *); -static __inline int +static __inline bool lacp_isactive(struct lagg_port *lgp) { struct lacp_port *lp = LACP_PORT(lgp); @@ -308,26 +308,23 @@ lacp_isactive(struct lagg_port *lgp) struct lacp_aggregator *la = lp->lp_aggregator; /* This port is joined to the active aggregator */ - if (la != NULL && la == lsc->lsc_active_aggregator) - return (1); - - return (0); + return (la != NULL && la == lsc->lsc_active_aggregator); } -static __inline int +static __inline bool lacp_iscollecting(struct lagg_port *lgp) { struct lacp_port *lp = LACP_PORT(lgp); - return ((lp->lp_state & LACP_STATE_COLLECTING) != 0); + return (lp->lp_state & LACP_STATE_COLLECTING); } -static __inline int +static __inline bool lacp_isdistributing(struct lagg_port *lgp) { struct lacp_port *lp = LACP_PORT(lgp); - return ((lp->lp_state & LACP_STATE_DISTRIBUTING) != 0); + return (lp->lp_state & LACP_STATE_DISTRIBUTING); } /* following constants don't include terminating NUL */ diff --git a/sys/net/if_lagg.c b/sys/net/if_lagg.c index 6a6f08b9696e..b970e1a9f2b1 100644 --- a/sys/net/if_lagg.c +++ b/sys/net/if_lagg.c @@ -2441,7 +2441,7 @@ lagg_lacp_input(struct lagg_softc *sc, struct lagg_port *lp, struct mbuf *m) * If the port is not collecting or not in the active aggregator then * free and return. */ - if (lacp_iscollecting(lp) == 0 || lacp_isactive(lp) == 0) { + if (!lacp_iscollecting(lp) || !lacp_isactive(lp)) { m_freem(m); return (NULL); }