lkml.org 
[lkml]   [2017]   [Sep]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 3/4] Add the fp_selection_helper function to set the file pointer for the related functions
Em Fri, Sep 22, 2017 at 11:03:27AM +0200, Jiri Olsa escreveu:
> On Mon, Sep 18, 2017 at 01:55:21PM +0800, yuzhoujian wrote:
> > Signed-off-by: yuzhoujian <yuzhoujian@didichuxing.com>
> > ---
> > tools/perf/builtin-script.c | 24 ++++++++++++++++--------
> > 1 file changed, 16 insertions(+), 8 deletions(-)
> >
> > diff --git a/tools/perf/builtin-script.c b/tools/perf/builtin-script.c
> > index f709f6f..89bab68 100644
> > --- a/tools/perf/builtin-script.c
> > +++ b/tools/perf/builtin-script.c
> > @@ -1527,6 +1527,13 @@ static int cleanup_scripting(void)
> > return scripting_ops ? scripting_ops->stop_script() : 0;
> > }
> >
> > +static FILE *fp_selection_helper(bool per_event_dump)
> > +{
> > + if (per_event_dump == false)
> > + return stdout;
> > + else
> > + return per_event_dump_file;
>
> when's the per_event_dump_file ever set?

And my first reaction with this "helper" was: what is this needed for?!?
Why not have a local variable in the function where the whole chain is
called from and there set the output doing this 'perf_event_dump' test
_just once_.

Also, using 'per_event_dump == false' for a boolean variable is valid,
but utterly uncommon and unnecessary, why not:

FILE *fp = per_event_dump ? per_event_dump_file : stdout;

then use fp to pass to the initial function, etc?

- Arnaldo

\
 
 \ /
  Last update: 2017-09-22 16:27    [W:0.063 / U:0.732 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site