Skip to contentSkip to conversation

spl: mmc: Fix compiler warning

PATCH New Marek Vasut 2 participants 3 messages Dec 5, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spl: mmc: Fix compiler warning

Fix the following warning:
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;
              ^

The fix is as simple as initializing the struct mmc *mmc to NULL, so the subsequent functions can check if the variable is set or not.

Cc Pantelis Antoniou <[email protected]>
Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>
---
 common/spl/spl_mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/spl/spl_mmc.c +1 -1
index b3c2c64..43748d0 100644
@@ -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;
Signature · 1 line
2.1.4
#1 lore raw

PATCH 1/1 spl: mmc: Fix compiler warning

Quoted 9 lines · Marek Vasut

Fix the following warning:
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;
              ^
Quoted 8 lines

The fix is as simple as initializing the struct mmc *mmc to NULL, so the subsequent functions can check if the variable is set or not.

Cc Pantelis Antoniou <[email protected]>
Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>

I'm glad we're all grabbing gcc-5.x now. I am however going to grab Simon's patch for this shortly. Thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20151205/cc892d72/attachment.sig>
#2 lore raw

PATCH 1/1 spl: mmc: Fix compiler warning

Quoted 20 lines · Tom Rini
Quoted 19 lines · Marek Vasut

Fix the following warning:
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;

              ^

The fix is as simple as initializing the struct mmc *mmc to NULL, so the subsequent functions can check if the variable is set or not.

Quoted 7 lines
Quoted 4 lines
Cc Pantelis Antoniou <[email protected]>
Cc Tom Rini <[email protected]>
Cc Simon Glass <[email protected]>

I'm glad we're all grabbing gcc-5.x now. I am however going to grab Simon's patch for this shortly. Thanks!

This popped up with gcc 4.9 though ;-)
Thanks anyway.

Best regards,
Marek Vasut