tools lib traceevent: Replace malloc_or_die to plain malloc in alloc_event()
PATCH 1/1 tools lib traceevent: Replace malloc_or_die to plain malloc in alloc_event()
From: Namhyung Kim <[email protected]>
Because the only caller of the alloc_event() (pevent_parse_event) checks return value properly, it can be changed to use plain malloc.
--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
@@ -621,7 +621,9 @@ static struct event_format *alloc_event(void) {struct event_format *event; - event =malloc_or_die (sizeof (*event)); + event =malloc (sizeof (*event)); +if (!event) +return NULL ;memset (event,0 ,sizeof (*event));return event;
Signature · 1 line
1.7.10.2
Hi, Steve
Could you take a look at this too?
Quoted 28 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Because the only caller of the
alloc_event()(pevent_parse_event) checks return value properly, it can be changed to use plain malloc.Cc Frederic Weisbecker <[email protected]>Cc Steven Rostedt <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/traceevent/event-parse.c +3
-1@@ -621,7 +621,9 @@ static struct event_format *alloc_event(void) {struct event_format *event; - event =malloc_or_die (sizeof (*event)); + event =malloc (sizeof (*event)); +if (!event) +return NULL ;memset (event,0 ,sizeof (*event));return event;
Quoted 18 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Because the only caller of the
alloc_event()(pevent_parse_event) checks return value properly, it can be changed to use plain malloc.Cc Frederic Weisbecker <[email protected]>Cc Steven Rostedt <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/traceevent/event-parse.c +0
-0
tools/lib/traceevent/event-parse.c static struct event_format *alloc_event(void) · line 627
Quoted 8 lines
tools/lib/traceevent/event-parse.c +3
-1@@ -621,7 +621,9 @@ static struct event_format *alloc_event(void) {struct event_format *event; - event =malloc_or_die (sizeof (*event)); + event =malloc (sizeof (*event)); +if (!event) +return NULL ;memset (event,0 ,sizeof (*event));
Perhaps we should combined these to:
{
struct event_format *event;
event = calloc(1, sizeof(*event));
return event;
}Or even:
{
return calloc(1, sizeof(struct event_format));
}-- Steve
Quoted 2 lines
tools/lib/traceevent/event-parse.c +0
-0return event;
Hi,
Quoted 37 lines · Steven Rostedt
Quoted 18 lines · Namhyung Kim
From: Namhyung Kim <[email protected]>
Because the only caller of the
alloc_event()(pevent_parse_event) checks return value properly, it can be changed to use plain malloc.Cc Frederic Weisbecker <[email protected]>Cc Steven Rostedt <[email protected]>Signed-off-by Namhyung Kim <[email protected]>--- tools/lib/traceevent/event-parse.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)tools/lib/traceevent/event-parse.c +0
-0tools/lib/traceevent/event-parse.c static struct event_format *alloc_event(void) · line 627
Quoted 8 lines
tools/lib/traceevent/event-parse.c +3
-1@@ -621,7 +621,9 @@ static struct event_format *alloc_event(void) {struct event_format *event; - event =malloc_or_die (sizeof (*event)); + event =malloc (sizeof (*event)); +if (!event) +return NULL ;memset (event,0 ,sizeof (*event));Perhaps we should combined these to:
{ struct event_format *event; event = calloc(1, sizeof(*event)); return event; }
Quoted 6 lines
Or even:
{ return calloc(1, sizeof(struct event_format)); }
Ok, I'll take this. Thanks.
Namhyung
Arnaldo Carvalho de Melo
AppliedEm Mon, Jun 11, 2012 at 03:28:53PM +0900, Namhyung Kim escreveu:
Quoted 5 lines
From: Namhyung Kim <[email protected]>
Because the only caller of the
alloc_event()(pevent_parse_event) checks return value properly, it can be changed to use plain malloc.
Thanks, applied to perf/core.
- Arnaldo
Commit-ID: 50d8f9e393c5a1a8864fda75e3a9f2b800497a61 Gitweb: http://git.kernel.org/tip/50d8f9e393c5a1a8864fda75e3a9f2b800497a61 Author: Namhyung Kim <[email protected]> AuthorDate: Mon, 11 Jun 2012 15:28:53 +0900 Committer: Arnaldo Carvalho de Melo <[email protected]> CommitDate: Fri, 29 Jun 2012 13:28:13 -0300
tools lib traceevent: Replace malloc_or_die to plain malloc in alloc_event()
Because the only caller of the alloc_event() (pevent_parse_event) checks return value properly, it can be changed to use plain malloc.
--- tools/lib/traceevent/event-parse.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
tools/lib/traceevent/event-parse.c +3 -1
@@ -616,7 +616,9 @@ static struct event_format *alloc_event(void) {struct event_format *event; - event =malloc_or_die (sizeof (*event)); + event =malloc (sizeof (*event)); +if (!event) +return NULL ;memset (event,0 ,sizeof (*event));return event;