mirror of
https://github.com/AuxXxilium/kmod.git
synced 2025-03-07 13:17:47 +07:00
tests: release memory before error exits.
this makes it easier to valgrind the error cases as well.
This commit is contained in:
parent
69f9dd4369
commit
8226058343
@ -29,8 +29,10 @@ int main(int argc, char *argv[])
|
||||
printf("libkmod version %s\n", VERSION);
|
||||
|
||||
err = kmod_module_new_from_path(ctx, path, &mod);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
kmod_unref(ctx);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Trying insmod '%s'\n", path);
|
||||
err = kmod_module_insert_module(mod, 0);
|
||||
|
@ -40,6 +40,7 @@ int main(int argc, char *argv[])
|
||||
kmod_list_foreach(l, list) {
|
||||
struct kmod_module *mod = kmod_module_get_module(l);
|
||||
printf("\t%s\n", kmod_module_get_name(mod));
|
||||
kmod_module_unref(mod);
|
||||
}
|
||||
|
||||
kmod_module_unref_list(list);
|
||||
|
@ -27,6 +27,7 @@ int main(int argc, char *argv[])
|
||||
err = kmod_loaded_get_list(ctx, &list);
|
||||
if (err < 0) {
|
||||
fprintf(stderr, "%s\n", strerror(-err));
|
||||
kmod_unref(ctx);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
|
@ -29,8 +29,10 @@ int main(int argc, char *argv[])
|
||||
printf("libkmod version %s\n", VERSION);
|
||||
|
||||
err = kmod_module_new_from_name(ctx, modname, &mod);
|
||||
if (err < 0)
|
||||
if (err < 0) {
|
||||
kmod_unref(ctx);
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
printf("Trying to remove '%s'\n", modname);
|
||||
kmod_module_remove_module(mod, 0);
|
||||
|
Loading…
Reference in New Issue
Block a user