All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>,
	intel-gfx@lists.freedesktop.org
Cc: alex.zuo@intel.com, jonathan.cavitt@intel.com,
	imre.deak@intel.com, michal.grzelak@intel.com
Subject: Re: [PATCH v2] drm/i915/kunit: DP Link: Use if statements instead of for loops
Date: Wed, 12 Aug 2026 12:15:37 +0300	[thread overview]
Message-ID: <afaa8f5d600415eed8b2ea39cefe2709818e3877@intel.com> (raw)
In-Reply-To: <20260811175719.139464-1-jonathan.cavitt@intel.com>

On Wed, 12 Aug 2026, Jonathan Cavitt <jonathan.cavitt@intel.com> wrote:
> The static functions get_target_config and get_fallback_config in
> intel_dp_link_test.c use for loops to determine if the requested index of
> the config set is in the bounds of the config set entry list.
>
> Reconfigure these functions to use if statements instead, as these for
> loops are only run for a single iteration.

The CI on intel-gfx doesn't run kunit tests, while intel-xe does.

Please send the changes to intel-xe, and double check that the link
tests get run, before merging.

> Issue caught by static analysis.
>
> v2: (Michal)
> - Change i <= 0 check to i == 0, as i cannot be negative by assertion
> - Remove unnecessary newlines
>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Imre Deak <imre.deak@intel.com>
> Cc: Michal Grzelak <michal.grzelak@intel.com>
> ---
>  .../i915/display/tests/intel_dp_link_test.c   | 34 ++++++++-----------
>  1 file changed, 15 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c b/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c
> index 67c6fe9f1812..6dfd8903a8ec 100644
> --- a/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c
> +++ b/drivers/gpu/drm/i915/display/tests/intel_dp_link_test.c
> @@ -1215,22 +1215,20 @@ static bool get_fallback_config(const struct test_config_table *expected_table,
>  	struct kunit *test = expected_table->test;
>  	const struct link_config_set *config_set =
>  		get_fallback_configs_for_output_type(test, output_type);
> +	const struct intel_dp_link_config *config;
>  	int i;
>  
>  	i = lookup_config(config_set, target_config);
>  	KUNIT_ASSERT_GE(test, i, 0);
>  
> -	for (i--; i >= 0; i--) {
> -		const struct intel_dp_link_config *config =
> -			&config_set->entries[i];
> +	if (!i)
> +		return false;
>  
> -		assert_config_is_supported(expected_table, config);
> -		*fallback_config = *config;
> +	config = &config_set->entries[i-1];

Nitpick, checkpatch should complain about missing spaces around the
operand in "i-1".

> +	assert_config_is_supported(expected_table, config);
> +	*fallback_config = *config;
>  
> -		return true;
> -	}
> -
> -	return false;
> +	return true;
>  }
>  
>  static bool get_target_config(const struct test_config_table *expected_table,
> @@ -1240,19 +1238,17 @@ static bool get_target_config(const struct test_config_table *expected_table,
>  	struct kunit *test = expected_table->test;
>  	const struct link_config_set *config_set =
>  		get_target_configs_for_output_type(test, output_type);
> -	int i;
> +	const struct intel_dp_link_config *config;
> +	int i = config_set->size - 1;
>  
> -	for (i = config_set->size - 1; i >= 0; i--) {
> -		const struct intel_dp_link_config *config =
> -			&config_set->entries[i];
> +	if (i < 0)
> +		return false;
>  
> -		assert_config_is_supported(expected_table, config);
> -		*target = *config;
> +	config = &config_set->entries[i];
> +	assert_config_is_supported(expected_table, config);
> +	*target = *config;
>  
> -		return true;
> -	}
> -
> -	return false;
> +	return true;
>  }
>  
>  static void test_fallback_seq(struct kunit *test,

-- 
Jani Nikula, Intel

      parent reply	other threads:[~2026-08-12  9:15 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 17:57 [PATCH v2] drm/i915/kunit: DP Link: Use if statements instead of for loops Jonathan Cavitt
2026-08-11 19:01 ` ✓ i915.CI.BAT: success for drm/i915/kunit: DP Link: Use if statements instead of for loops (rev2) Patchwork
2026-08-11 23:14 ` ✓ i915.CI.Full: " Patchwork
2026-08-12  9:15 ` Jani Nikula [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=afaa8f5d600415eed8b2ea39cefe2709818e3877@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=alex.zuo@intel.com \
    --cc=imre.deak@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jonathan.cavitt@intel.com \
    --cc=michal.grzelak@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.