Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1308808 > unrolled thread

[PATCH] spi: fix counting in spi-loopback-test code

Started byArnd Bergmann <arnd@arndb.de>
First post2016-01-13 22:00 +0100
Last post2016-01-15 12:30 +0100
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] spi: fix counting in spi-loopback-test code Arnd Bergmann <arnd@arndb.de> - 2016-01-13 22:00 +0100
    Re: [PATCH] spi: fix counting in spi-loopback-test code Geert Uytterhoeven <geert@linux-m68k.org> - 2016-01-15 12:30 +0100

#1308808 — [PATCH] spi: fix counting in spi-loopback-test code

FromArnd Bergmann <arnd@arndb.de>
Date2016-01-13 22:00 +0100
Subject[PATCH] spi: fix counting in spi-loopback-test code
Message-ID<qQAGl-54j-5@gated-at.bofh.it>
These variables are always used uninitialized:

drivers/spi/spi-loopback-test.c: In function 'spi_test_run_iter':
drivers/spi/spi-loopback-test.c:768:17: warning: 'rx_count' may be used uninitialized in this function [-Wmaybe-uninitialized]
drivers/spi/spi-loopback-test.c:762:17: warning: 'tx_count' may be used uninitialized in this function [-Wmaybe-uninitialized]

Adding an explicit initialization seems to be the only
workable solution here, to make the code behave correctly
and build without warning.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Fixes: 84e0c4e5e2c4 ("spi: add loopback test driver to allow for spi_master regression tests")
---
The warning is hidden in allmodconfig at the moment because we build
that with -Os rather than -O2, which shows it.

diff --git a/drivers/spi/spi-loopback-test.c b/drivers/spi/spi-loopback-test.c
index 894616f687b0..cf4bb36bee25 100644
--- a/drivers/spi/spi-loopback-test.c
+++ b/drivers/spi/spi-loopback-test.c
@@ -761,6 +761,7 @@ static int spi_test_run_iter(struct spi_device *spi,
 		test.iterate_transfer_mask = 1;
 
 	/* count number of transfers with tx/rx_buf != NULL */
+	rx_count = tx_count = 0;
 	for (i = 0; i < test.transfer_count; i++) {
 		if (test.transfers[i].tx_buf)
 			tx_count++;

[toc] | [next] | [standalone]


#1310061

FromGeert Uytterhoeven <geert@linux-m68k.org>
Date2016-01-15 12:30 +0100
Message-ID<qRaJP-5m5-3@gated-at.bofh.it>
In reply to#1308808
On Wed, Jan 13, 2016 at 9:51 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> These variables are always used uninitialized:
>
> drivers/spi/spi-loopback-test.c: In function 'spi_test_run_iter':
> drivers/spi/spi-loopback-test.c:768:17: warning: 'rx_count' may be used uninitialized in this function [-Wmaybe-uninitialized]
> drivers/spi/spi-loopback-test.c:762:17: warning: 'tx_count' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> Adding an explicit initialization seems to be the only
> workable solution here, to make the code behave correctly
> and build without warning.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> Fixes: 84e0c4e5e2c4 ("spi: add loopback test driver to allow for spi_master regression tests")

Just noticed the same, so
Acked-by: Geert Uytterhoeven <geert@linux-m68k.org>

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web