[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <201204231304.q3ND4TFe020805@drepperk.user.openhosting.com>
Date: Mon, 23 Apr 2012 09:04:29 -0400
From: Ulrich Drepper <drepper@...adia.org>
To: a.p.zijlstra@...llo.nl, acme@...stprotocols.net, dsahern@...il.com,
eranian@...gle.com, linux-kernel@...r.kernel.org, mingo@...hat.com,
paulus@...ba.org, robert.richter@....com
Subject: [PATCH] Small perf cleanup
I just noticed this. The if branch is completely unnecessary since
'realloc' handles NULL pointers for the first parameter. This is
really only a cleanup and submitted mainly to prevent proliferation
of bad practices.
Signed-off-by: Ulrich Drepper <drepper@...il.com>
tools/perf/util/header.c | 17 ++++++-----------
1 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4c7c2d7..6e618ba 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -31,21 +31,16 @@ static const char **header_argv;
int perf_header__push_event(u64 id, const char *name)
{
+ struct perf_trace_event_type *nevents;
+
if (strlen(name) > MAX_EVENT_NAME)
pr_warning("Event %s will be truncated\n", name);
- if (!events) {
- events = malloc(sizeof(struct perf_trace_event_type));
- if (events == NULL)
- return -ENOMEM;
- } else {
- struct perf_trace_event_type *nevents;
+ nevents = realloc(events, (event_count + 1) * sizeof(*events));
+ if (nevents == NULL)
+ return -ENOMEM;
+ events = nevents;
- nevents = realloc(events, (event_count + 1) * sizeof(*events));
- if (nevents == NULL)
- return -ENOMEM;
- events = nevents;
- }
memset(&events[event_count], 0, sizeof(struct perf_trace_event_type));
events[event_count].event_id = id;
strncpy(events[event_count].name, name, MAX_EVENT_NAME - 1);
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists