From nobody Mon Jun 03 15:52:06 2024 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 4VtJBZ64Hwz5Mk4Q; Mon, 03 Jun 2024 15:52:06 +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 4VtJBZ5ZY4z40l2; Mon, 3 Jun 2024 15:52:06 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1717429926; 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=fS4+Hu3dL66RadJfbsqlCrLYh6T1nyWBhJehzjt5ZVk=; b=YHC33m/NMKPZwuCSWjGbrWf3zViUw21dpJ+lkOjXtmaic02jbB8fFcQOj3e5dNeb4Ixfe5 pASI5RBGwDR7zcluymGqcNAEPEouNdW8aULtybvpDgnQ+Ld5RLo6+xu7rlGoaGiyST4t1s T9wK1umPDrP81E2tfFt60KXSg7L6by7uzwNl3ISdWq2edsvo38n4dLgguoQ4SVrjwzXf28 0qdEzr0USZ4lKxRp5HL8kDWgQG9xxgBb/etkeq6opi8AMk74N5E2fH7Knc7ZleZ9UHa+p+ 1Z6tgXzQussu83xNcp/2F7bwbgSqNnlMmt/YJwbtetZ/mx1PvfVyw06/0Xy8mA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1717429926; a=rsa-sha256; cv=none; b=EsEcJB+MocLFpPk6eFSt1SzJ7c9jegFYN8O/vEU+WF9SRMnb6M3S0yXFRlAcg0JnNyf5nv no9wjJU+aDjgOmypnlnPWHVfZjvp9sYPUhGeM2eMg2Tdc7E7jZChAEn/LqppzgS2WMuUmy 4+dsx/NFJ8bXdvhN6mlhFvqTqk29E88CrUCmN7LPgAcpj2PbGdhlGnjFjP/fD2lH6Pg3Rp DnwnpKWzIkRZLyf9BPL4e1DxHPJ/1UBUJ/tO23lkVWqqS3jk/1H8DK5sUMOUxzDGgbk3hk 3/IOOB6yxW5r4b9OG41j1S0tJruklTk+nU5lc4XbMRLqDDqBKYuDXxrakeuoQw== 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=1717429926; 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=fS4+Hu3dL66RadJfbsqlCrLYh6T1nyWBhJehzjt5ZVk=; b=pfJWGKWEnHrFfOMs7DWhvzuDzsqUyq/j6+s6m42hI/GDhIWkVFxaTvk+67/aJ6cead2QT3 KysnldlKh4PAE3k+DkSMo4iKaS7wDZMMZI3WnpyZYYB+JSboVFT9ayKCpClMH0kNCTHM2B vGe4SzRZi1y4wobxsQpmV94FtmckKXYoXp8prpO93pclKbFUk1wFQmWrev64uEzhZ3Umni +gnax6QNwsh2a93Re9eZwwzjZRPJS0etw0UhvfTUsaJ+0NsA+UQWHvkyQyKKxUZmVoqVCQ XjEsSlngq5rKlasddEw0aTJjqZ2qCOMl4aAc9r2JaY4f3GWLMiCEXhfa9Zr9vw== 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 4VtJBZ4sZBzhSR; Mon, 3 Jun 2024 15:52:06 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 453Fq6sc008789; Mon, 3 Jun 2024 15:52:06 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 453Fq6dC008786; Mon, 3 Jun 2024 15:52:06 GMT (envelope-from git) Date: Mon, 3 Jun 2024 15:52:06 GMT Message-Id: <202406031552.453Fq6dC008786@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gordon Tetlow Subject: git: c3e9423743d9 - main - 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: gordon X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: c3e9423743d91ae5b5865602a905900a1855055e Auto-Submitted: auto-generated The branch main has been updated by gordon: URL: https://cgit.FreeBSD.org/src/commit/?id=c3e9423743d91ae5b5865602a905900a1855055e commit c3e9423743d91ae5b5865602a905900a1855055e Author: Gordon Tetlow AuthorDate: 2024-05-31 17:48:10 +0000 Commit: Gordon Tetlow CommitDate: 2024-06-03 15:48:35 +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 --- 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 a8bd5a0c89db..92543a281959 100644 --- a/sbin/ifconfig/ifconfig.c +++ b/sbin/ifconfig/ifconfig.c @@ -1877,6 +1877,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 76a5aeb718b1..555e7dbaca64 100644 --- a/sbin/ifconfig/ifconfig.h +++ b/sbin/ifconfig/ifconfig.h @@ -260,6 +260,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 8964b63caf7b..729d4ca56545 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) {