git: 2ef4baaffce0 - main - libsysdecode: avoid extra commas for undecoded netlink attributes

Kristof Provost <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a79e16d.24240.518d20ec__45223.0520242424$1786372520$gmane$org@gitrepo.freebsd.org>
The branch main has been updated by kp:

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

commit 2ef4baaffce0ab71491085e68fefc92eff8e715c
Author:     Ishan Agrawal <[email protected]>
AuthorDate: 2026-08-08 06:40:20 +0000
Commit:     Kristof Provost <[email protected]>
CommitDate: 2026-08-10 14:33:32 +0000

    libsysdecode: avoid extra commas for undecoded netlink attributes
    
    Signed-off-by:  Ishan Agrawal <[email protected]>
    Sponsored-by:   Google LLC (GSoC 2026)
    Reviewed by:    kp
---
 lib/libsysdecode/netlink.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/lib/libsysdecode/netlink.c b/lib/libsysdecode/netlink.c
index 56b5671b129d..2785b23cb98b 100644
--- a/lib/libsysdecode/netlink.c
+++ b/lib/libsysdecode/netlink.c
@@ -256,13 +256,14 @@ nl_decode_attrs_raw(FILE *fp, const struct nlattr *nla_head, size_t len,
 	fprintf(fp, "{");
 
 	NLA_FOREACH_CONST(nla, nla_head, len) {
-		if (!first)
-			fprintf(fp, ",");
-
 		s = search_decoders(ps, pslen, nla->nla_type & NLA_TYPE_MASK);
-		if (s != NULL && s->cb != NULL)
-			s->cb(fp, nla, s->attr_name, s->args);
 
+		if (s != NULL && s->cb != NULL) {
+			if (!first)
+				fprintf(fp, ",");
+
+			s->cb(fp, nla, s->attr_name, s->args);
+		}
 		first = false;
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.