Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Feb 2025 19:53:02 GMT
From:      Gleb Smirnoff <glebius@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: d2e6eb604656 - main - genl: fix printing of a command with zero capabilities
Message-ID:  <202502041953.514Jr2fS086393@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by glebius:

URL: https://cgit.FreeBSD.org/src/commit/?id=d2e6eb6046560a848cf5627b4353a6fef1421ed4

commit d2e6eb6046560a848cf5627b4353a6fef1421ed4
Author:     Gleb Smirnoff <glebius@FreeBSD.org>
AuthorDate: 2025-02-04 19:52:35 +0000
Commit:     Gleb Smirnoff <glebius@FreeBSD.org>
CommitDate: 2025-02-04 19:52:35 +0000

    genl: fix printing of a command with zero capabilities
---
 usr.bin/genl/genl.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/usr.bin/genl/genl.c b/usr.bin/genl/genl.c
index 51d2dfaa6364..4d2c252dab98 100644
--- a/usr.bin/genl/genl.c
+++ b/usr.bin/genl/genl.c
@@ -214,13 +214,19 @@ dump_operations(struct genl_ctrl_ops *ops)
 		return;
 	printf("\tsupported operations: \n");
 	for (uint32_t i = 0; i < ops->num_ops; i++) {
-		printf("\t  - ID: %#02x, Capabilities: %#02x (",
+		bool p = true;
+
+		printf("\t  - ID: %#02x, Capabilities: %#02x",
 		    ops->ops[i]->id,
 		    ops->ops[i]->flags);
 		for (size_t j = 0; j < nitems(op_caps); j++)
-			if ((ops->ops[i]->flags & op_caps[j].flag) == op_caps[j].flag)
-				printf("%s; ", op_caps[j].str);
-		printf("\b\b)\n");
+			if ((ops->ops[i]->flags & op_caps[j].flag) ==
+			    op_caps[j].flag) {
+				printf("%s%s", p ? " (" : "; ",
+				    op_caps[j].str);
+				p = false;
+			}
+		printf("%s\n", p ? "" : ")");
 	}
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202502041953.514Jr2fS086393>