xfs_db: fix inverted logic in error path
PATCH 1/1 xfs_db: fix inverted logic in error path
From: Darrick J. Wong <[email protected]>
smatch complains proceeding into the if body if leaf is a null pointer. This is backwards, so correct that.
check.c:3455 process_leaf_node_dir_v2_int() warn: variable dereferenced before check 'leaf'
--- db/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
db/check.c +1 -1
@@ -3452,7 +3452,7 @@ process_leaf_node_dir_v2_int( id->ino, dabno, stale, be16_to_cpu(leaf3->hdr.stale)); error++; - }else if (!leaf && stale !=be16_to_cpu (leaf->hdr.stale)) { + }else if (leaf && stale !=be16_to_cpu (leaf->hdr.stale)) {if (!sflag || v) dbprintf(_("dir %lld block %d stale mismatch " "%d/%d\n"),
Quoted 17 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
smatch complains proceeding into the if body if leaf is a null pointer. This is backwards, so correct that.
check.c:3455
process_leaf_node_dir_v2_int()warn: variable dereferenced before check 'leaf'Signed-off-by Darrick J. Wong <[email protected]>--- db/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)db/check.c +0
-0
db/check.c process_leaf_node_dir_v2_int( · line 3458
Quoted 8 lines
db/check.c +1
-1@@ -3452,7 +3452,7 @@ process_leaf_node_dir_v2_int( id->ino, dabno, stale, be16_to_cpu(leaf3->hdr.stale)); error++; - }else if (!leaf && stale !=be16_to_cpu (leaf->hdr.stale)) { + }else if (leaf && stale !=be16_to_cpu (leaf->hdr.stale)) {if (!sflag || v) dbprintf(_("dir %lld block %d stale mismatch " "%d/%d\n"),
Looks good. I'm surprised the compiler didn't warn about this obviously broken code...
Signature · 2 lines
Dave Chinner [email protected]
Darrick J. Wong
NAKQuoted 30 lines · Dave Chinner
Quoted 17 lines · Darrick J. Wong
From: Darrick J. Wong <[email protected]>
smatch complains proceeding into the if body if leaf is a null pointer. This is backwards, so correct that.
check.c:3455
process_leaf_node_dir_v2_int()warn: variable dereferenced before check 'leaf'Signed-off-by Darrick J. Wong <[email protected]>--- db/check.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)db/check.c +0
-0db/check.c process_leaf_node_dir_v2_int( · line 3458
Quoted 8 lines
db/check.c +1
-1@@ -3452,7 +3452,7 @@ process_leaf_node_dir_v2_int( id->ino, dabno, stale, be16_to_cpu(leaf3->hdr.stale)); error++; - }else if (!leaf && stale !=be16_to_cpu (leaf->hdr.stale)) { + }else if (leaf && stale !=be16_to_cpu (leaf->hdr.stale)) {if (!sflag || v) dbprintf(_("dir %lld block %d stale mismatch " "%d/%d\n"),Looks good. I'm surprised the compiler didn't warn about this obviously broken code...
Quoted 1 line
Reviewed-by Dave Chinner <[email protected]>
NAK, this logic is actually trying to switch between the V4 and V5 directory format logic, but it's using the subtlety that @leaf3 is a
null pointer for a V4 fs and non-null for a V5 fs. Hence this check
really should be:
} else if (!leaf3 && stale != be16_to_cpu(leaf->hdr.stale)) {Even though that looks *totally* wrong. But xfs_check is deprecated, so fmeh.
So I'll go fix that and rerun through testing. I had thought this was fine, but xfs/291 barfed up errors overnight.
--D
Quoted 3 lines
Signature · 2 lines
Dave Chinner [email protected]