Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Nathan Chancellor <nathan@kernel.org>
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	llvm@lists.linux.dev, kernel test robot <lkp@intel.com>,
	Huang Rui <ray.huang@amd.com>,
	"Gautham R. Shenoy" <gautham.shenoy@amd.com>,
	Perry Yuan <perry.yuan@amd.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	Viresh Kumar <viresh.kumar@linaro.org>,
	Swapnil Sapkal <swapnil.sapkal@amd.com>
Subject: Re: [PATCH] cpufreq/amd-pstate: Avoid shadowing ret in amd_pstate_ut_check_driver()
Date: Tue, 13 May 2025 11:14:05 -0500	[thread overview]
Message-ID: <34aa4d3e-ed6b-4caf-aeb5-0f40ecff1a94@kernel.org> (raw)
In-Reply-To: <20250512-amd-pstate-ut-uninit-ret-v1-1-fcb4104f502e@kernel.org>

On 5/12/2025 4:28 PM, Nathan Chancellor wrote:
> Clang warns (or errors with CONFIG_WERROR=y):
> 
>    drivers/cpufreq/amd-pstate-ut.c:262:6: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
>      262 |         if (ret)
>          |             ^~~
> 
> ret is declared at the top of the function and in the for loop so the
> initialization of ret is local to the loop. Remove the declaration in
> the for loop so that ret is always used initialized.
> 
> Fixes: d26d16438bc5 ("amd-pstate-ut: Reset amd-pstate driver mode after running selftests")
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202505072226.g2QclhaR-lkp@intel.com/
> Signed-off-by: Nathan Chancellor <nathan@kernel.org>
> ---
>   drivers/cpufreq/amd-pstate-ut.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/cpufreq/amd-pstate-ut.c b/drivers/cpufreq/amd-pstate-ut.c
> index 30835d0e4994..65f9d2bae2d3 100644
> --- a/drivers/cpufreq/amd-pstate-ut.c
> +++ b/drivers/cpufreq/amd-pstate-ut.c
> @@ -246,7 +246,7 @@ static int amd_pstate_ut_check_driver(u32 index)
>   	int ret;
>   
>   	for (mode1 = AMD_PSTATE_DISABLE; mode1 < AMD_PSTATE_MAX; mode1++) {
> -		int ret = amd_pstate_set_mode(mode1);
> +		ret = amd_pstate_set_mode(mode1);
>   		if (ret)
>   			return ret;
>   		for (mode2 = AMD_PSTATE_DISABLE; mode2 < AMD_PSTATE_MAX; mode2++) {
> 
> ---
> base-commit: b01fc4eca73cbd7946181255a95dbe64ff83bc5f
> change-id: 20250512-amd-pstate-ut-uninit-ret-46a23a195687
> 
> Best regards,

Much appreciated.

Acked-by: Mario Limonciello <mario.limonciello@amd.com>

Applied to superm1/bleeding-edge.

      reply	other threads:[~2025-05-13 16:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 21:28 [PATCH] cpufreq/amd-pstate: Avoid shadowing ret in amd_pstate_ut_check_driver() Nathan Chancellor
2025-05-13 16:14 ` Mario Limonciello [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=34aa4d3e-ed6b-4caf-aeb5-0f40ecff1a94@kernel.org \
    --to=superm1@kernel.org \
    --cc=gautham.shenoy@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=perry.yuan@amd.com \
    --cc=rafael@kernel.org \
    --cc=ray.huang@amd.com \
    --cc=swapnil.sapkal@amd.com \
    --cc=viresh.kumar@linaro.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox