Skip to contentSkip to conversation

tools/perf: Simplify event_read_id exit path

PATCH In review Borislav Petkov 1 participant 2 messages Mar 21, 2012 – Mar 23, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools/perf: Simplify event_read_id exit path

We're freeing the token in any case so simplify the exit path by unifying it.

No functional change.

---
 tools/perf/util/trace-event-parse.c |   10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
tools/perf/util/trace-event-parse.c +4 -6
index a4088ced1e64..dfd1bd8371a4 100644
@@ -722,7 +722,7 @@ static char *event_read_name(void)
 static int event_read_id(void)
 {
 	char *token;
-	int id;
+	int id = -1;
 
 	if (read_expected_item(EVENT_ITEM, "ID") < 0)
 		return -1;
@@ -731,15 +731,13 @@ static int event_read_id(void)
 		return -1;
 
 	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		goto fail;
+		goto free;
 
 	id = strtoul(token, NULL, 0);
-	free_token(token);
-	return id;
 
- fail:
+ free:
 	free_token(token);
-	return -1;
+	return id;
 }
 
 static int field_is_string(struct format_field *field)
Signature · 1 line
1.7.9.3.362.g71319
#1 lore raw

[tip:perf/urgent] perf tools: Simplify event_read_id exit path

Commit-ID:  842f07f6127afa48cca6b2ce9021b985e8eb9068
Gitweb:     http://git.kernel.org/tip/842f07f6127afa48cca6b2ce9021b985e8eb9068
Author:     Borislav Petkov <[email protected]>
AuthorDate: Wed, 21 Mar 2012 15:15:47 +0100
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 22 Mar 2012 15:10:42 -0300

perf tools: Simplify event_read_id exit path

We're freeing the token in any case so simplify the exit path by unifying it.

No functional change.

---
 tools/perf/util/trace-event-parse.c |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)
tools/perf/util/trace-event-parse.c +4 -6
index a4088ce..dfd1bd8 100644
@@ -722,7 +722,7 @@ static char *event_read_name(void)
 static int event_read_id(void)
 {
 	char *token;
-	int id;
+	int id = -1;
 
 	if (read_expected_item(EVENT_ITEM, "ID") < 0)
 		return -1;
@@ -731,15 +731,13 @@ static int event_read_id(void)
 		return -1;
 
 	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		goto fail;
+		goto free;
 
 	id = strtoul(token, NULL, 0);
-	free_token(token);
-	return id;
 
- fail:
+ free:
 	free_token(token);
-	return -1;
+	return id;
 }
 
 static int field_is_string(struct format_field *field)