]> git.ipfire.org Git - thirdparty/kmod.git/commit
libkmod: Avoid redundant kmod_pool_get_module call
authorTobias Stoeckmann <tobias@stoeckmann.org>
Mon, 30 Sep 2024 18:27:49 +0000 (20:27 +0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 1 Oct 2024 15:13:16 +0000 (10:13 -0500)
commite19338daa67b7669391e1164b30d7bb64785feeb
treefcf269dbc2478be2a3a9d3c88e73e5c4e41afb6f
parente7db27b058fc690a540c104f2809ab8e3c2bd995
libkmod: Avoid redundant kmod_pool_get_module call

Before kmod_module_new_from_path creates a module with kmod_module_new,
it checks with kmod_pool_get_module if a module with given name already
exists.

This check can be removed, because kmod_module_new does the same. If the
module already existed, the same checks are performed as in current code
for the "if (m != NULL)" case. If it did not exist yet, m->path is NULL
and the first if-block is entered.

And since kmod_module_new takes care of incrementing the reference
counter, the explicit call of kmod_module_ref can be removed from
kmod_module_new_from_path as well.

Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/168
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
libkmod/libkmod-module.c