From nobody Sat Sep 27 15:14:15 2025 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 4cYrZw0kVsz68DCf; Sat, 27 Sep 2025 15:14:16 +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 "R12" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4cYrZv20nyz44XB; Sat, 27 Sep 2025 15:14:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758986055; 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=4mC52n28wUEHS5vk5lDc+qV6vIXgYAov1MzLXNBho8A=; b=oB/xVJOa3w9Gu+T2C7ZzY4Z1CmBcMW77A1GVrwi2qQRtoohaJJz3TAo9cau2K7DJUkUwUc saB0CGEQXjAFqbadHeJY3Rl7zv6Rh/XcKfDK1qNj5OBaoEDCGQ2TKchOUJ6tSkgTy9cK8j vuEOWyjiBAQt87PWYjApq79d4ou4NzYhKv3c1g3w40iS2qtc7w8xX83c0xKmvMhHIw8GTe LOvvPaQ56LkmWwSmNkWFeZrN4wketkH8VTYOfzphLkaNh+Ywm+7o6y3OA+MsFvlU0V82K9 KKosepZqaFYu6OohNWIs+xlJQRzNRAVQ7hXPPJ2muI7U7suR29J8TKXsYB5+kA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1758986055; 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=4mC52n28wUEHS5vk5lDc+qV6vIXgYAov1MzLXNBho8A=; b=VssliMcJ89/36E8i8Ius0j8CusnqafzoWqlpJZO0d5wRUd3CaWsKty2cf5MxyBlVcPgVZZ OlYyIgSuvR99E/P3u7rHFevZdWgUdW9HZHTJH4Q4UAuY/GNWXEkeVBjdFI9xsDoq6KEsJ+ C0AtR7VRKRAGbBpw0BnUBtgVF7tEO9z/1GakDsCOMIIeREloWJcI2ebw7EJLUKLiGrFgOd X1VakcwwkZEcxulsYTn80sqjFnE7vU5Jf9IfYU1YwQFcYW5SfctXuY6NVcT4Fh4zgiUsZB ZZTFE6qC4VQZSYbq73IO/ehBG56SH76a6k/pd1nAozvsq/V7xs45B4mG+gSmPQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1758986055; a=rsa-sha256; cv=none; b=vepHZ/PJb/nwYsOVUD2WD1ztksZH8IhtRRz/WUbSLvZtTuBW2Dtqc8QMI3swpg/zrW6lp0 FFPEVKWYXR0RlVu0ReMycDwvFw3q92hYrs9uVqJVLNzKHxGCrs0AEvH4YpVEV3vCqQTx0E uOfLgn+EJXiMqcmuwysiUBaDsnWHSjATqOzqwLPuDTvGfTDAtLqOcfmvY/dKDtjcshKb7v 9VzRZDnarOWxtaJrlUhNGwlgkeA4uPbaFjAeUC8H9b2PihBsorc0m+q5ZWZqnk0sU3p0Sv QbX5IqW4v0Kp+f7hIoMm6BmqtFr4ssZC5JNDW4ulSshbzjpqaDqHs7FWR8jYtA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none 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 4cYrZv1WBHzfsD; Sat, 27 Sep 2025 15:14:15 +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 58RFEF0r083674; Sat, 27 Sep 2025 15:14:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 58RFEF58083671; Sat, 27 Sep 2025 15:14:15 GMT (envelope-from git) Date: Sat, 27 Sep 2025 15:14:15 GMT Message-Id: <202509271514.58RFEF58083671@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: ac91312f28a9 - stable/14 - Move print_bits to ifconfig.c and make available to other src files. 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: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-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/14 X-Git-Reftype: branch X-Git-Commit: ac91312f28a93e9d1d2a21ddbde76d6920ce8ddc Auto-Submitted: auto-generated The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=ac91312f28a93e9d1d2a21ddbde76d6920ce8ddc commit ac91312f28a93e9d1d2a21ddbde76d6920ce8ddc Author: Gordon Tetlow AuthorDate: 2024-05-31 17:48:10 +0000 Commit: Zhenlei Huang CommitDate: 2025-09-27 15:11:40 +0000 Move print_bits to ifconfig.c and make available to other src files. Reviewed by: emaste Event: Kitchener-Waterloo Hackathon 202406 Differential Revision: https://reviews.freebsd.org/D45441 (cherry picked from commit c3e9423743d91ae5b5865602a905900a1855055e) --- sbin/ifconfig/ifconfig.c | 23 +++++++++++++++++++++++ sbin/ifconfig/ifconfig.h | 2 ++ sbin/ifconfig/ifconfig_netlink.c | 23 ----------------------- 3 files changed, 25 insertions(+), 23 deletions(-) diff --git a/sbin/ifconfig/ifconfig.c b/sbin/ifconfig/ifconfig.c index 2449d6ca484e..3f3569efbe66 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1887,6 +1887,29 @@ Perror(const char *cmd) Perrorc(cmd, errno); } +void +print_bits(const char *btype, uint32_t *v, const int v_count, + const char **names, const int n_count) +{ + int num = 0; + + for (int i = 0; i < v_count * 32; i++) { + bool is_set = v[i / 32] & (1U << (i % 32)); + if (is_set) { + if (num++ == 0) + printf("<"); + if (num != 1) + printf(","); + if (i < n_count) + printf("%s", names[i]); + else + printf("%s_%d", btype, i); + } + } + if (num > 0) + printf(">"); +} + /* * Print a value a la the %b format of the kernel's printf */ diff --git a/sbin/ifconfig/ifconfig.h b/sbin/ifconfig/ifconfig.h index 264e7b82a40e..1ea6c29e4ddb 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -268,6 +268,8 @@ void setifcap(if_ctx *ctx, const char *, int value); void setifcapnv(if_ctx *ctx, const char *vname, const char *arg); void Perror(const char *cmd); +void print_bits(const char *btype, uint32_t *v, const int v_count, + const char **names, const int n_count); void printb(const char *s, unsigned value, const char *bits); void ifmaybeload(struct ifconfig_args *args, const char *name); diff --git a/sbin/ifconfig/ifconfig_netlink.c b/sbin/ifconfig/ifconfig_netlink.c index 11b3595dafe6..0ec63e3a0b99 100644 --- a/sbin/ifconfig/ifconfig_netlink.c +++ b/sbin/ifconfig/ifconfig_netlink.c @@ -81,29 +81,6 @@ static const char *IFFBITS[] = { "LOWER_UP", /* 24:0x1000000 IFF_NETLINK_1*/ }; -static void -print_bits(const char *btype, uint32_t *v, const int v_count, - const char **names, const int n_count) -{ - int num = 0; - - for (int i = 0; i < v_count * 32; i++) { - bool is_set = v[i / 32] & (1U << (i % 32)); - if (is_set) { - if (num++ == 0) - printf("<"); - if (num != 1) - printf(","); - if (i < n_count) - printf("%s", names[i]); - else - printf("%s_%d", btype, i); - } - } - if (num > 0) - printf(">"); -} - static void nl_init_socket(struct snl_state *ss) {