From a49a96bdf027ea465e14551a305a9a1be5a26059 Mon Sep 17 00:00:00 2001 From: Emil Velikov Date: Thu, 19 Sep 2024 15:50:21 +0100 Subject: [PATCH] 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 --- testsuite/testsuite.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) { -- 2.47.3