[PATCH i-g-t v4 4/6] lib/igt_kmod: Stop passing ktap around
Lucas De Marchi
lucas.demarchi at intel.com
Tue Nov 19 05:29:52 UTC 2024
Just allocate and free in the only function it's needed.
Reviewed-by: Janusz Krzysztofik <janusz.krzysztofik at linux.intel.com>
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
lib/igt_kmod.c | 28 ++++++++++++----------------
1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/lib/igt_kmod.c b/lib/igt_kmod.c
index 51032502f..626d67541 100644
--- a/lib/igt_kmod.c
+++ b/lib/igt_kmod.c
@@ -995,8 +995,9 @@ static void kunit_results_free(struct igt_list_head *results,
}
static int kunit_get_results(struct igt_list_head *results, const char *debugfs_path,
- const char *suite, struct igt_ktap_results **ktap)
+ const char *suite)
{
+ struct igt_ktap_results *ktap;
char results_path[PATH_MAX];
FILE *results_stream;
char *buf = NULL;
@@ -1012,21 +1013,21 @@ static int kunit_get_results(struct igt_list_head *results, const char *debugfs_
if (igt_debug_on(!results_stream))
return -errno;
- *ktap = igt_ktap_alloc(results);
- if (igt_debug_on(!*ktap)) {
+ ktap = igt_ktap_alloc(results);
+ if (igt_debug_on(!ktap)) {
err = -ENOMEM;
goto out_fclose;
}
while (len = getline(&buf, &size, results_stream), len > 0) {
- err = igt_ktap_parse(buf, *ktap);
+ err = igt_ktap_parse(buf, ktap);
if (err != -EINPROGRESS)
break;
}
free(buf);
+ igt_ktap_free(&ktap);
- igt_ktap_free(ktap);
out_fclose:
fclose(results_stream);
@@ -1038,8 +1039,7 @@ static void kunit_get_tests(struct igt_list_head *tests,
const char *suite,
const char *opts,
const char *debugfs_path,
- DIR *debugfs_dir,
- struct igt_ktap_results **ktap)
+ DIR *debugfs_dir)
{
struct igt_ktap_result *r, *rn;
struct dirent *subdir;
@@ -1077,7 +1077,7 @@ static void kunit_get_tests(struct igt_list_head *tests,
if (suite && strcmp(subdir->d_name, suite))
continue;
- igt_warn_on_f(kunit_get_results(tests, debugfs_path, subdir->d_name, ktap),
+ igt_warn_on_f(kunit_get_results(tests, debugfs_path, subdir->d_name),
"parsing KTAP report from test suite \"%s\" failed\n",
subdir->d_name);
@@ -1094,8 +1094,7 @@ static void __igt_kunit(struct igt_ktest *tst,
const char *subtest,
const char *opts,
const char *debugfs_path,
- struct igt_list_head *tests,
- struct igt_ktap_results **ktap)
+ struct igt_list_head *tests)
{
struct igt_ktap_result *t;
@@ -1125,7 +1124,7 @@ static void __igt_kunit(struct igt_ktest *tst,
igt_assert_eq(igt_kernel_tainted(&taints), 0);
igt_assert_eq(kunit_get_results(&results, debugfs_path,
- t->suite_name, ktap), 0);
+ t->suite_name), 0);
for (i = 0; i < 2; i++) {
kunit_result_free(&r, &suite_name, &case_name);
@@ -1189,7 +1188,6 @@ void igt_kunit(const char *module_name, const char *suite, const char *opts)
{
char debugfs_path[PATH_MAX] = { '\0', };
struct igt_ktest tst = { .kmsg = -1, };
- struct igt_ktap_results *ktap = NULL;
DIR *debugfs_dir = NULL;
char *subtest;
IGT_LIST_HEAD(tests);
@@ -1240,15 +1238,13 @@ void igt_kunit(const char *module_name, const char *suite, const char *opts)
*/
igt_subtest_with_dynamic(subtest) {
kunit_get_tests(&tests, &tst, suite, opts,
- debugfs_path, debugfs_dir, &ktap);
- __igt_kunit(&tst, subtest, opts, debugfs_path, &tests, &ktap);
+ debugfs_path, debugfs_dir);
+ __igt_kunit(&tst, subtest, opts, debugfs_path, &tests);
}
igt_fixture {
char *suite_name = NULL, *case_name = NULL;
- igt_ktap_free(&ktap);
-
kunit_results_free(&tests, &suite_name, &case_name);
closedir(debugfs_dir);
--
2.47.0
More information about the igt-dev
mailing list