From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933479Ab3LDUOE (ORCPT ); Wed, 4 Dec 2013 15:14:04 -0500 Received: from merlin.infradead.org ([205.233.59.134]:59892 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933475Ab3LDUNw (ORCPT ); Wed, 4 Dec 2013 15:13:52 -0500 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Jiri Olsa , Corey Ashford , David Ahern , Frederic Weisbecker , Ingo Molnar , Namhyung Kim , Paul Mackerras , Peter Zijlstra , Steven Rostedt , Arnaldo Carvalho de Melo Subject: [PATCH 33/38] tools lib traceevent: Remove malloc_or_die from event-plugin.c Date: Wed, 4 Dec 2013 17:06:57 -0300 Message-Id: <1386187622-2928-34-git-send-email-acme@infradead.org> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1386187622-2928-1-git-send-email-acme@infradead.org> References: <1386187622-2928-1-git-send-email-acme@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by merlin.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jiri Olsa Removing malloc_or_die calls from event-plugin.c, replacing them with standard malloc and error path. Suggested-by: Namhyung Kim Signed-off-by: Jiri Olsa Acked-by: Steven Rostedt Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Ingo Molnar Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Steven Rostedt Link: http://lkml.kernel.org/r/1386076182-14484-23-git-send-email-jolsa@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/lib/traceevent/event-plugin.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/lib/traceevent/event-plugin.c b/tools/lib/traceevent/event-plugin.c index d272d87aa7d4..125f5676bcb5 100644 --- a/tools/lib/traceevent/event-plugin.c +++ b/tools/lib/traceevent/event-plugin.c @@ -47,7 +47,11 @@ load_plugin(struct pevent *pevent, const char *path, char *plugin; void *handle; - plugin = malloc_or_die(strlen(path) + strlen(file) + 2); + plugin = malloc(strlen(path) + strlen(file) + 2); + if (!plugin) { + warning("could not allocate plugin memory\n"); + return; + } strcpy(plugin, path); strcat(plugin, "/"); @@ -71,7 +75,12 @@ load_plugin(struct pevent *pevent, const char *path, goto out_free; } - list = malloc_or_die(sizeof(*list)); + list = malloc(sizeof(*list)); + if (!list) { + warning("could not allocate plugin memory\n"); + goto out_free; + } + list->next = *plugin_list; list->handle = handle; list->name = plugin; @@ -163,7 +172,11 @@ load_plugins(struct pevent *pevent, const char *suffix, if (!home) return; - path = malloc_or_die(strlen(home) + strlen(LOCAL_PLUGIN_DIR) + 2); + path = malloc(strlen(home) + strlen(LOCAL_PLUGIN_DIR) + 2); + if (!path) { + warning("could not allocate plugin memory\n"); + return; + } strcpy(path, home); strcat(path, "/"); -- 1.8.1.4