aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIshan Agrawal <iagrawal9990@gmail.com>2026-08-08 06:40:20 +0000
committerKristof Provost <kp@FreeBSD.org>2026-08-10 14:33:32 +0000
commit2ef4baaffce0ab71491085e68fefc92eff8e715c (patch)
tree17563612ab265cc9d397d8700b9d167731149f8b
parent15c0c9df3a4af27176d8bbefcd21b68e2a952835 (diff)
libsysdecode: avoid extra commas for undecoded netlink attributes
Signed-off-by: Ishan Agrawal <iagrawal9990@gmail.com> Sponsored-by: Google LLC (GSoC 2026) Reviewed by: kp
-rw-r--r--lib/libsysdecode/netlink.c11
1 files 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;
}