diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-08 15:55:24 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-08 22:04:07 +0200 |
commit | 232ac0d6810498dc7a3a6b9d1fd4dca983e1535f (patch) | |
tree | c3d1cd6c5a89240374d52daeffc0490389336477 /src/modules-load | |
parent | b32bceb6c319f5a7b61f8bbfc14af8bb43effc11 (diff) | |
download | systemd-232ac0d6810498dc7a3a6b9d1fd4dca983e1535f.tar.gz |
util-lib: introdude _cleanup_ macros for kmod objects
Diffstat (limited to 'src/modules-load')
-rw-r--r-- | src/modules-load/modules-load.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 6efebcd94f..1cb9001c39 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -29,6 +29,7 @@ #include "fd-util.h" #include "fileio.h" #include "log.h" +#include "module-util.h" #include "proc-cmdline.h" #include "string-util.h" #include "strv.h" @@ -77,7 +78,8 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat static int load_module(struct kmod_ctx *ctx, const char *m) { const int probe_flags = KMOD_PROBE_APPLY_BLACKLIST; - struct kmod_list *itr, *modlist = NULL; + struct kmod_list *itr; + _cleanup_(kmod_module_unref_listp) struct kmod_list *modlist = NULL; int r = 0; log_debug("load: %s", m); @@ -92,7 +94,7 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { } kmod_list_foreach(itr, modlist) { - struct kmod_module *mod; + _cleanup_(kmod_module_unrefp) struct kmod_module *mod = NULL; int state, err; mod = kmod_module_get_module(itr); @@ -120,12 +122,8 @@ static int load_module(struct kmod_ctx *ctx, const char *m) { r = err; } } - - kmod_module_unref(mod); } - kmod_module_unref_list(modlist); - return r; } @@ -218,7 +216,7 @@ static int parse_argv(int argc, char *argv[]) { int main(int argc, char *argv[]) { int r, k; - struct kmod_ctx *ctx; + _cleanup_(kmod_unrefp) struct kmod_ctx *ctx = NULL; r = parse_argv(argc, argv); if (r <= 0) @@ -280,7 +278,6 @@ int main(int argc, char *argv[]) { } finish: - kmod_unref(ctx); strv_free(arg_proc_cmdline_modules); return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS; |