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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Steven Rostedt (Google)" <rostedt@xxxxxxxxxxx>

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@xxxxxxxxxxx>
---
 lib/trace-cmd/trace-input.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

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++) {
-- 
2.39.2




[Index of Archives]     [Linux USB Development]     [Linux USB Development]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux