tools lib traceevent: Take care of return value of asprintf
authorHe Zhe <zhe.he@windriver.com>
Thu, 20 Feb 2020 01:58:50 +0000 (09:58 +0800)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 18 Apr 2020 12:05:00 +0000 (09:05 -0300)
commitf8ff18be1f5c6ba1c2befb043bea6e7eaf9f8987
treeb31525929f466d4065a7e4628af5411d39be37aa
parentbec49a9e05db3dbdca696fa07c62c52638fb6371
tools lib traceevent: Take care of return value of asprintf

According to the API, if memory allocation wasn't possible, or some
other error occurs, asprintf will return -1, and the contents of strp
below are undefined.

  int asprintf(char **strp, const char *fmt, ...);

This patch takes care of return value of asprintf to make it less error
prone and prevent the following build warning.

  ignoring return value of ‘asprintf’, declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: He Zhe <zhe.he@windriver.com>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Cc: Tzvetomir Stoyanov <tstoyanov@vmware.com>
Cc: hewenliang4@huawei.com
Link: http://lore.kernel.org/lkml/1582163930-233692-1-git-send-email-zhe.he@windriver.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/lib/traceevent/parse-filter.c