Re: [PATCH v4 10/20] kernel-shark: Start using data streams

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

 





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.
   *



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

  Powered by Linux