From 7854e94af7a46bcdb31eebc3f633e93589303e5e Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sat, 26 Oct 2024 10:20:38 +0000 Subject: [PATCH] linter: Create a filelist with all files with issues Signed-off-by: Michael Tremer --- src/libpakfire/linter.c | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/libpakfire/linter.c b/src/libpakfire/linter.c index d1dbc78ba..0e9cac5ec 100644 --- a/src/libpakfire/linter.c +++ b/src/libpakfire/linter.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -64,6 +65,9 @@ struct pakfire_linter { // Package struct pakfire_package* pkg; + // Filelist + struct pakfire_filelist* filelist; + // Results TAILQ_HEAD(results, pakfire_linter_result) results; @@ -121,9 +125,15 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi return -errno; // Store file - if (file) + if (file) { result->file = pakfire_file_ref(file); + // Add the file to the filelist + r = pakfire_filelist_add(linter->filelist, file); + if (r < 0) + goto ERROR; + } + // Store priority result->priority = priority; @@ -133,10 +143,8 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi va_end(args); // Fail on error - if (r < 0) { - pakfire_linter_result_free(result); - return r; - } + if (r < 0) + goto ERROR; // Store the result TAILQ_INSERT_TAIL(&linter->results, result, nodes); @@ -152,6 +160,12 @@ int pakfire_linter_result(struct pakfire_linter* linter, struct pakfire_file* fi } return 0; + +ERROR: + if (result) + pakfire_linter_result_free(result); + + return r; } int pakfire_linter_create(struct pakfire_linter** linter, @@ -190,6 +204,11 @@ int pakfire_linter_create(struct pakfire_linter** linter, goto ERROR; } + // Create a filelist + r = pakfire_filelist_create(&l->filelist, l->pakfire); + if (r < 0) + goto ERROR; + // Return the pointer *linter = pakfire_linter_ref(l); @@ -213,6 +232,8 @@ static void pakfire_linter_free(struct pakfire_linter* linter) { pakfire_linter_result_free(result); } + if (linter->filelist) + pakfire_filelist_unref(linter->filelist); if (linter->archive) pakfire_archive_unref(linter->archive); if (linter->pkg) -- 2.39.5