[U-Boot] [PATCH 2/7] spl: mmc: Explicitly init mmc struct

Sjoerd Simons sjoerd.simons at collabora.co.uk
Fri Dec 4 23:27:36 CET 2015


gcc fails to work out that the mmc variable will only ever be used if it
has been initialized by spl_mmc_get_device_index and throws the
following error:

common/spl/spl_mmc.c: In function ‘spl_mmc_load_image’:
common/spl/spl_mmc.c:31:24: warning: ‘mmc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  count = mmc->block_dev.block_read(0, sector, 1, header);
                        ^
common/spl/spl_mmc.c:251:14: note: ‘mmc’ was declared here
  struct mmc *mmc;

Prevent this by explicitly initializing the variable.

Signed-off-by: Sjoerd Simons <sjoerd.simons at collabora.co.uk>
---

 common/spl/spl_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index b3c2c64..43748d0 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -248,7 +248,7 @@ int spl_mmc_do_fs_boot(struct mmc *mmc)
 
 int spl_mmc_load_image(u32 boot_device)
 {
-	struct mmc *mmc;
+	struct mmc *mmc = NULL;
 	u32 boot_mode;
 	int err = 0;
 	__maybe_unused int part;
-- 
2.6.2



More information about the U-Boot mailing list