All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2
@ 2012-08-07 16:58 Tom Rini
  2012-08-07 18:55 ` Wolfgang Denk
  0 siblings, 1 reply; 2+ messages in thread
From: Tom Rini @ 2012-08-07 16:58 UTC (permalink / raw)
  To: u-boot

The above warning was introduced originally in 436da3c "ext2load:
increase read speed" and fixed for newer toolchains in b803273 "ext2fs:
fix warning: 'blocknxt' may be used uninitialized".  This change did not
fix the warning with gcc 4.2, as found in ELDK 4.2.

If we rework the while loop to initalize blocknxt before entering the
warning really goes away.  Tested on am335x with an approx 7mb file and
crc32 in U-Boot befor and after this change.

Cc: Wolfgang Denk <wd@denx.de>
Cc: Eric Nelson <eric.nelson@boundarydevices.com>
Cc: Thierry Reding <thierry.reding@avionic-design.de>
Cc: Jason Cooper <u-boot@lakedaemon.net>
Cc: Andreas Bie?mann <andreas.devel@googlemail.com>
Cc: Reinhard Arlt <reinhard.arlt@esd-electronics.com>
Cc: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Tom Rini <trini@ti.com>
---
 fs/ext2/ext2fs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ext2/ext2fs.c b/fs/ext2/ext2fs.c
index 182f0ac..418404e 100644
--- a/fs/ext2/ext2fs.c
+++ b/fs/ext2/ext2fs.c
@@ -440,9 +440,8 @@ int ext2fs_read_file
 		/* grab middle blocks in one go */
 		if (i != pos / blocksize && i < blockcnt - 1 && blockcnt > 3) {
 			int oldblk = blknr;
-			int blocknxt;
+			int blocknxt = ext2fs_read_block(node, i + 1);
 			while (i < blockcnt - 1) {
-				blocknxt = ext2fs_read_block(node, i + 1);
 				if (blocknxt == (oldblk + 1)) {
 					oldblk = blocknxt;
 					i++;
@@ -450,6 +449,7 @@ int ext2fs_read_file
 					blocknxt = ext2fs_read_block(node, i);
 					break;
 				}
+				blocknxt = ext2fs_read_block(node, i);
 			}
 
 			if (oldblk == blknr)
-- 
1.7.9.5

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

* [U-Boot] [PATCH] ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2
  2012-08-07 16:58 [U-Boot] [PATCH] ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2 Tom Rini
@ 2012-08-07 18:55 ` Wolfgang Denk
  0 siblings, 0 replies; 2+ messages in thread
From: Wolfgang Denk @ 2012-08-07 18:55 UTC (permalink / raw)
  To: u-boot

Dear Tom Rini,

In message <1344358714-14032-1-git-send-email-trini@ti.com> you wrote:
> The above warning was introduced originally in 436da3c "ext2load:
> increase read speed" and fixed for newer toolchains in b803273 "ext2fs:
> fix warning: 'blocknxt' may be used uninitialized".  This change did not
> fix the warning with gcc 4.2, as found in ELDK 4.2.
> 
> If we rework the while loop to initalize blocknxt before entering the
> warning really goes away.  Tested on am335x with an approx 7mb file and
> crc32 in U-Boot befor and after this change.
> 
> Cc: Wolfgang Denk <wd@denx.de>
> Cc: Eric Nelson <eric.nelson@boundarydevices.com>
> Cc: Thierry Reding <thierry.reding@avionic-design.de>
> Cc: Jason Cooper <u-boot@lakedaemon.net>
> Cc: Andreas Bie?mann <andreas.devel@googlemail.com>
> Cc: Reinhard Arlt <reinhard.arlt@esd-electronics.com>
> Cc: Kim Phillips <kim.phillips@freescale.com>
> Signed-off-by: Tom Rini <trini@ti.com>
> ---
>  fs/ext2/ext2fs.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I know engineers. They love to change things.             - Dr. McCoy

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

end of thread, other threads:[~2012-08-07 18:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-08-07 16:58 [U-Boot] [PATCH] ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2 Tom Rini
2012-08-07 18:55 ` Wolfgang Denk

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.