public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] spl: mmc: Fix compiler warning
@ 2015-12-05 20:42 Marek Vasut
  2015-12-05 21:02 ` Tom Rini
  0 siblings, 1 reply; 3+ messages in thread
From: Marek Vasut @ 2015-12-05 20:42 UTC (permalink / raw)
  To: u-boot

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.

Signed-off-by: Marek Vasut <marex@denx.de>
Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
---
 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.1.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] spl: mmc: Fix compiler warning
  2015-12-05 20:42 [U-Boot] [PATCH] spl: mmc: Fix compiler warning Marek Vasut
@ 2015-12-05 21:02 ` Tom Rini
  2015-12-05 21:04   ` Marek Vasut
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Rini @ 2015-12-05 21:02 UTC (permalink / raw)
  To: u-boot

On Sat, Dec 05, 2015 at 09:42:35PM +0100, Marek Vasut wrote:

> 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.
> 
> Signed-off-by: Marek Vasut <marex@denx.de>
> Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> Cc: Tom Rini <trini@konsulko.com>
> Cc: Simon Glass <sjg@chromium.org>

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

-- 
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>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH] spl: mmc: Fix compiler warning
  2015-12-05 21:02 ` Tom Rini
@ 2015-12-05 21:04   ` Marek Vasut
  0 siblings, 0 replies; 3+ messages in thread
From: Marek Vasut @ 2015-12-05 21:04 UTC (permalink / raw)
  To: u-boot

On Saturday, December 05, 2015 at 10:02:56 PM, Tom Rini wrote:
> On Sat, Dec 05, 2015 at 09:42:35PM +0100, Marek Vasut wrote:
> > 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.
> > 
> > Signed-off-by: Marek Vasut <marex@denx.de>
> > Cc: Pantelis Antoniou <panto@antoniou-consulting.com>
> > Cc: Tom Rini <trini@konsulko.com>
> > Cc: Simon Glass <sjg@chromium.org>
> 
> 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-12-05 21:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-05 20:42 [U-Boot] [PATCH] spl: mmc: Fix compiler warning Marek Vasut
2015-12-05 21:02 ` Tom Rini
2015-12-05 21:04   ` Marek Vasut

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox