All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] env: suppress a spurious warning with GCC 7.1
@ 2017-11-21 22:29 Philipp Tomsich
  2017-11-24 22:36 ` Simon Glass
  2017-11-30 15:36 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 3+ messages in thread
From: Philipp Tomsich @ 2017-11-21 22:29 UTC (permalink / raw)
  To: u-boot

GCC 7.1 seems to be smart enough to track val through the various
static inline functions, but not smart enough to see that val will
always be initialised when no error is returned.  This triggers
the following warning:
  env/mmc.c: In function 'mmc_get_env_addr':
  env/mmc.c:121:12: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]

To make it easier for compiler to understand what is going on, let's
initialise val.

Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
---

 env/mmc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/env/mmc.c b/env/mmc.c
index 3343f9e..ed7bcf1 100644
--- a/env/mmc.c
+++ b/env/mmc.c
@@ -73,7 +73,7 @@ static inline s64 mmc_offset(int copy)
 		.partition = "u-boot,mmc-env-partition",
 		.offset = "u-boot,mmc-env-offset",
 	};
-	s64 val, defvalue;
+	s64 val = 0, defvalue;
 	const char *propname;
 	const char *str;
 	int err;
-- 
2.1.4

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

* [U-Boot] [PATCH] env: suppress a spurious warning with GCC 7.1
  2017-11-21 22:29 [U-Boot] [PATCH] env: suppress a spurious warning with GCC 7.1 Philipp Tomsich
@ 2017-11-24 22:36 ` Simon Glass
  2017-11-30 15:36 ` [U-Boot] " Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2017-11-24 22:36 UTC (permalink / raw)
  To: u-boot

On 21 November 2017 at 15:29, Philipp Tomsich
<philipp.tomsich@theobroma-systems.com> wrote:
> GCC 7.1 seems to be smart enough to track val through the various
> static inline functions, but not smart enough to see that val will
> always be initialised when no error is returned.  This triggers
> the following warning:
>   env/mmc.c: In function 'mmc_get_env_addr':
>   env/mmc.c:121:12: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
>
> To make it easier for compiler to understand what is going on, let's
> initialise val.
>
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> ---
>
>  env/mmc.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

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

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

* [U-Boot] env: suppress a spurious warning with GCC 7.1
  2017-11-21 22:29 [U-Boot] [PATCH] env: suppress a spurious warning with GCC 7.1 Philipp Tomsich
  2017-11-24 22:36 ` Simon Glass
@ 2017-11-30 15:36 ` Tom Rini
  1 sibling, 0 replies; 3+ messages in thread
From: Tom Rini @ 2017-11-30 15:36 UTC (permalink / raw)
  To: u-boot

On Tue, Nov 21, 2017 at 11:29:40PM +0100, Philipp Tomsich wrote:

> GCC 7.1 seems to be smart enough to track val through the various
> static inline functions, but not smart enough to see that val will
> always be initialised when no error is returned.  This triggers
> the following warning:
>   env/mmc.c: In function 'mmc_get_env_addr':
>   env/mmc.c:121:12: warning: 'val' may be used uninitialized in this function [-Wmaybe-uninitialized]
> 
> To make it easier for compiler to understand what is going on, let's
> initialise val.
> 
> Signed-off-by: Philipp Tomsich <philipp.tomsich@theobroma-systems.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20171130/311a37cb/attachment.sig>

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

end of thread, other threads:[~2017-11-30 15:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-21 22:29 [U-Boot] [PATCH] env: suppress a spurious warning with GCC 7.1 Philipp Tomsich
2017-11-24 22:36 ` Simon Glass
2017-11-30 15:36 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.