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+}