lkml.org 
[lkml]   [2020]   [Jul]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] libsubcmd: Fix OPT_CALLBACK_SET()
From
Date
Hi Arnaldo,

Can you please consider this trivial fix.

Ravi

On 6/19/20 7:04 PM, Ravi Bangoria wrote:
> Any option macro with _SET suffix should set opt->set variable which
> is not happening for OPT_CALLBACK_SET(). This is causing issues with
> perf record --switch-output-event. Fix that.
>
> Before:
> # ./perf record --overwrite -e sched:*switch,syscalls:sys_enter_mmap \
> --switch-output-event syscalls:sys_enter_mmap
> ^C[ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.297 MB perf.data (657 samples) ]
>
> After:
>
> $ ./perf record --overwrite -e sched:*switch,syscalls:sys_enter_mmap \
> --switch-output-event syscalls:sys_enter_mmap
> [ perf record: dump data: Woken up 1 times ]
> [ perf record: Dump perf.data.2020061918144542 ]
> [ perf record: dump data: Woken up 1 times ]
> [ perf record: Dump perf.data.2020061918144608 ]
> [ perf record: dump data: Woken up 1 times ]
> [ perf record: Dump perf.data.2020061918144660 ]
> ^C[ perf record: dump data: Woken up 1 times ]
> [ perf record: Dump perf.data.2020061918144784 ]
> [ perf record: Woken up 0 times to write data ]
> [ perf record: Dump perf.data.2020061918144803 ]
> [ perf record: Captured and wrote 0.419 MB perf.data.<timestamp> ]
>
> Fixes: 636eb4d001b1 ("libsubcmd: Introduce OPT_CALLBACK_SET()")
> Signed-off-by: Ravi Bangoria <ravi.bangoria@linux.ibm.com>
> ---
> tools/lib/subcmd/parse-options.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/lib/subcmd/parse-options.c b/tools/lib/subcmd/parse-options.c
> index dbb9efbf718a..39ebf6192016 100644
> --- a/tools/lib/subcmd/parse-options.c
> +++ b/tools/lib/subcmd/parse-options.c
> @@ -237,6 +237,9 @@ static int get_value(struct parse_opt_ctx_t *p,
> return err;
>
> case OPTION_CALLBACK:
> + if (opt->set)
> + *(bool *)opt->set = true;
> +
> if (unset)
> return (*opt->callback)(opt, NULL, 1) ? (-1) : 0;
> if (opt->flags & PARSE_OPT_NOARG)
>

\
 
 \ /
  Last update: 2020-07-17 05:43    [W:0.179 / U:0.772 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site