From: Guillaume Nault Date: Fri, 8 Nov 2019 17:00:18 +0000 (+0100) Subject: ipnetns: don't print unassigned nsid in json export X-Git-Tag: v5.5.0~57^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c9b69276c76e44234e62d3e1f678d25172a03f4;p=thirdparty%2Fiproute2.git ipnetns: don't print unassigned nsid in json export Don't output the nsid and current-nsid json keys if they're not set. Otherwise a parser would have to special case the "not-assigned" string. Signed-off-by: Guillaume Nault Signed-off-by: David Ahern --- diff --git a/ip/ipnetns.c b/ip/ipnetns.c index 355455dbc..cb8c0019f 100644 --- a/ip/ipnetns.c +++ b/ip/ipnetns.c @@ -329,15 +329,15 @@ int print_nsid(struct nlmsghdr *n, void *arg) nsid = rta_getattr_s32(tb[NETNSA_NSID]); if (nsid < 0) - print_string(PRINT_ANY, "nsid", "nsid %s ", "not-assigned"); + print_string(PRINT_FP, NULL, "nsid unassigned ", NULL); else print_int(PRINT_ANY, "nsid", "nsid %d ", nsid); if (tb[NETNSA_CURRENT_NSID]) { current = rta_getattr_s32(tb[NETNSA_CURRENT_NSID]); if (current < 0) - print_string(PRINT_ANY, "current-nsid", - "current-nsid %s ", "not-assigned"); + print_string(PRINT_FP, NULL, + "current-nsid unassigned ", NULL); else print_int(PRINT_ANY, "current-nsid", "current-nsid %d ", current);