2011-03-16 07:57:29

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [tip:perf/core] perf probe: Clean up probe_point_lazy_walker() return value

On Tue, 2011-03-15 at 23:18 +0000, tip-bot for Ingo Molnar wrote:

> perf probe: Clean up probe_point_lazy_walker() return value

> --- a/tools/perf/util/probe-finder.c
> +++ b/tools/perf/util/probe-finder.c
> @@ -1328,7 +1328,7 @@ static int probe_point_lazy_walker(const char *fname, int lineno,
> * Continue if no error, because the lazy pattern will match
> * to other lines
> */
> - return ret < 0 ?: 0;
> + return ret < 0 ? ret : 0;
> }

It is a slight change in semantics though, the return value will now be
negative instead of 1. If its used as a boolean that's fine, but still.

I'd have changed it to:

return ret < 0;

Which is identical to the previous statement.


Subject: Re: [tip:perf/core] perf probe: Clean up probe_point_lazy_walker() return value

(2011/03/16 16:59), Peter Zijlstra wrote:
> On Tue, 2011-03-15 at 23:18 +0000, tip-bot for Ingo Molnar wrote:
>
>> perf probe: Clean up probe_point_lazy_walker() return value
>
>> --- a/tools/perf/util/probe-finder.c
>> +++ b/tools/perf/util/probe-finder.c
>> @@ -1328,7 +1328,7 @@ static int probe_point_lazy_walker(const char *fname, int lineno,
>> * Continue if no error, because the lazy pattern will match
>> * to other lines
>> */
>> - return ret < 0 ?: 0;
>> + return ret < 0 ? ret : 0;
>> }
>
> It is a slight change in semantics though, the return value will now be
> negative instead of 1. If its used as a boolean that's fine, but still.
>
> I'd have changed it to:
>
> return ret < 0;
>
> Which is identical to the previous statement.

Sorry this was my mistake, that statement actually aims to
what Ingo has done.

If probe_point_lazy_walker() returns non-zero value,
die_walk_lines() returns immediately, because a positive return
value means the handler finds line and wanna stop walking on
the lines, and a negative return value means some errors
occurred in the handler and must stop.

However, probe_point_lazy_walker() has to continue to walk,
because given lazy-pattern can match several lines. Thus, this
must return 0 if ret is a positive value, and return an error code
if ret is a negative value.

Thank you,


--
Masami HIRAMATSU
2nd Dept. Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: [email protected]

2011-03-16 14:16:46

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [tip:perf/core] perf probe: Clean up probe_point_lazy_walker() return value

Em Wed, Mar 16, 2011 at 08:59:17AM +0100, Peter Zijlstra escreveu:
> On Tue, 2011-03-15 at 23:18 +0000, tip-bot for Ingo Molnar wrote:
>
> > perf probe: Clean up probe_point_lazy_walker() return value
>
> > --- a/tools/perf/util/probe-finder.c
> > +++ b/tools/perf/util/probe-finder.c
> > @@ -1328,7 +1328,7 @@ static int probe_point_lazy_walker(const char *fname, int lineno,
> > * Continue if no error, because the lazy pattern will match
> > * to other lines
> > */
> > - return ret < 0 ?: 0;
> > + return ret < 0 ? ret : 0;
> > }
>
> It is a slight change in semantics though, the return value will now be
> negative instead of 1. If its used as a boolean that's fine, but still.
>
> I'd have changed it to:
>
> return ret < 0;
>
> Which is identical to the previous statement.

Looks similar to the problem fixed in:

fbee632d0ca9f4073a3fefb9a843eac8af036b0f

for another function, I bet the intent in both cases was to return ret,
i.e. the negative value.

- Arnaldo