From: Emil Velikov Date: Thu, 19 Sep 2024 14:50:21 +0000 (+0100) Subject: testsuite: sort modnames only, if available X-Git-Tag: v34~303 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=a49a96bdf027ea465e14551a305a9a1be5a26059;p=thirdparty%2Fkmod.git testsuite: sort modnames only, if available 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 Link: https://github.com/kmod-project/kmod/pull/144 Signed-off-by: Lucas De Marchi --- diff --git a/testsuite/testsuite.c b/testsuite/testsuite.c index 51a3d9f1..22ee29c2 100644 --- a/testsuite/testsuite.c +++ b/testsuite/testsuite.c @@ -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) {