Skip to contentSkip to conversation

ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2

PATCH New Tom Rini 2 participants 2 messages Aug 7, 2012 ext2 file system

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH 1/1 ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2

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 <[email protected]>
Cc Eric Nelson <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Andreas Bie?mann <[email protected]>
Cc Reinhard Arlt <[email protected]>
Cc Kim Phillips <[email protected]>
---
 fs/ext2/ext2fs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
fs/ext2/ext2fs.c +2 -2
index 182f0ac..418404e 100644
@@ -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)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH 1/1 ext2fs: fix warning: 'blocknxt' may be used uninitialized with gcc 4.2

Dear Tom Rini,

Quoted 17 lines · In message <[email protected]> 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 <[email protected]>
Cc Eric Nelson <[email protected]>
Cc Thierry Reding <[email protected]>
Cc Jason Cooper <[email protected]>
Cc Andreas Bie?mann <[email protected]>
Cc Reinhard Arlt <[email protected]>
Cc Kim Phillips <[email protected]>
Quoted 3 lines
---
 fs/ext2/ext2fs.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk

Signature · 4 lines
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