Skip to contentSkip to conversation

perf list: Esacpe \r in json output

PATCH Applied Ian Rogers 2 participants 2 messages Apr 10, 2024 – Apr 12, 2024 perf events

lore
Share & tools
lore

Ian Rogers

author reviewer
#0 lore raw

PATCH 1/1 perf list: Esacpe \r in json output

Events like for sapphirerapids have \r in the uncore descriptions. The non-escaped versions of this fail json validation the the perf list test.

---
 tools/perf/builtin-list.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-list.c +3 -0
index 02bf608d585e..9333cc64c2ce 100644
@@ -313,6 +313,9 @@ static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ..
 					case '\n':
 						strbuf_addstr(buf, "\\n");
 						break;
+					case '\r':
+						strbuf_addstr(buf, "\\r");
+						break;
 					case '\\':
 						fallthrough;
 					case '\"':
Signature · 1 line
2.44.0.478.gd926399ef9-goog
maintainer Applied
#1 lore raw
Quoted 3 lines · Ian Rogers

Events like for sapphirerapids have \r in the uncore descriptions. The non-escaped versions of this fail json validation the the perf list test.

Thanks, applied to perf-tools-next,

- Arnaldo

Quoted 21 lines
---
 tools/perf/builtin-list.c | 3 +++
 1 file changed, 3 insertions(+)
tools/perf/builtin-list.c +3 -0
index 02bf608d585e..9333cc64c2ce 100644
@@ -313,6 +313,9 @@ static void fix_escape_fprintf(FILE *fp, struct strbuf *buf, const char *fmt, ..
 					case '\n':
 						strbuf_addstr(buf, "\\n");
 						break;
+					case '\r':
+						strbuf_addstr(buf, "\\r");
+						break;
 					case '\\':
 						fallthrough;
 					case '\"':
Signature · 1 line
2.44.0.478.gd926399ef9-goog