[igt-dev] [PATCH i-g-t 1/2] lib/igt_device_scan: refactor filer adding

Kamil Konieczny kamil.konieczny at linux.intel.com
Tue Oct 18 09:10:00 UTC 2022


Refactor filter adding loop.

Signed-off-by: Kamil Konieczny <kamil.konieczny at linux.intel.com>
---
 lib/igt_device_scan.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/lib/igt_device_scan.c b/lib/igt_device_scan.c
index 15be3844..6f5b90e6 100644
--- a/lib/igt_device_scan.c
+++ b/lib/igt_device_scan.c
@@ -1775,13 +1775,15 @@ int igt_device_filter_add(const char *filters)
 
 	while ((filter = strsep(&dup, ";"))) {
 		bool is_valid = is_filter_valid(filter);
+		struct device_filter *df;
 		igt_warn_on(!is_valid);
-		if (is_valid) {
-			struct device_filter *df = malloc(sizeof(*df));
-			strncpy(df->filter, filter, sizeof(df->filter)-1);
-			igt_list_add_tail(&df->link, &device_filters);
-			count++;
-		}
+		if (!is_valid)
+			continue;
+
+		df = malloc(sizeof(*df));
+		strncpy(df->filter, filter, sizeof(df->filter)-1);
+		igt_list_add_tail(&df->link, &device_filters);
+		count++;
 	}
 
 	free(dup_orig);
-- 
2.34.1



More information about the igt-dev mailing list