diff options
author | Steven Rostedt (Red Hat) <rostedt@goodmis.org> | 2016-07-11 13:00:56 -0400 |
---|---|---|
committer | Steven Rostedt <rostedt@goodmis.org> | 2016-07-11 13:00:56 -0400 |
commit | 6f79497e85dd7924365633b479b00ad1116a03d5 (patch) | |
tree | 28960a6f74cb1e98c0f6ab1af53ef76a44bdcecf | |
parent | 496c5d9ce71e8648af4be7bf0912f86f1ea4f19e (diff) | |
download | trace-cmd-6f79497e85dd7924365633b479b00ad1116a03d5.tar.gz |
trace-cmd: Consolidate tracecmd_{read,peak}_next_data()
Now that there's a tracecmd_peak_next_data() that is a subset of the
functionality of tracecmd_read_next_data(), have tracecmd_read_next_data()
call tracecmd_peak_next_data() and remove the duplicate code.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r-- | trace-input.c | 31 |
1 files changed, 7 insertions, 24 deletions
diff --git a/trace-input.c b/trace-input.c index e8253288..894cc945 100644 --- a/trace-input.c +++ b/trace-input.c @@ -1756,34 +1756,17 @@ tracecmd_read_data(struct tracecmd_input *handle, int cpu) struct pevent_record * tracecmd_read_next_data(struct tracecmd_input *handle, int *rec_cpu) { - unsigned long long ts; struct pevent_record *record; - int first_record = 1; - int next; - int cpu; - - if (rec_cpu) - *rec_cpu = -1; - - next = -1; - ts = 0; + int next_cpu; - for (cpu = 0; cpu < handle->cpus; cpu++) { - record = tracecmd_peek_data(handle, cpu); - if (record && (first_record || record->ts < ts)) { - ts = record->ts; - next = cpu; - first_record = 0; - } - } + record = tracecmd_peek_next_data(handle, &next_cpu); + if (!record) + return NULL; - if (next >= 0) { - if (rec_cpu) - *rec_cpu = next; - return tracecmd_read_data(handle, next); - } + if (rec_cpu) + *rec_cpu = next_cpu; - return NULL; + return tracecmd_read_data(handle, next_cpu); } /** |