Skip to contentSkip to conversation

devlink: fix json binary printout of arrays

PATCH In review Jiri Pirko 1 participant 2 messages Oct 9, 2019 – Oct 10, 2019

Subsystems (2)
lore
Share & tools
lore

Jiri Pirko

author
#0 lore raw

PATCH 1/1 devlink: fix json binary printout of arrays

From: Jiri Pirko <[email protected]>

The binary is printed out into json as an array of byte values. Add missing (removed) start and end array json calls.

Fixes f359942a25d3 ("devlink: Remove enclosing array brackets binary print with json format")
---
 devlink/devlink.c | 4 ++++
 1 file changed, 4 insertions(+)
devlink/devlink.c +4 -0
index 51aba6e200cd..8fc1f3b8b35a 100644
@@ -1930,6 +1930,8 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
 {
 	int i = 0;
 
+	if (dl->json_output)
+		jsonw_start_array(dl->jw);
 	while (i < len) {
 		if (dl->json_output)
 			jsonw_printf(dl->jw, "%d", data[i]);
@@ -1941,6 +1943,8 @@ static void pr_out_binary_value(struct dl *dl, uint8_t *data, uint32_t len)
 	}
 	if (!dl->json_output && !is_binary_eol(i))
 		__pr_out_newline();
+	if (dl->json_output)
+		jsonw_end_array(dl->jw);
 }
 
 static void pr_out_str_value(struct dl *dl, const char *value)
Signature · 1 line
2.21.0
author
#1 lore raw
Quoted 7 lines · Wed, Oct 09, 2019 at 10:32:32AM CEST, [email protected] wrote:

From: Jiri Pirko <[email protected]>

The binary is printed out into json as an array of byte values. Add missing (removed) start and end array json calls.

Fixes f359942a25d3 ("devlink: Remove enclosing array brackets binary print with json format")

Please scratch this patch.