Skip to contentSkip to conversation

trace-cmd record: Remove redundant check of instance in allocate_instance()

PATCH In review Steven Rostedt 1 participant 2 messages Jun 2, 2023 – Jun 3, 2023 1 message not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd record: Remove redundant check of instance in allocate_instance()

From: "Steven Rostedt (Google)" <[email protected]>

The error path only happens after the instance has been allocated. No need to check if it exists again.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217127

---
 tracecmd/trace-record.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
tracecmd/trace-record.c +3 -5
index b094f0699a43..41d765b593b7 100644
@@ -387,11 +387,9 @@ struct buffer_instance *allocate_instance(const char *name)
 	return instance;
 
 error:
-	if (instance) {
-		free(instance->name);
-		tracefs_instance_free(instance->tracefs);
-		free(instance);
-	}
+	free(instance->name);
+	tracefs_instance_free(instance->tracefs);
+	free(instance);
 	return NULL;
 }
 
Signature · 1 line
2.39.2

A message that is not in the archive (sent off-list or not yet received): [email protected]

#2 lore raw
Quoted 6 lines · On Fri, 2 Jun 2023 15:12:11 +0200 Markus Elfring <[email protected]> wrote:
Quoted 4 lines

The error path only happens after the instance has been allocated. No need to check if it exists again.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=217127

Will it be more appropriate to refer to an other bug report here?

I first wasn't going to bother with it, but then I started modifying code around it where you mention this in the above mentioned bug, and tagged that one. I can modify it to have you original one (I'll do that internally, not with a v2).

Quoted 8 lines

2023-03-04
Improve exception handling in allocate_instance()
https://bugzilla.kernel.org/show_bug.cgi?id=217128

Will any additional adjustments become helpful for jump targets in this function implementation?

No need to spend cycles on this. It's a very slow path. Optimizing it is nothing more than an academic exercise.

-- Steve