diff mbox

[U-Boot,v2,1/3] spl: mmc: Fix compiler warning with CONFIG_DM_MMC

Message ID 1449016560-3740-2-git-send-email-sjg@chromium.org
State Superseded
Headers show

Commit Message

Simon Glass Dec. 2, 2015, 12:35 a.m. UTC
Since commit 4188ba3 we get the following warning on rockchip boards:

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;

Correct this by move the variable init earlier.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v2:
- Fix the warning in the commit message (it was the wrong one)

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

Patch

diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c
index b3c2c64..9df4786 100644
--- a/common/spl/spl_mmc.c
+++ b/common/spl/spl_mmc.c
@@ -84,6 +84,7 @@  static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 	struct udevice *dev;
 	int err, mmc_dev;
 
+	*mmc = NULL;
 	mmc_dev = spl_mmc_get_device_index(boot_device);
 	if (mmc_dev < 0)
 		return mmc_dev;
@@ -104,7 +105,6 @@  static int spl_mmc_find_device(struct mmc **mmc, u32 boot_device)
 		return err;
 	}
 
-	*mmc = NULL;
 	*mmc = mmc_get_mmc_dev(dev);
 	return *mmc != NULL ? 0 : -ENODEV;
 }