Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

perf list: Fix the --no-desc option

Currently, the --no-desc option in perf list isn't functioning as
intended.

This issue arises from the overwriting of struct option->desc with the
opposite value of struct option->long_desc. Consequently, whatever
parse_options() returns at struct option->desc gets overridden later,
rendering the --desc or --no-desc arguments ineffective.

To resolve this, set ->desc as true by default and allow parse_options()
to adjust it accordingly. This adjustment will fix the --no-desc
option while preserving the functionality of the other parameters.

Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Cc: leit@meta.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240517141427.1905691-1-leitao@debian.org

authored by

Breno Leitao and committed by
Namhyung Kim
265b7115 cbd446b4

+10 -13
+10 -13
tools/perf/builtin-list.c
··· 162 162 } else 163 163 fputc('\n', fp); 164 164 165 - if (desc && print_state->desc) { 165 + if (long_desc && print_state->long_desc) { 166 + fprintf(fp, "%*s", 8, "["); 167 + wordwrap(fp, long_desc, 8, pager_get_columns(), 0); 168 + fprintf(fp, "]\n"); 169 + } else if (desc && print_state->desc) { 166 170 char *desc_with_unit = NULL; 167 171 int desc_len = -1; 168 172 ··· 181 177 wordwrap(fp, desc_len > 0 ? desc_with_unit : desc, 8, pager_get_columns(), 0); 182 178 fprintf(fp, "]\n"); 183 179 free(desc_with_unit); 184 - } 185 - long_desc = long_desc ?: desc; 186 - if (long_desc && print_state->long_desc) { 187 - fprintf(fp, "%*s", 8, "["); 188 - wordwrap(fp, long_desc, 8, pager_get_columns(), 0); 189 - fprintf(fp, "]\n"); 190 180 } 191 181 192 182 if (print_state->detailed && encoding_desc) { ··· 254 256 } 255 257 fprintf(fp, " %s\n", name); 256 258 257 - if (desc && print_state->desc) { 258 - fprintf(fp, "%*s", 8, "["); 259 - wordwrap(fp, desc, 8, pager_get_columns(), 0); 260 - fprintf(fp, "]\n"); 261 - } 262 259 if (long_desc && print_state->long_desc) { 263 260 fprintf(fp, "%*s", 8, "["); 264 261 wordwrap(fp, long_desc, 8, pager_get_columns(), 0); 262 + fprintf(fp, "]\n"); 263 + } else if (desc && print_state->desc) { 264 + fprintf(fp, "%*s", 8, "["); 265 + wordwrap(fp, desc, 8, pager_get_columns(), 0); 265 266 fprintf(fp, "]\n"); 266 267 } 267 268 if (expr && print_state->detailed) { ··· 504 507 int i, ret = 0; 505 508 struct print_state default_ps = { 506 509 .fp = stdout, 510 + .desc = true, 507 511 }; 508 512 struct print_state json_ps = { 509 513 .fp = stdout, ··· 577 579 }; 578 580 ps = &json_ps; 579 581 } else { 580 - default_ps.desc = !default_ps.long_desc; 581 582 default_ps.last_topic = strdup(""); 582 583 assert(default_ps.last_topic); 583 584 default_ps.visited_metrics = strlist__new(NULL, NULL);