Planned changes require a couple of loops around kunit_result_free(). Since we already have such loop, move it into a helper in preparation for future uses. Signed-off-by: Janusz Krzysztofik <janusz.krzysztofik@xxxxxxxxxxxxxxx> Reviewed-by: Kamil Konieczny <kamil.konieczny@xxxxxxxxxxxxxxx> --- lib/igt_kmod.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c index d014644fb4..21c547bf42 100644 --- a/lib/igt_kmod.c +++ b/lib/igt_kmod.c @@ -888,13 +888,25 @@ static void kunit_result_free(struct igt_ktap_result **r, *r = NULL; } +static void kunit_results_free(struct igt_list_head *results, + char **suite_name, char **case_name) +{ + struct igt_ktap_result *r, *rn; + + igt_list_for_each_entry_safe(r, rn, results, link) + kunit_result_free(&r, suite_name, case_name); + + free(*case_name); + free(*suite_name); +} + static void __igt_kunit(struct igt_ktest *tst, const char *name, const char *opts) { struct modprobe_data modprobe = { tst->kmod, opts, 0, pthread_self(), }; char *suite_name = NULL, *case_name = NULL; - struct igt_ktap_result *r, *rn; struct igt_ktap_results *ktap; + struct igt_ktap_result *r; pthread_mutexattr_t attr; IGT_LIST_HEAD(results); unsigned long taints; @@ -1000,11 +1012,7 @@ __igt_kunit(struct igt_ktest *tst, const char *name, const char *opts) } while (ret == -EINPROGRESS); - igt_list_for_each_entry_safe(r, rn, &results, link) - kunit_result_free(&r, &suite_name, &case_name); - - free(case_name); - free(suite_name); + kunit_results_free(&results, &suite_name, &case_name); switch (pthread_mutex_lock(&modprobe.lock)) { case 0: -- 2.42.0