On 19.11.20 г. 3:29 ч., Steven Rostedt wrote:
On Wed, 18 Nov 2020 16:49:53 +0200 "Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:@@ -327,6 +302,34 @@ int kshark_add_stream(struct kshark_context *kshark_ctx) return stream->stream_id; }+/**+ * @brief Use an existing Trace data stream to open and prepare for reading + * a trace data file specified by "file". + * + * @param stream: Input location for a Trace data stream pointer. + * @param file: The file to load. + * + * @returns Zero on success or a negative error code in the case of an errno. + */ +int kshark_stream_open(struct kshark_data_stream *stream, const char *file) +{ + struct kshark_context *kshark_ctx = NULL; + + if (!stream || !kshark_instance(&kshark_ctx)) + return -EFAULT; + + stream->file = strdup(file);Should probably check the result of the allocation of file.+ + if (kshark_tep_check_data(file)) { + kshark_set_data_format(stream->data_format, + TEP_DATA_FORMAT_IDENTIFIER); + + return kshark_tep_init_input(stream, file);Why pass in file, if it is going to equal stream->file? Couldn't kshark_tep_init_input() just use whatever is in the stream->file?
Will change both in v5. Thanks a lot! Y.
-- Steve+ } + + return -ENODATA; +} + /** * @brief Remove Data stream. *