ocfs2: Fix 2 warning during ocfs2 make.
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data type
--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/ocfs2/dir.c +1 -1
@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir,u32 *num_dx_entries, struct buffer_head *dirent_bh) { - int ret, namelen, i; + int ret = 0, namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;
fs/ocfs2/suballoc.c +1 -1
@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } -if (le16_to_cpu (inode_fe->i_suballoc_slot) !=OCFS2_INVALID_SLOT && +if (le16_to_cpu (inode_fe->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && (u32 )le16_to_cpu (inode_fe->i_suballoc_slot) > osb->max_slots -1 ) {mlog (ML_ERROR ,"inode %llu has invalid suballoc slot %u\n" , blkno, (u32 )le16_to_cpu (inode_fe->i_suballoc_slot));
Signature · 1 line
1.6.2.rc2.16.gf474c
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
Hi Tao,
I think for the OCFS2_INVALID_SLOT problem,
define OCFS2_INVALID_SLOT as (u16)-1 is better. so that we needn't force convert type wherever it's used.
ocfs2/ocfs2_fs.h.1 2009-03-19 14:24:18.000000000 +0800 renamed from ocfs2/ocfs2_fs.h 2009-02-18 19:58:02.000000000 +0800 +1 -1
@@ -303,7 +303,7 @@ struct ocfs2_new_group_input { #define OCFS2_MAX_SLOTS 255 /* Slot map indicator for an empty slot */ -#define OCFS2_INVALID_SLOT -1 +#define OCFS2_INVALID_SLOT (u16)-1 #define OCFS2_VOL_UUID_LEN 16 #define OCFS2_MAX_VOL_LABEL_LEN 64
I didn't paste the part for removing force type converting.
thanks,
wengang.
Quoted 38 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeSigned-off-by Tao Ma <[email protected]>--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/dir.c +1
-1@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir,u32 *num_dx_entries, struct buffer_head *dirent_bh) { - int ret, namelen, i; + int ret = 0, namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;fs/ocfs2/suballoc.c +1
-1@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } -if (le16_to_cpu (inode_fe->i_suballoc_slot) !=OCFS2_INVALID_SLOT && +if (le16_to_cpu (inode_fe->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && (u32 )le16_to_cpu (inode_fe->i_suballoc_slot) > osb->max_slots -1 ) {mlog (ML_ERROR ,"inode %llu has invalid suballoc slot %u\n" , blkno, (u32 )le16_to_cpu (inode_fe->i_suballoc_slot));
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
while, the slot is type of u32 in for functions...
Quoted 68 lines · Wengang Wang
Hi Tao,
I think for the
OCFS2_INVALID_SLOTproblem,
defineOCFS2_INVALID_SLOTas (u16)-1 is better. so that we needn't force convert type wherever it's used.ocfs2/ocfs2_fs.h.1 2009-03-19 14:24:18.000000000 +0800 renamed from ocfs2/ocfs2_fs.h 2009-02-18 19:58:02.000000000 +0800 +1
-1@@ -303,7 +303,7 @@ struct ocfs2_new_group_input { #define OCFS2_MAX_SLOTS 255 /* Slot map indicator for an empty slot */ -#define OCFS2_INVALID_SLOT -1 +#define OCFS2_INVALID_SLOT (u16)-1 #define OCFS2_VOL_UUID_LEN 16 #define OCFS2_MAX_VOL_LABEL_LEN 64I didn't paste the part for removing force type converting.
thanks,
wengang.Quoted 30 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeSigned-off-by Tao Ma <[email protected]>--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/dir.c +1
-1@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir,u32 *num_dx_entries, struct buffer_head *dirent_bh) { - int ret, namelen, i; + int ret = 0, namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;fs/ocfs2/suballoc.c +0
-0fs/ocfs2/suballoc.c static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, · line 2219
Quoted 8 lines
fs/ocfs2/suballoc.c +1
-1@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } -if (le16_to_cpu (inode_fe->i_suballoc_slot) !=OCFS2_INVALID_SLOT && +if (le16_to_cpu (inode_fe->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && (u32 )le16_to_cpu (inode_fe->i_suballoc_slot) > osb->max_slots -1 ) {mlog (ML_ERROR ,"inode %llu has invalid suballoc slot %u\n" , blkno, (u32 )le16_to_cpu (inode_fe->i_suballoc_slot));_______________________________________________
Ocfs2-devel mailing list
Ocfs2-devel at oss.oracle.com
http://oss.oracle.com/mailman/listinfo/ocfs2-devel
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
In reply to Wengang WangHi wengang,
Quoted 5 lines · Wengang Wang
Hi Tao,
I think for the
OCFS2_INVALID_SLOTproblem,
defineOCFS2_INVALID_SLOTas (u16)-1 is better. so that we needn't force convert type wherever it's used.
I just copy/paste and do like others. Seefs/ocfs2/slot_map.c: if (le16_to_cpu(sm->sm_slots[i]) ==
(u16)OCFS2_INVALID_SLOT)
And after I searched again, I guess we can't do that. look at fs/ocfs2/super.c.osb->slot_num = OCFS2_INVALID_SLOT;slot_num is defined as int. So your definition will break the rule. and make slot_num=65535.
Regards,
Tao
Quoted 64 lines
ocfs2/ocfs2_fs.h.1 2009-03-19 14:24:18.000000000 +0800 renamed from ocfs2/ocfs2_fs.h 2009-02-18 19:58:02.000000000 +0800 +1
-1@@ -303,7 +303,7 @@ struct ocfs2_new_group_input { #define OCFS2_MAX_SLOTS 255 /* Slot map indicator for an empty slot */ -#define OCFS2_INVALID_SLOT -1 +#define OCFS2_INVALID_SLOT (u16)-1 #define OCFS2_VOL_UUID_LEN 16 #define OCFS2_MAX_VOL_LABEL_LEN 64I didn't paste the part for removing force type converting.
thanks,
wengang.Quoted 44 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeSigned-off-by Tao Ma <[email protected]>--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/dir.c +1
-1@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir, u32 *num_dx_entries, struct buffer_head *dirent_bh) { -int ret, namelen, i; +int ret =0 , namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;fs/ocfs2/suballoc.c +1
-1@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } - if (le16_to_cpu(inode_fe->i_suballoc_slot) != OCFS2_INVALID_SLOT && + if (le16_to_cpu(inode_fe->i_suballoc_slot) !=(u16)OCFS2_INVALID_SLOT &&
(u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots- 1) {
mlog(ML_ERROR, "inode %llu has invalid suballoc slot %u\n",
blkno, (u32)le16_to_cpu(inode_fe->i_suballoc_slot));
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
yes, that's the problem.
we'd better unify the different types(but could be another patch). since the on disk is u16, modifying other types to u16 is fine :)
thanks,
wengang.
Quoted 84 lines · Tao Ma
Hi wengang,
Quoted 5 lines · Wengang Wang
Hi Tao,
I think for the
OCFS2_INVALID_SLOTproblem,
defineOCFS2_INVALID_SLOTas (u16)-1 is better. so that we needn't force convert type wherever it's used.I just copy/paste and do like others. See
fs/ocfs2/slot_map.c: if (le16_to_cpu(sm->sm_slots[i])==
(u16)OCFS2_INVALID_SLOT)And after I searched again, I guess we can't do that. look at
fs/ocfs2/super.c.osb->slot_num=OCFS2_INVALID_SLOT;slot_numis defined as int. So your definition will break the rule. and make slot_num=65535.Regards,
TaoQuoted 64 lines
ocfs2/ocfs2_fs.h.1 2009-03-19 14:24:18.000000000 +0800 renamed from ocfs2/ocfs2_fs.h 2009-02-18 19:58:02.000000000 +0800 +1
-1@@ -303,7 +303,7 @@ struct ocfs2_new_group_input { #define OCFS2_MAX_SLOTS 255 /* Slot map indicator for an empty slot */ -#define OCFS2_INVALID_SLOT -1 +#define OCFS2_INVALID_SLOT (u16)-1 #define OCFS2_VOL_UUID_LEN 16 #define OCFS2_MAX_VOL_LABEL_LEN 64I didn't paste the part for removing force type converting.
thanks,
wengang.Quoted 44 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeSigned-off-by Tao Ma <[email protected]>--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/dir.c +1
-1@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir, u32 *num_dx_entries, struct buffer_head *dirent_bh) { -int ret, namelen, i; +int ret =0 , namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;fs/ocfs2/suballoc.c +1
-1@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } - if (le16_to_cpu(inode_fe->i_suballoc_slot) != OCFS2_INVALID_SLOT && + if (le16_to_cpu(inode_fe->i_suballoc_slot) !=(u16)OCFS2_INVALID_SLOT &&
(u32)le16_to_cpu(inode_fe->i_suballoc_slot) > osb->max_slots- 1) {
mlog(ML_ERROR, "inode %llu has invalid suballoc slot %u\n",
blkno, (u32)le16_to_cpu(inode_fe->i_suballoc_slot));
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
Quoted 3 lines · Wengang Wang
yes, that's the problem.
we'd better unify the different types(but could be another patch). since the on disk is u16, modifying other types to u16 is fine :)
The -1 is a special value, and it isn't always a u16 we're
talking about. This is both historical code and on-disk values. INVALID_SLOT isn't 65535, it's -1. You have to have the comparisons as they currently stand, with the casts.
Joel
Signature · 9 lines
"Any man who is under 30, and is not a liberal, has not heart;
and any man who is over 30, and is not a conservative, has no brains."
- Sir Winston Churchill
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
In reply to Tao MaQuoted 7 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeSigned-off-by Tao Ma <[email protected]>
Good catch. Both are bugs, and both are correctly fixed.
Quoted 39 lines
--- fs/ocfs2/dir.c | 2 +- fs/ocfs2/suballoc.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)fs/ocfs2/dir.c +1
-1@@ -2697,7 +2697,7 @@ static int ocfs2_dx_dir_index_block(struct inode *dir,u32 *num_dx_entries, struct buffer_head *dirent_bh) { - int ret, namelen, i; + int ret = 0, namelen, i;char *de_buf, *limit;struct ocfs2_dir_entry *de;struct buffer_head *dx_leaf_bh;fs/ocfs2/suballoc.c +1
-1@@ -2213,7 +2213,7 @@ static int ocfs2_get_suballoc_slot_bit(struct ocfs2_super *osb, u64 blkno, goto bail; } -if (le16_to_cpu (inode_fe->i_suballoc_slot) !=OCFS2_INVALID_SLOT && +if (le16_to_cpu (inode_fe->i_suballoc_slot) != (u16 )OCFS2_INVALID_SLOT && (u32 )le16_to_cpu (inode_fe->i_suballoc_slot) > osb->max_slots -1 ) {mlog (ML_ERROR ,"inode %llu has invalid suballoc slot %u\n" , blkno, (u32 )le16_to_cpu (inode_fe->i_suballoc_slot));Signature · 7 lines
1.6.2.rc2.16.gf474c _______________________________________________ Ocfs2-devel mailing list Ocfs2-devel at oss.oracle.com http://oss.oracle.com/mailman/listinfo/ocfs2-devel
Signature · 7 lines
Pitchers and catchers report. Joel Becker Principal Software Developer Oracle E-mail: joel.becker at oracle.com Phone: (650) 506-8127
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
In reply to Tao MaQuoted 5 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data type
Does the 2nd bug still exist in merge_window? I didn't see it, so I just merged the 1st one into merge_window.
--Mark
--
Mark Fasheh
PATCH 1/1 ocfs2: Fix 2 warning during ocfs2 make.
Hi Mark,
I saw this in your upstream-merge_window. And I compared it with yourmerge_window, the upstream one has more patches than the other, it looks like the branch you mentioned in "Ocfs2 updates for 2.6.30". The bug is found there.
Regards,
Tao
Quoted 14 lines · Mark Fasheh
Quoted 5 lines · Tao Ma
fs/ocfs2/dir.c: In function ?ocfs2_extend_dir?:fs/ocfs2/dir.c:2700: warning: ?ret? may be used uninitialized in this function
fs/ocfs2/suballoc.c: In function ?ocfs2_get_suballoc_slot_bit?:fs/ocfs2/suballoc.c:2216: warning: comparison is always true due to limited range of data typeDoes the 2nd bug still exist in
merge_window? I didn't see it, so I just merged the 1st one intomerge_window.--Mark--
Mark Fasheh