Skip to contentSkip to conversation

/fs/ocfs2/slot_map.c (2.6.35.6): Uninitialized variable

PATCH New Poyo VL 3 participants 3 messages Sep 27, 2010 – Oct 11, 2010 OCFS2

lore
Share & tools
lore

Poyo VL

author
#0 lore raw

PATCH 1/1 /fs/ocfs2/slot_map.c (2.6.35.6): Uninitialized variable

When I tried to compile I got the following warning:
fs/ocfs2/slot_map.c: In function ?ocfs2_init_slot_info?:
fs/ocfs2/slot_map.c:360: warning: ?bytes? may be used uninitialized in this function
fs/ocfs2/slot_map.c:360: note: ?bytes? was declared here
Compiler: gcc version 4.4.3 (GCC) on Mandriva
I'm not sure why this warning occurs, I think compiler don't know that variable "bytes" is initialized when it is sent by reference to ocfs2_slot_map_physical_size and it throws that ugly warning. However, a simple initialization of "bytes" variable with 0 will fix it. Patch is downer, I also attached it because there are problems with Yahoo! Mail.

---

fs/ocfs2/slot_map.c 2010-09-27 22:27:29.342567489 +0300 renamed from fs/ocfs2/slot_map.c 2010-09-27 22:27:07.605568537 +0300 +1 -1
@@ -357,7 +357,7 @@ static int ocfs2_map_slot_buffers(struct
 {
     int status = 0;
     u64 blkno;
-    unsigned long long blocks, bytes;
+    unsigned long long blocks, bytes = 0;
     unsigned int i;
     struct buffer_head *bh;
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.diff
Type: application/octet-stream
Size: 341 bytes
Desc: not available
Url : http://oss.oracle.com/pipermail/ocfs2-devel/attachments/20100927/b34b17b6/attachment.obj

#1 lore raw

PATCH 1/1 /fs/ocfs2/slot_map.c (2.6.35.6): Uninitialized variable

Quoted 12 lines · Poyo VL

When I tried to compile I got the following warning:
fs/ocfs2/slot_map.c: In function ?ocfs2_init_slot_info?:
fs/ocfs2/slot_map.c:360: warning: ?bytes? may be used uninitialized in this function
fs/ocfs2/slot_map.c:360: note: ?bytes? was declared here
Compiler: gcc version 4.4.3 (GCC) on Mandriva
I'm not sure why this warning occurs, I think compiler don't know that variable "bytes" is initialized when it is sent by reference to ocfs2_slot_map_physical_size and it throws that ugly warning. However, a simple initialization of "bytes" variable with 0 will fix it. Patch is downer, I also attached it because there are problems with Yahoo! Mail.

Quoted 1 line

This looks reasonable, though using uninitialized_var() might be the preferred method.

--
Mark Fasheh

#2 lore raw

PATCH 1/1 /fs/ocfs2/slot_map.c (2.6.35.6): Uninitialized variable

In reply to Poyo VL
Quoted 12 lines · Poyo VL

When I tried to compile I got the following warning:
fs/ocfs2/slot_map.c: In function ?ocfs2_init_slot_info?:
fs/ocfs2/slot_map.c:360: warning: ?bytes? may be used uninitialized in this function
fs/ocfs2/slot_map.c:360: note: ?bytes? was declared here
Compiler: gcc version 4.4.3 (GCC) on Mandriva
I'm not sure why this warning occurs, I think compiler don't know that variable "bytes" is initialized when it is sent by reference to ocfs2_slot_map_physical_size and it throws that ugly warning. However, a simple initialization of "bytes" variable with 0 will fix it. Patch is downer, I also attached it because there are problems with Yahoo! Mail.

Quoted 1 line

This patch is now in the merge-window branch of ocfs2.git. In
the future, please send patches inline without MIME.

Joel

Signature · 11 lines
"The lawgiver, of all beings, most owes the law allegiance.  He of all
 men should behave as though the law compelled him.  But it is the
 universal weakness of mankind that what we are given to administer we
 presently imagine we own."
        - H.G. Wells

Joel Becker
Consulting Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127