summaryrefslogtreecommitdiff
path: root/src/core/kmod-setup.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-10-08 15:55:24 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2017-10-08 22:04:07 +0200
commit232ac0d6810498dc7a3a6b9d1fd4dca983e1535f (patch)
treec3d1cd6c5a89240374d52daeffc0490389336477 /src/core/kmod-setup.c
parentb32bceb6c319f5a7b61f8bbfc14af8bb43effc11 (diff)
downloadsystemd-232ac0d6810498dc7a3a6b9d1fd4dca983e1535f.tar.gz
util-lib: introdude _cleanup_ macros for kmod objects
Diffstat (limited to 'src/core/kmod-setup.c')
-rw-r--r--src/core/kmod-setup.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 066b959770..10d3ced93d 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -31,6 +31,7 @@
#include "fileio.h"
#include "kmod-setup.h"
#include "macro.h"
+#include "module-util.h"
#include "string-util.h"
#if HAVE_KMOD
@@ -110,7 +111,7 @@ int kmod_setup(void) {
/* virtio_rng would be loaded by udev later, but real entropy might be needed very early */
{ "virtio_rng", NULL, false, false, has_virtio_rng },
};
- struct kmod_ctx *ctx = NULL;
+ _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL;
unsigned int i;
int r;
@@ -118,7 +119,7 @@ int kmod_setup(void) {
return 0;
for (i = 0; i < ELEMENTSOF(kmod_table); i++) {
- struct kmod_module *mod;
+ _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL;
if (kmod_table[i].path && access(kmod_table[i].path, F_OK) >= 0)
continue;
@@ -157,13 +158,8 @@ int kmod_setup(void) {
log_full_errno(print_warning ? LOG_WARNING : LOG_DEBUG, r,
"Failed to insert module '%s': %m", kmod_module_get_name(mod));
}
-
- kmod_module_unref(mod);
}
- if (ctx)
- kmod_unref(ctx);
-
#endif
return 0;
}