[Ocfs2-tools-devel] [PATCH] libocfs2: avoid assigning a garbage or undefined value

chuanchang.jia at gmail.com chuanchang.jia at gmail.com
Sat Sep 17 19:02:57 PDT 2011


Variable 'blkno' declared without an initial value, the codes are taking true
branch of 'if (dx_root->dr_flags & OCFS2_DX_FLAG_INLINE)' and loop body of 
'for (i = 0; i < entry_list->de_num_used; i++) {', and then entering 
'if (!(dx_root->dr_flags & OCFS2_DX_FLAG_INLINE)) {' true branch, 
'lookup->dl_dx_leaf_blkno' will be assigned a value is garbage or undefined. 

Signed-off-by: Alex Jia <chuanchang.jia at gmail.com>
---
 libocfs2/dir_indexed.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/libocfs2/dir_indexed.c b/libocfs2/dir_indexed.c
index a195ea5..29173c9 100644
--- a/libocfs2/dir_indexed.c
+++ b/libocfs2/dir_indexed.c
@@ -1413,7 +1413,7 @@ errcode_t ocfs2_dx_dir_search(ocfs2_filesys *fs,
 	struct ocfs2_dx_entry *dx_entry;
 	struct ocfs2_dir_entry *dir_ent;
 	uint32_t leaf_cpos;
-	uint64_t blkno;
+	uint64_t blkno = 0;
 	int i, found;
 
 	if (dx_root->dr_flags & OCFS2_DX_FLAG_INLINE)
-- 
1.7.1




More information about the Ocfs2-tools-devel mailing list