File: netlink-fix-missing-headers-in-text-output.patch

package info (click to toggle)
ethtool 1%3A6.15-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,996 kB
  • sloc: ansic: 66,004; sh: 97; makefile: 88; xml: 17
file content (64 lines) | stat: -rw-r--r-- 1,524 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
From: Jakub Kicinski <kuba@kernel.org>
Date: Sat, 12 Jul 2025 07:51:05 -0700
Subject: netlink: fix missing headers in text output
Origin: https://git.kernel.org/pub/scm/network/ethtool/ethtool.git/commit?id=b70c928661024cd07914feb49122275daab904ea

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()")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
---
 json_print.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/json_print.c b/json_print.c
index 4f61640392cf..e07c651f477b 100644
--- a/json_print.c
+++ b/json_print.c
@@ -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
-- 
2.50.1