* [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts
@ 2023-03-29 7:30 Manu Bretelle
2023-03-29 9:46 ` Quentin Monnet
2023-03-29 17:00 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Manu Bretelle @ 2023-03-29 7:30 UTC (permalink / raw)
To: chantr4, quentin, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf
This is essentially a backport of iproute2's
commit ed54f76484b5 ("json: fix backslash escape typo in jsonw_puts")
Also added the stdio.h include in json_writer.h to be able to compile
and run the json_writer test as used below).
Before this fix:
$ gcc -D notused -D TEST -I../../include -o json_writer json_writer.c
json_writer.h
$ ./json_writer
{
"Vyatta": {
"url": "http://vyatta.com",
"downloads": 2000000,
"stock": 8.16,
"ARGV": [],
"empty": [],
"NIL": {},
"my_null": null,
"special chars": [
"slash": "/",
"newline": "\n",
"tab": "\t",
"ff": "\f",
"quote": "\"",
"tick": "'",
"backslash": "\n"
]
}
}
After:
$ gcc -D notused -D TEST -I../../include -o json_writer json_writer.c
json_writer.h
$ ./json_writer
{
"Vyatta": {
"url": "http://vyatta.com",
"downloads": 2000000,
"stock": 8.16,
"ARGV": [],
"empty": [],
"NIL": {},
"my_null": null,
"special chars": [
"slash": "/",
"newline": "\n",
"tab": "\t",
"ff": "\f",
"quote": "\"",
"tick": "'",
"backslash": "\\"
]
}
}
Signed-off-by: Manu Bretelle <chantr4@gmail.com>
---
tools/bpf/bpftool/json_writer.c | 2 +-
tools/bpf/bpftool/json_writer.h | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/bpf/bpftool/json_writer.c b/tools/bpf/bpftool/json_writer.c
index bca5dd0a59e3..be379613d118 100644
--- a/tools/bpf/bpftool/json_writer.c
+++ b/tools/bpf/bpftool/json_writer.c
@@ -75,7 +75,7 @@ static void jsonw_puts(json_writer_t *self, const char *str)
fputs("\\b", self->out);
break;
case '\\':
- fputs("\\n", self->out);
+ fputs("\\\\", self->out);
break;
case '"':
fputs("\\\"", self->out);
diff --git a/tools/bpf/bpftool/json_writer.h b/tools/bpf/bpftool/json_writer.h
index 8ace65cdb92f..5aaffd3b837b 100644
--- a/tools/bpf/bpftool/json_writer.h
+++ b/tools/bpf/bpftool/json_writer.h
@@ -14,6 +14,7 @@
#include <stdbool.h>
#include <stdint.h>
#include <stdarg.h>
+#include <stdio.h>
#include <linux/compiler.h>
/* Opaque class structure */
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts
2023-03-29 7:30 [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts Manu Bretelle
@ 2023-03-29 9:46 ` Quentin Monnet
2023-03-29 17:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Quentin Monnet @ 2023-03-29 9:46 UTC (permalink / raw)
To: Manu Bretelle, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf
2023-03-29 00:30 UTC-0700 ~ Manu Bretelle <chantr4@gmail.com>
> This is essentially a backport of iproute2's
> commit ed54f76484b5 ("json: fix backslash escape typo in jsonw_puts")
>
> Also added the stdio.h include in json_writer.h to be able to compile
> and run the json_writer test as used below).
>
> Before this fix:
>
> $ gcc -D notused -D TEST -I../../include -o json_writer json_writer.c
> json_writer.h
> $ ./json_writer
> {
> "Vyatta": {
> "url": "http://vyatta.com",
> "downloads": 2000000,
> "stock": 8.16,
> "ARGV": [],
> "empty": [],
> "NIL": {},
> "my_null": null,
> "special chars": [
> "slash": "/",
> "newline": "\n",
> "tab": "\t",
> "ff": "\f",
> "quote": "\"",
> "tick": "'",
> "backslash": "\n"
> ]
> }
> }
>
> After:
>
> $ gcc -D notused -D TEST -I../../include -o json_writer json_writer.c
> json_writer.h
> $ ./json_writer
> {
> "Vyatta": {
> "url": "http://vyatta.com",
> "downloads": 2000000,
> "stock": 8.16,
> "ARGV": [],
> "empty": [],
> "NIL": {},
> "my_null": null,
> "special chars": [
> "slash": "/",
> "newline": "\n",
> "tab": "\t",
> "ff": "\f",
> "quote": "\"",
> "tick": "'",
> "backslash": "\\"
> ]
> }
> }
>
> Signed-off-by: Manu Bretelle <chantr4@gmail.com>
Reviewed-by: Quentin Monnet <quentin@isovalent.com>
Thank you!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts
2023-03-29 7:30 [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts Manu Bretelle
2023-03-29 9:46 ` Quentin Monnet
@ 2023-03-29 17:00 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-03-29 17:00 UTC (permalink / raw)
To: Manu Bretelle
Cc: quentin, ast, daniel, andrii, martin.lau, song, yhs,
john.fastabend, kpsingh, sdf, haoluo, jolsa, bpf
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Wed, 29 Mar 2023 00:30:02 -0700 you wrote:
> This is essentially a backport of iproute2's
> commit ed54f76484b5 ("json: fix backslash escape typo in jsonw_puts")
>
> Also added the stdio.h include in json_writer.h to be able to compile
> and run the json_writer test as used below).
>
> Before this fix:
>
> [...]
Here is the summary with links:
- tools: bpftool: json: fix backslash escape typo in jsonw_puts
https://git.kernel.org/bpf/bpf-next/c/d8d8b008629f
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-29 17:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-29 7:30 [PATCH] tools: bpftool: json: fix backslash escape typo in jsonw_puts Manu Bretelle
2023-03-29 9:46 ` Quentin Monnet
2023-03-29 17:00 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).