diff options
author | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-06-15 13:11:35 -0400 |
---|---|---|
committer | Steven Rostedt (Google) <rostedt@goodmis.org> | 2023-07-05 20:27:35 -0400 |
commit | ac643dee477a9c9933bf8b3c22c9a76771bd137a (patch) | |
tree | b53ff656abade4889cce6bafe877be08ddb4158a | |
parent | da7def56e25d49b338ae2586e0df48f3b6fa0123 (diff) | |
download | trace-cmd-ac643dee477a9c9933bf8b3c22c9a76771bd137a.tar.gz |
trace-cmd library: Have callbacks exit out of the iterator
In the man page for tracecmd_iterate_events() it states that if the
callback() returns anything other than zero, it will exit the iterator.
But this is not true. It only exits if the callback returns less than
zero. This is a bug as the code should do what the man page states. Have
it exit the loop if the callback returns non zero.
Link: https://lore.kernel.org/linux-trace-devel/20230615131135.123e38af@gandalf.local.home
Fixes: 2cb6cc2f4e556 ("tracecmd library: Add tracecmd_iterate_events()")
Fixes: b37903ae5fb53 ("tracecmd library: Add tracecmd_iterate_events_multi()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
-rw-r--r-- | lib/trace-cmd/trace-input.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c index 145c02ee..51420c13 100644 --- a/lib/trace-cmd/trace-input.c +++ b/lib/trace-cmd/trace-input.c @@ -2816,7 +2816,7 @@ int tracecmd_iterate_events(struct tracecmd_input *handle, records[next_cpu] = tracecmd_peek_data(handle, next_cpu); tracecmd_free_record(record); } - } while (next_cpu >= 0 && ret >= 0); + } while (next_cpu >= 0 && ret == 0); /* Need to unlock and free the records */ for (cpu = 0; cpu < handle->max_cpu; cpu++) { @@ -2912,7 +2912,7 @@ int tracecmd_iterate_events_multi(struct tracecmd_input **handles, records[next_cpu].record = tracecmd_peek_data(handle, cpu); } - } while (next_cpu >= 0 && ret >= 0); + } while (next_cpu >= 0 && ret == 0); /* Unlock and free the records */ for (cpu = 0; cpu < all_cpus; cpu++) { |