* [PATCH] spi: sirf: avoid uninitialized-use warning
@ 2013-06-03 13:24 Arnd Bergmann
2013-06-03 15:44 ` Stephen Warren
0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2013-06-03 13:24 UTC (permalink / raw)
To: linux-arm-kernel
24778be20 "spi: convert drivers to use bits_per_word_mask"
removed the "default" statement in the spi_sirfsoc_setup_transfer
switch, causing a new warning:
drivers/spi/spi-sirf.c: In function 'spi_sirfsoc_setup_transfer':
arch/arm/include/asm/io.h:90:2: warning: 'rxfifo_ctrl' may be used uninitialized in this function [-Wmaybe-uninitialized]
asm volatile("str %1, %0"
^
drivers/spi/spi-sirf.c:364:19: note: 'rxfifo_ctrl' was declared here
u32 txfifo_ctrl, rxfifo_ctrl;
^
The compiler has correctly identified that this case may happen,
but since we know that things are horribly broken if bits_per_word
is ever something other than the values we tested, calling BUG()
is an appropriate action and tells the compiler that execution
will not continue afterwards.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Cc: Stephen Warren <swarren@wwwdotorg.org>
Cc: Mark Brown <broonie@kernel.org>
---
I keep using the wrong address for Mark even though I know it doesn't work
any more. Sorry for the duplicate mail.
diff --git a/drivers/spi/spi-sirf.c b/drivers/spi/spi-sirf.c
index 265a5c6..fc20bcf 100644
--- a/drivers/spi/spi-sirf.c
+++ b/drivers/spi/spi-sirf.c
@@ -409,6 +409,8 @@ spi_sirfsoc_setup_transfer(struct spi_device *spi, struct spi_transfer *t)
rxfifo_ctrl = SIRFSOC_SPI_FIFO_THD(SIRFSOC_SPI_FIFO_SIZE / 2) |
SIRFSOC_SPI_FIFO_WIDTH_DWORD;
break;
+ default:
+ BUG();
}
if (!(spi->mode & SPI_CS_HIGH))
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH] spi: sirf: avoid uninitialized-use warning
2013-06-03 13:24 [PATCH] spi: sirf: avoid uninitialized-use warning Arnd Bergmann
@ 2013-06-03 15:44 ` Stephen Warren
0 siblings, 0 replies; 2+ messages in thread
From: Stephen Warren @ 2013-06-03 15:44 UTC (permalink / raw)
To: linux-arm-kernel
On 06/03/2013 07:24 AM, Arnd Bergmann wrote:
> 24778be20 "spi: convert drivers to use bits_per_word_mask"
> removed the "default" statement in the spi_sirfsoc_setup_transfer
> switch, causing a new warning:
>
> drivers/spi/spi-sirf.c: In function 'spi_sirfsoc_setup_transfer':
> arch/arm/include/asm/io.h:90:2: warning: 'rxfifo_ctrl' may be used uninitialized in this function [-Wmaybe-uninitialized]
> asm volatile("str %1, %0"
> ^
> drivers/spi/spi-sirf.c:364:19: note: 'rxfifo_ctrl' was declared here
> u32 txfifo_ctrl, rxfifo_ctrl;
> ^
>
> The compiler has correctly identified that this case may happen,
> but since we know that things are horribly broken if bits_per_word
> is ever something other than the values we tested, calling BUG()
> is an appropriate action and tells the compiler that execution
> will not continue afterwards.
I guess this is fine, although BUG() seems a little scary, even though
it is a bug.
In some of the other drivers, I converted:
if () {
} else if () {
} else {
error
}
... to:
if () {
} else {
}
... the equivalent of which would be to just add a "default:" to, say,
the 8-bpw case in the switch. But I guess I don't feel too strongly
either way.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-06-03 15:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-03 13:24 [PATCH] spi: sirf: avoid uninitialized-use warning Arnd Bergmann
2013-06-03 15:44 ` Stephen Warren
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.