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

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Oct 18 15:13:22 UTC 2022


On Tue, Oct 18, 2022 at 11:10:00AM +0200, Kamil Konieczny wrote:
> Refactor filter adding loop.

Eh, one thing not visible here - patch subject - s/filer/filter/

--
Zbigniew

> 
> 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