Skip to contentSkip to conversation

tools lib traceevent: Replace malloc_or_die to plain malloc in alloc_event()

PATCH Applied Namhyung Kim 4 participants 6 messages Jun 11, 2012 – Jul 6, 2012

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

Cc Frederic Weisbecker <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 tools/lib/traceevent/event-parse.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
index c471075e4974..a6b5bcdc5580 100644
@@ -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
#1 lore raw

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]>
---
 tools/lib/traceevent/event-parse.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +3 -1
index c471075e4974..a6b5bcdc5580 100644
@@ -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;
#2 lore raw
In reply to Namhyung Kim
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]>
---
 tools/lib/traceevent/event-parse.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +0 -0
index c471075e4974..a6b5bcdc5580 100644

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 -0
 	return event;
#3 lore raw

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]>
---
 tools/lib/traceevent/event-parse.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/lib/traceevent/event-parse.c +0 -0
index c471075e4974..a6b5bcdc5580 100644

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;
}
Quoted 6 lines

Or even:

{
	return calloc(1, sizeof(struct event_format));
}

Ok, I'll take this. Thanks.
Namhyung

#4 lore raw
In reply to Namhyung Kim

Em 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

#5 lore raw
In reply to Namhyung Kim
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
index b1abd39..83f0a8a 100644
@@ -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;