aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-02-11 12:31:39 +0200
committerYordan Karadzhov (VMware) <y.karadz@gmail.com>2021-02-16 10:25:14 +0200
commit0f6a0d523e8ae7b0962e2c0fee8cc1bc1eb6bcbc (patch)
treea3ec0d1bf1d21381d62e0471c430483620ad0074
parent6dde872d097c5ead6bcecf1d35905a63313b24cb (diff)
downloadkernel-shark-0f6a0d523e8ae7b0962e2c0fee8cc1bc1eb6bcbc.tar.gz
kernel-shark: Add get_stream_object()
In a previous patch we modified kshark_get_data_stream() to return NULL in the case when the kshark_data_stream object does not own a data processing interface. This was motivated by the idea that kshark_get_data_stream() is supposed to be used to access only successfully loaded data streams, which is not possible in the case when the data processing interface is not initialized. However, this creates a contradiction with the definition of the public method kshark_add_stream(). This method adds a stream without initializing its data processing interface. In this patch we add a static function that returns the Data stream object, regardless of the existence of the interface and we use this static function in all cases when the existence of the interface is not guaranteed. Link: https://lore.kernel.org/linux-trace-devel/20210211103205.418588-2-y.karadz@gmail.com Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
-rw-r--r--src/libkshark.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/libkshark.c b/src/libkshark.c
index a54fdd51..c57ca01f 100644
--- a/src/libkshark.c
+++ b/src/libkshark.c
@@ -361,6 +361,17 @@ kshark_get_data_stream(struct kshark_context *kshark_ctx, int sd)
return NULL;
}
+static struct kshark_data_stream *
+get_stream_object(struct kshark_context *kshark_ctx, int sd)
+{
+ if (sd >= 0 && sd <= kshark_ctx->stream_info.max_stream_id)
+ if (kshark_ctx->stream[sd] &&
+ kshark_is_valid_stream(kshark_ctx->stream[sd]))
+ return kshark_ctx->stream[sd];
+
+ return NULL;
+}
+
/**
* @brief Get the Data stream object corresponding to a given entry
*
@@ -443,7 +454,7 @@ int kshark_close(struct kshark_context *kshark_ctx, int sd)
struct kshark_data_stream *stream;
int ret;
- stream = kshark_get_data_stream(kshark_ctx, sd);
+ stream = get_stream_object(kshark_ctx, sd);
if (!stream)
return -EFAULT;
@@ -1182,7 +1193,7 @@ bool kshark_filter_is_set(struct kshark_context *kshark_ctx, int sd)
{
struct kshark_data_stream *stream;
- stream = kshark_get_data_stream(kshark_ctx, sd);
+ stream = get_stream_object(kshark_ctx, sd);
if (!stream)
return false;