]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
test-initstate: Check for negative value on error
authorLucas De Marchi <lucas.demarchi@intel.com>
Tue, 15 Feb 2022 22:05:13 +0000 (14:05 -0800)
committerLucas De Marchi <lucas.demarchi@intel.com>
Mon, 21 Feb 2022 04:58:11 +0000 (20:58 -0800)
Documentation says kmod_module_new_from_lookup() returns < 0 on error
and 0 otherwise. There are bugs in libkmod however making it return
a positive value in some situations, that need to be fixed. However
it's best to check for the error explicitly like is done in the rest
of the library to avoid this kind of issues.

Reviewed-by: Luis Chamberlain <mcgrof@kernel.org>
testsuite/test-initstate.c

index da2303a1a6bca65e4260c5dce67a74ec24ad6347..9332e8f21eeb80aa5821a03d5c624c280d67896f 100644 (file)
@@ -45,7 +45,7 @@ static noreturn int test_initstate_from_lookup(const struct test *t)
                exit(EXIT_FAILURE);
 
        err = kmod_module_new_from_lookup(ctx, "fake-builtin", &list);
-       if (err != 0) {
+       if (err < 0) {
                ERR("could not create module from lookup: %s\n", strerror(-err));
                exit(EXIT_FAILURE);
        }