[U-Boot] [PATCH v2] fsl: sys_eeprom: Fix 'may be used uninitialized' warning

Anton Vorontsov avorontsov at ru.mvista.com
Wed Sep 2 00:17:24 CEST 2009


The warning is bogus, so silence it by initializing the 'ret' variable.

Signed-off-by: Anton Vorontsov <avorontsov at ru.mvista.com>
---

On Tue, Sep 01, 2009 at 09:27:37PM +0200, Wolfgang Denk wrote:
> Dear Anton Vorontsov,
> 
> In message <20090901182518.GA17903 at oksana.dev.rtsoft.ru> you wrote:
> >
> > We can fix the warnings by assigning some value to a variable
> > at declaration, but the advantage of 'x = x' trick is that it
> > doesn't generate any code.
> 
> Argh... what a clev^H^H^H^Hdirty trick.
> 
> Thanks for the explanation.
> 
> However, in this case it seems to make sense to me to explicitly
> initialize the return code with zero.

Well, I don't see any advantages of this, but here it is anyway.

Thanks.

p.s. Timur, since the patch has changed, I couldn't preserve your
     previous Ack.

 board/freescale/common/sys_eeprom.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/board/freescale/common/sys_eeprom.c b/board/freescale/common/sys_eeprom.c
index c0fff68..661015e 100644
--- a/board/freescale/common/sys_eeprom.c
+++ b/board/freescale/common/sys_eeprom.c
@@ -204,7 +204,8 @@ static void update_crc(void)
  */
 static int prog_eeprom(void)
 {
-	int ret, i;
+	int ret = 0; /* shut up gcc */
+	int i;
 	void *p;
 #ifdef CONFIG_SYS_EEPROM_BUS_NUM
 	unsigned int bus;
-- 
1.6.3.3



More information about the U-Boot mailing list