Message ID | 20230602040123.3ce83b19@rorschach.local.home (mailing list archive) |
---|---|
State | Accepted |
Commit | 22ad81e4818d1f56112bdd6be7e62535c74085b9 |
Headers | show |
Series | trace-cmd record: Remove redundant check of instance in allocate_instance() | expand |
On Fri, 2 Jun 2023 15:12:11 +0200 Markus Elfring <Markus.Elfring@web.de> wrote: > > 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). > > 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
diff --git a/tracecmd/trace-record.c b/tracecmd/trace-record.c index b094f0699a43..41d765b593b7 100644 --- a/tracecmd/trace-record.c +++ b/tracecmd/trace-record.c @@ -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; }