From nobody Tue Jun 27 22:29:34 2023 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 4QrKC30Rdpz4l01l; Tue, 27 Jun 2023 22:29:35 +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 4QrKC301M9z3tQT; Tue, 27 Jun 2023 22:29:35 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687904975; 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=CMS2rAhuTdc5Gqe8hO6JHVkYUcH0HvzM9sqKNkc5crg=; b=ZJHjON38BZ1SHzCHfyg9eqLZNqBu5lgFz5qEy7nQ6l2G+2boFwwD3px9HdsoeEPxgNpj9R oF5cfJiz7d17ieDlzeKBZEAksxdhyw9yq9sPGg9Oi56b1XntJm/dIhV4lqEIl3HIsZ2xj1 U7ww5USS3k4sAhhe31TKobVZlgBhd+8HpzWYdBvs7Mam51FcVdXrjX6OCk6wT70z7De5k0 K/m4BunV0ki0qtnGSaSfKN1dhyjNnlsXdhKfr4iL/q10lAFka+A10pTiFO1mVSX8i6HA4w vloIEyVZD+qMfuFXEjQ3OodOj/zc2LvSd6Y7BwgKIy1bF9SsEkH+gC5MGwEYmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1687904975; 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=CMS2rAhuTdc5Gqe8hO6JHVkYUcH0HvzM9sqKNkc5crg=; b=msfvZq/Um+BeOpZrn05Oel4XXZ1Ywckw6547S9+1+5xcTQlZNlT6ZzDwQ3XO87/6uIPY5f vL4h+GV46wZq2dcIv3pdmYEWEaf6q9XTgxGNo4HFTUt18AQL2GtEnAVyhVII8O65ZoE7nS k7b5gB/orINUK4Z56gg5TwJv59zUP/FjuLcz42cm3w3vS2qvDXU9ZIpNZ/2qT78daGE+ww 20n1N1UuEc2vFShp2u7OdDLzNhN5ICSH0RvTCVEbeUwuPXYvikEYngOFsELMtGAlsrnjsH UMEsAwEEiwYB2aiYnOp6TzyeiRHOJM/LbBWaINp+RuNfM336dI4M41AmrXJjsA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1687904975; a=rsa-sha256; cv=none; b=rZidGpRrinFL0JMfCOcaV93k3TIq9NbdN5D6GZPKaG4lsFCz6kwNndmHT5EkhqIZB9/v+D x2vk2RTMnX3wI0hnjeU7zy+vo8cFGNwGA80WL/2UkZNz441nnqYkAwN/HPjmwiXTaEj736 e6hDaA6QuM44ofJGRC0xO7Wdv/1XIjFi+0S5P69+h7hFglt7+fvOov0+PjrhwaBJni4qLr IcF+nZ0sDFhJ6s4pDCujR0ofErlfGfkoRv0IoYzgyJCAQTn8PvyV1bn+RKniZkRRhmTdlh aNyTaFlpMsYAil6wA25zES8FAVApWmvXxq6XmXfB4yV3GF3EYx0gjAWqC438zQ== 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 4QrKC26C6Zz182j; Tue, 27 Jun 2023 22:29:34 +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 35RMTYAO031765; Tue, 27 Jun 2023 22:29:34 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 35RMTYFQ031764; Tue, 27 Jun 2023 22:29:34 GMT (envelope-from git) Date: Tue, 27 Jun 2023 22:29:34 GMT Message-Id: <202306272229.35RMTYFQ031764@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 21c32cebf81a - main - ifconfig: skip calling fnmatch once the result no longer matters 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: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 21c32cebf81aa763771607ba3d7cc71b9eaa3fa1 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=21c32cebf81aa763771607ba3d7cc71b9eaa3fa1 commit 21c32cebf81aa763771607ba3d7cc71b9eaa3fa1 Author: Alfonso Gregory AuthorDate: 2023-06-27 22:18:55 +0000 Commit: Warner Losh CommitDate: 2023-06-27 22:28:44 +0000 ifconfig: skip calling fnmatch once the result no longer matters Because fnmatch has no side effects, we can safely avoid calling fnmatch if the end result does not matter anyway (the compiler cannot see this, so it calls fnmatch in the event it has side-effects). Reviewed by: imp Pull Request: https://github.com/freebsd/freebsd-src/pull/747 --- sbin/ifconfig/ifconfig.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 5d789795e636..b26fbaf82776 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -910,11 +910,11 @@ group_member(const char *ifname, const char *match, const char *nomatch) matched = false; nomatched = true; for (ifg = ifgr.ifgr_groups; ifg && len >= sizeof(*ifg); ifg++) { - len -= sizeof(struct ifg_req); - if (match) - matched |= !fnmatch(match, ifg->ifgrq_group, 0); - if (nomatch) - nomatched &= fnmatch(nomatch, ifg->ifgrq_group, 0); + len -= sizeof(*ifg); + if (match && !matched) + matched = !fnmatch(match, ifg->ifgrq_group, 0); + if (nomatch && nomatched) + nomatched = fnmatch(nomatch, ifg->ifgrq_group, 0); } free(ifgr.ifgr_groups);