diff options
author | Yordan Karadzhov <ykaradzhov@vmware.com> | 2019-03-14 17:10:12 +0200 |
---|---|---|
committer | Steven Rostedt (VMware) <rostedt@goodmis.org> | 2019-03-22 15:14:11 -0400 |
commit | 29a20594a76e6fd947f01ff0efc13a6802693776 (patch) | |
tree | 29fef675b60ac26b7a90244a6f354bf417068291 | |
parent | 916bb75625f10fc6ea303ea4740629240b94660b (diff) | |
download | trace-cmd-29a20594a76e6fd947f01ff0efc13a6802693776.tar.gz |
kernel-shark: In collections, handle the case when the data is small
In particular, handle the case when the size of the data is smaller
than the required margin.
Link: http://lore.kernel.org/linux-trace-devel/20190314151012.905-13-ykaradzhov@vmware.com
Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com>
Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r-- | kernel-shark/src/libkshark-collection.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/kernel-shark/src/libkshark-collection.c b/kernel-shark/src/libkshark-collection.c index c70da1ef..02a014e5 100644 --- a/kernel-shark/src/libkshark-collection.c +++ b/kernel-shark/src/libkshark-collection.c @@ -71,7 +71,7 @@ static bool collection_add_entry(struct entry_list **list, static struct kshark_entry_collection * kshark_data_collection_alloc(struct kshark_context *kshark_ctx, struct kshark_entry **data, - size_t first, + ssize_t first, size_t n_rows, matching_condition_func cond, int val, @@ -81,9 +81,19 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx, struct kshark_entry *last_vis_entry = NULL; struct entry_list *col_list, *temp; size_t resume_count = 0, break_count = 0; - size_t i, j, end, last_added = 0; + size_t i, j, last_added = 0; + ssize_t end; bool good_data = false; + /* Create the collection. */ + col_ptr = calloc(1, sizeof(*col_ptr)); + if (!col_ptr) + goto fail; + + end = first + n_rows - margin; + if (first >= end) + return col_ptr; + col_list = malloc(sizeof(*col_list)); if (!col_list) goto fail; @@ -106,7 +116,6 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx, temp->type = COLLECTION_IGNORE; } - end = first + n_rows - margin; for (i = first + margin; i < end; ++i) { if (!cond(kshark_ctx, data[i], val)) { /* @@ -204,11 +213,6 @@ kshark_data_collection_alloc(struct kshark_context *kshark_ctx, */ assert(break_count == resume_count); - /* Create the collection. */ - col_ptr = malloc(sizeof(*col_ptr)); - if (!col_ptr) - goto fail; - col_ptr->next = NULL; col_ptr->resume_points = calloc(resume_count, |