From mboxrd@z Thu Jan 1 00:00:00 1970 From: Anton Vorontsov Date: Tue, 1 Sep 2009 21:38:14 +0400 Subject: [U-Boot] [PATCH 2/2] fsl: sys_eeprom: Fix 'may be used uninitialized' warning In-Reply-To: <607BBB57-C4BD-4E89-A70D-7AD1A8109F5C@kernel.crashing.org> References: <20090901165902.GA6435@oksana.dev.rtsoft.ru> <607BBB57-C4BD-4E89-A70D-7AD1A8109F5C@kernel.crashing.org> Message-ID: <20090901173814.GA4471@oksana.dev.rtsoft.ru> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Tue, Sep 01, 2009 at 12:30:53PM -0500, Kumar Gala wrote: > > On Sep 1, 2009, at 11:59 AM, Anton Vorontsov wrote: > > >The warning is bogus, so silence it with uninitialized_var(). > > > >Signed-off-by: Anton Vorontsov > >--- > >board/freescale/common/sys_eeprom.c | 4 +++- > >1 files changed, 3 insertions(+), 1 deletions(-) > > > >diff --git a/board/freescale/common/sys_eeprom.c > >b/board/freescale/common/sys_eeprom.c > >index c0fff68..a765b39 100644 > >--- a/board/freescale/common/sys_eeprom.c > >+++ b/board/freescale/common/sys_eeprom.c > >@@ -24,6 +24,7 @@ > > */ > > > >#include > >+#include > >#include > >#include > >#include > >@@ -204,7 +205,8 @@ static void update_crc(void) > > */ > >static int prog_eeprom(void) > >{ > >- int ret, i; > >+ int uninitialized_var(ret); > >+ int i; > > why don't we init ret = 0; seems like we should be doing that since > we might not enter the for loop No, we always enter the for loop: for (i = 0, p = &e; i < sizeof(e); i += 8, p += 8) { sizeof(e) always > 0 because: #if !defined(CONFIG_SYS_I2C_EEPROM_CCID) && !defined(CONFIG_SYS_I2C_EEPROM_NXID) #error "Please define either CONFIG_SYS_I2C_EEPROM_CCID or CONFIG_SYS_I2C_EEPROM_NXID" #endif static struct __attribute__ ((__packed__)) eeprom { #ifdef CONFIG_SYS_I2C_EEPROM_CCID u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'CCID' */ ... #endif #ifdef CONFIG_SYS_I2C_EEPROM_NXID u8 id[4]; /* 0x00 - 0x03 EEPROM Tag 'NXID' */ ... #endif } e; -- Anton Vorontsov email: cbouatmailru at gmail.com irc://irc.freenode.net/bd2