Re: [PATCH v4 08/20] kernel-shark: Add stream interface for trace-cmd data

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

 





On 19.11.20 г. 3:11 ч., Steven Rostedt wrote:
On Wed, 18 Nov 2020 16:49:51 +0200
"Yordan Karadzhov (VMware)" <y.karadz@xxxxxxxxx> wrote:

+static char *tepdata_get_task(struct kshark_data_stream *stream,
+			      const struct kshark_entry *entry)
+{
+	struct kshark_generic_stream_interface *interface = stream->interface;
+	const char *task;
+	char *buffer;
+	int pid;
+
+	if (!interface)
+		return NULL;
+
+	pid = interface->get_pid(stream, entry);
+	task = tep_data_comm_from_pid(kshark_get_tep(stream), pid);


+	if (asprintf(&buffer, "%s", task)  <= 0)
+		return NULL;
+
+	return buffer;

That's a pretty fancy way to implement:

	return strdup(task ? : "(nil)");

  ;-)

If you wanted to show "(nil)" when task is NULL.

Otherwise, if you want to return NULL if task is NULL, then you could
simplify it further to just:

	return task ? strdup(task) : NULL;


I am taking this one for v5.

Thanks a lot!
Yordan


-- Steve


+}



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

  Powered by Linux