diff mbox series

spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op()

Message ID 20250111-spi-amd-fix-uninitialized-ret-v1-1-c66ab9f6a23d@kernel.org (mailing list archive)
State Accepted
Commit ea2680e9cc96b957927ea3ea36b2b4ecb5da3d03
Headers show
Series spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op() | expand

Commit Message

Nathan Chancellor Jan. 11, 2025, 7:08 p.m. UTC
After commit e6204f39fe3a ("spi: amd: Drop redundant check"), clang warns (or
errors with CONFIG_WERROR=y):

  drivers/spi/spi-amd.c:695:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
    695 |         return ret;
        |                ^~~
  drivers/spi/spi-amd.c:673:9: note: initialize the variable 'ret' to silence this warning
    673 |         int ret;
        |                ^
        |                 = 0
  1 error generated.

ret is no longer set on anything other than the default switch path.
Replace ret with a direct return of 0 at the end of the function and
-EOPNOTSUPP in the default case to resolve the warning.

Fixes: e6204f39fe3a ("spi: amd: Drop redundant check")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202501112315.ugYQ7Ce7-lkp@intel.com/
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
---
 drivers/spi/spi-amd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)


---
base-commit: 226d6cb3cb799aae46d0dd19a521133997d9db11
change-id: 20250111-spi-amd-fix-uninitialized-ret-bcbc2e33af94

Best regards,

Comments

Miguel Ojeda Jan. 11, 2025, 7:27 p.m. UTC | #1
On Sat, Jan 11, 2025 at 8:09 PM Nathan Chancellor <nathan@kernel.org> wrote:
>
> After commit e6204f39fe3a ("spi: amd: Drop redundant check"), clang warns (or
> errors with CONFIG_WERROR=y):

Reviewed-by: Miguel Ojeda <ojeda@kernel.org>

Cheers,
Miguel
Miquel Raynal Jan. 13, 2025, 10:42 a.m. UTC | #2
Hello,

On 11/01/2025 at 12:08:38 -07, Nathan Chancellor <nathan@kernel.org> wrote:

> After commit e6204f39fe3a ("spi: amd: Drop redundant check"), clang warns (or
> errors with CONFIG_WERROR=y):
>
>   drivers/spi/spi-amd.c:695:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
>     695 |         return ret;
>         |                ^~~
>   drivers/spi/spi-amd.c:673:9: note: initialize the variable 'ret' to silence this warning
>     673 |         int ret;
>         |                ^
>         |                 = 0
>   1 error generated.
>
> ret is no longer set on anything other than the default switch path.
> Replace ret with a direct return of 0 at the end of the function and
> -EOPNOTSUPP in the default case to resolve the warning.

Correct, thanks.

Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Mark Brown Jan. 13, 2025, 4:45 p.m. UTC | #3
On Sat, 11 Jan 2025 12:08:38 -0700, Nathan Chancellor wrote:
> After commit e6204f39fe3a ("spi: amd: Drop redundant check"), clang warns (or
> errors with CONFIG_WERROR=y):
> 
>   drivers/spi/spi-amd.c:695:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
>     695 |         return ret;
>         |                ^~~
>   drivers/spi/spi-amd.c:673:9: note: initialize the variable 'ret' to silence this warning
>     673 |         int ret;
>         |                ^
>         |                 = 0
>   1 error generated.
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op()
      commit: ea2680e9cc96b957927ea3ea36b2b4ecb5da3d03

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark
Miquel Raynal Jan. 14, 2025, 10:03 a.m. UTC | #4
Hi Mark,

On 13/01/2025 at 16:45:09 GMT, Mark Brown <broonie@kernel.org> wrote:

> On Sat, 11 Jan 2025 12:08:38 -0700, Nathan Chancellor wrote:
>> After commit e6204f39fe3a ("spi: amd: Drop redundant check"), clang warns (or
>> errors with CONFIG_WERROR=y):
>> 
>>   drivers/spi/spi-amd.c:695:9: error: variable 'ret' is uninitialized when used here [-Werror,-Wuninitialized]
>>     695 |         return ret;
>>         |                ^~~
>>   drivers/spi/spi-amd.c:673:9: note: initialize the variable 'ret' to silence this warning
>>     673 |         int ret;
>>         |                ^
>>         |                 = 0
>>   1 error generated.
>> 
>> [...]
>
> Applied to
>
>    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
>
> Thanks!

I'm wondering whether it's relevant to pull the branch you shared
as-is. Do you plan on pushing this patch of top of it? Or shall I wait
-rc1 for the SPI NAND part?

Thanks,
Miquèl
Mark Brown Jan. 14, 2025, 3:17 p.m. UTC | #5
On Tue, Jan 14, 2025 at 11:03:22AM +0100, Miquel Raynal wrote:
> On 13/01/2025 at 16:45:09 GMT, Mark Brown <broonie@kernel.org> wrote:

> > Applied to

> >    https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

> > Thanks!

> I'm wondering whether it's relevant to pull the branch you shared
> as-is. Do you plan on pushing this patch of top of it? Or shall I wait
> -rc1 for the SPI NAND part?

Well, it's not a branch but rather a tag which complicates matters a
bit.  I could cherry pick the patch over and make a new tag I guess?  Or
you could just not do allmodconfig builds with clang?

The following changes since commit 9d89551994a430b50c4fffcb1e617a057fa76e20:

  Linux 6.13-rc6 (2025-01-05 14:13:40 -0800)

are available in the Git repository at:

  https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git tags/spi-mem-dtr-2

for you to fetch changes up to e896c04890aeff2292364c19632fc15d890d436c:

  spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op() (2025-01-14 15:07:11 +0000)

----------------------------------------------------------------
spi: Support DTR in spi-mem

Changes to support DTR with spi-mem.

----------------------------------------------------------------
Miquel Raynal (20):
      spi: spi-mem: Extend spi-mem operations with a per-operation maximum frequency
      spi: spi-mem: Add a new controller capability
      spi: amd: Support per spi-mem operation frequency switches
      spi: amd: Drop redundant check
      spi: amlogic-spifc-a1: Support per spi-mem operation frequency switches
      spi: cadence-qspi: Support per spi-mem operation frequency switches
      spi: dw: Support per spi-mem operation frequency switches
      spi: fsl-qspi: Support per spi-mem operation frequency switches
      spi: microchip-core-qspi: Support per spi-mem operation frequency switches
      spi: mt65xx: Support per spi-mem operation frequency switches
      spi: mxic: Support per spi-mem operation frequency switches
      spi: nxp-fspi: Support per spi-mem operation frequency switches
      spi: rockchip-sfc: Support per spi-mem operation frequency switches
      spi: spi-sn-f-ospi: Support per spi-mem operation frequency switches
      spi: spi-ti-qspi: Support per spi-mem operation frequency switches
      spi: zynq-qspi: Support per spi-mem operation frequency switches
      spi: zynqmp-gqspi: Support per spi-mem operation frequency switches
      spi: spi-mem: Reorder spi-mem macro assignments
      spi: spi-mem: Create macros for DTR operation
      spi: spi-mem: Estimate the time taken by operations

Nathan Chancellor (1):
      spi: amd: Fix -Wuninitialized in amd_spi_exec_mem_op()

 drivers/mtd/nand/spi/core.c           |  2 ++
 drivers/spi/spi-amd.c                 | 26 +++++++-------
 drivers/spi/spi-amlogic-spifc-a1.c    |  7 +++-
 drivers/spi/spi-cadence-quadspi.c     |  3 +-
 drivers/spi/spi-dw-core.c             | 10 ++++--
 drivers/spi/spi-fsl-qspi.c            | 12 +++++--
 drivers/spi/spi-mem.c                 | 64 +++++++++++++++++++++++++++++++++++
 drivers/spi/spi-microchip-core-qspi.c | 26 +++++++++++---
 drivers/spi/spi-mt65xx.c              |  7 +++-
 drivers/spi/spi-mxic.c                |  3 +-
 drivers/spi/spi-nxp-fspi.c            | 12 +++++--
 drivers/spi/spi-rockchip-sfc.c        | 11 ++++--
 drivers/spi/spi-sn-f-ospi.c           |  8 +++--
 drivers/spi/spi-ti-qspi.c             |  7 +++-
 drivers/spi/spi-zynq-qspi.c           | 13 +++++--
 drivers/spi/spi-zynqmp-gqspi.c        | 13 ++++---
 include/linux/spi/spi-mem.h           | 56 +++++++++++++++++++++++++++++-
 17 files changed, 237 insertions(+), 43 deletions(-)
diff mbox series

Patch

diff --git a/drivers/spi/spi-amd.c b/drivers/spi/spi-amd.c
index fbe795bbcf507abcbbd973b226b5db0de1584898..c85997478b81903c97636d271baf7d378914c50a 100644
--- a/drivers/spi/spi-amd.c
+++ b/drivers/spi/spi-amd.c
@@ -670,7 +670,6 @@  static int amd_spi_exec_mem_op(struct spi_mem *mem,
 			       const struct spi_mem_op *op)
 {
 	struct amd_spi *amd_spi;
-	int ret;
 
 	amd_spi = spi_controller_get_devdata(mem->spi->controller);
 
@@ -689,10 +688,10 @@  static int amd_spi_exec_mem_op(struct spi_mem *mem,
 		amd_spi_mem_data_out(amd_spi, op);
 		break;
 	default:
-		ret = -EOPNOTSUPP;
+		return -EOPNOTSUPP;
 	}
 
-	return ret;
+	return 0;
 }
 
 static const struct spi_controller_mem_ops amd_spi_mem_ops = {