[PATCH] spi: fsl-lpspi: Pre-initialize ret in fsl_lpspi_transfer_one_msg()

From: Geert Uytterhoeven
Date: Wed Dec 14 2016 - 06:20:55 EST


With gcc 4.1.2:

drivers/spi/spi-fsl-lpspi.c: In function âfsl_lpspi_transfer_one_msgâ:
drivers/spi/spi-fsl-lpspi.c:369: warning: âretâ may be used uninitialized in this function

If the message contains no transfers, the function will set the
message's status to an uninitialized value, and will return that
uninitialized value.

While __spi_validate() should have been called in all paths leading to
this, and thus have rejected such messages, we better pre-initialize ret
to be safe for future modifications (spi_transfer_one_message() also
does this).

Signed-off-by: Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>
Signed-off-by: Mark Brown <broonie@xxxxxxxxxx>
---
drivers/spi/spi-fsl-lpspi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 52551f6d0c7d..2b93bc605b91 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -366,7 +366,7 @@ static int fsl_lpspi_transfer_one_msg(struct spi_master *master,
struct spi_transfer *xfer;
bool is_first_xfer = true;
u32 temp;
- int ret;
+ int ret = 0;

msg->status = 0;
msg->actual_length = 0;
--
2.11.0