From 88bf638487e6c5f3268b06629c00ed77c8173844 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Wed, 1 Apr 2026 17:59:31 +0200 Subject: [PATCH] cpumf: Adapt to new JSON Lines text format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit util_fmt now provides support for JSON Lines text format. Adapt certain checks in the code and document the newly supported format in the man pages for lshwc and lspai accordingly. Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- cpumf/lshwc.c | 4 ++-- cpumf/man/lshwc.8 | 2 +- cpumf/man/lspai.8 | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cpumf/lshwc.c b/cpumf/lshwc.c index 6772aa5a..c8e9cb3e 100644 --- a/cpumf/lshwc.c +++ b/cpumf/lshwc.c @@ -700,7 +700,7 @@ static int do_it(char *s) if (output_format == FMT_CSV) flags |= FMT_NOMETA; - if (output_format == FMT_JSON || output_format == FMT_JSONSEQ) + if (util_fmt_is_json(output_format)) flags |= FMT_HANDLEINT; if (quote_all) flags |= FMT_QUOTEALL; @@ -708,7 +708,7 @@ static int do_it(char *s) mk_labels(); util_fmt_init(stdout, output_format, flags, 1); util_fmt_obj_start(FMT_DEFAULT, "lshwc"); - if (output_format == FMT_JSON || output_format == FMT_JSONSEQ) { + if (util_fmt_is_json(output_format)) { util_fmt_obj_start(FMT_ROW, "cpumcf info"); util_fmt_pair(FMT_PERSIST, "counter first", "%d", cfvn); util_fmt_pair(FMT_PERSIST, "counter second", "%d", csvn); diff --git a/cpumf/man/lshwc.8 b/cpumf/man/lshwc.8 index 6349d272..a0691a76 100644 --- a/cpumf/man/lshwc.8 +++ b/cpumf/man/lshwc.8 @@ -138,7 +138,7 @@ Apply quoting to every output element, regardless of content or format. .TP .BR \-f ", " \-\-format \fI\ FORMAT\fP Retrieve output in one of the following formats: -JSON, CSV, JSON-SEQ or PAIRS. +JSON, CSV, JSON-SEQ, JSONL or PAIRS. If no format is specified, the output defaults to CSV. . .SS JSON Output Structure diff --git a/cpumf/man/lspai.8 b/cpumf/man/lspai.8 index d636520a..b851cc2b 100644 --- a/cpumf/man/lspai.8 +++ b/cpumf/man/lspai.8 @@ -136,7 +136,7 @@ Default sort order is PAI counter name. .TP .BI \-\-format "\ FORMAT" Retrieve output in one of the following formats: -JSON, csv, json-seq or pairs. +JSON, csv, json-seq, jsonl or pairs. If no format is specified, the output defaults to a human-readable format. .