]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
testsuite: sort modnames only, if available
authorEmil Velikov <emil.l.velikov@gmail.com>
Thu, 19 Sep 2024 14:50:21 +0000 (15:50 +0100)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Sun, 22 Sep 2024 22:35:37 +0000 (17:35 -0500)
In some tests we expect zero modules to be loaded. In those cases, skip
the sorting - qsort is annotated as non-null(1,2) so we shouldn't
provide null as expected/loaded modules.

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/144
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
testsuite/testsuite.c

index 51a3d9f10f843069e628708d4b8fb2db19bb2186..22ee29c2022d837255e9422dfa3c129de180db97 100644 (file)
@@ -910,8 +910,10 @@ static int check_loaded_modules(const struct test *t)
        a2 = read_loaded_modules(t, &buf2, &l2);
        if (l2 < 0)
                goto out_a1;
-       qsort(a1, l1, sizeof(char *), cmp_modnames);
-       qsort(a2, l2, sizeof(char *), cmp_modnames);
+       if (a1 && l1)
+               qsort(a1, l1, sizeof(char *), cmp_modnames);
+       if (a2 && l2)
+               qsort(a2, l2, sizeof(char *), cmp_modnames);
        i1 = i2 = 0;
        err = true;
        while (i1 < l1 || i2 < l2) {