diff mbox series

trace-cmd library: Have callbacks exit out of the iterator

Message ID 20230615131135.123e38af@gandalf.local.home (mailing list archive)
State Accepted
Commit ac643dee477a9c9933bf8b3c22c9a76771bd137a
Headers show
Series trace-cmd library: Have callbacks exit out of the iterator | expand

Commit Message

Steven Rostedt June 15, 2023, 5:11 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

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.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index 145c02eeb718..51420c13c750 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++) {