Skip to contentSkip to conversation

netlink: fix missing headers in text output

PATCH Arinzon, David 1 participant 1 message Jul 15, 2025 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Arinzon, David

author Reviewed-by David Arinzon
#1 lore raw
In reply to a message not in the archive
Quoted 58 lines

The commit under fixes added a NULL-check which prevents us from printing text headers. Conversions to add JSON support often use:

   print_string(PRINT_FP, NULL, "some text:\n", NULL);

to print in plain text mode.

Correct output:

   Channel parameters for vpn0:
   Pre-set maximums:
   RX:           n/a
   TX:           n/a
   Other:                n/a
   Combined:     1
   Current hardware settings:
   RX:           n/a
   TX:           n/a
   Other:                n/a
   Combined:     0

With the buggy patch:

   Channel parameters for vpn0:
   RX:           n/a
   TX:           n/a
   Other:                n/a
   Combined:     1
   RX:           n/a
   TX:           n/a
   Other:                n/a
   Combined:     0

Fixes fd328ccb3cc0 ("json_print: add NULL check before jsonw_string_field() in print_string()")

---
  json_print.c | 3 ++-

  1 file changed, 2 insertions(+), 1 deletion(-)
json_print.c +2 -1
index 4f61640392cf..e07c651f477b 100644
@@ -143,10 +143,11 @@ void print_string(enum output_type type,
          } else if (_IS_FP_CONTEXT(type)) {
                  if (value)
                          fprintf(stdout, fmt, value);
+               else
+                       fprintf(stdout, fmt);
          }
   }
 
-
   /*
    * value's type is bool. When using this function in FP context you can't pass
    * a value to it, you will need to use "is_json_context()" to have different
Signature · 1 line
2.50.1

Thanks for identifying the issue and proposing the fix.