Skip to contentSkip to conversation

do not test return value of xfs_bmap_*_count_leaves

PATCH In review Ruben Porras 2 participants 3 messages Mar 28, 2008 – Apr 4, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 do not test return value of xfs_bmap_*_count_leaves

These functions, xfs_bmap_count_leaves and xfs_bmap_disk_count_leaves, return always 0. Therefore it is not necessary to test the return value.

Regards

Index: fs/xfs/xfs_bmap.c
===================================================================
RCS file: /cvs/linux-2.6-xfs/fs/xfs/xfs_bmap.c,v
retrieving revision 1.383

xfs/xfs_bmap.c +3 -13
diff -u -r1.383 xfs_bmap.c
@@ -6361,13 +6361,9 @@
 	mp = ip->i_mount;
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
-		if (unlikely(xfs_bmap_count_leaves(ifp, 0,
+		xfs_bmap_count_leaves(ifp, 0,
 			ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
-			count) < 0)) {
-			XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)",
-					 XFS_ERRLEVEL_LOW, mp);
-			return XFS_ERROR(EFSCORRUPTED);
-		}
+			count);
 		return 0;
 	}
 
@@ -6448,13 +6444,7 @@
 		for (;;) {
 			nextbno = be64_to_cpu(block->bb_rightsib);
 			numrecs = be16_to_cpu(block->bb_numrecs);
-			if (unlikely(xfs_bmap_disk_count_leaves(0,
-					block, numrecs, count) < 0)) {
-				xfs_trans_brelse(tp, bp);
-				XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
-						 XFS_ERRLEVEL_LOW, mp);
-				return XFS_ERROR(EFSCORRUPTED);
-			}
+			xfs_bmap_disk_count_leaves(0, block, numrecs, count);
 			xfs_trans_brelse(tp, bp);
 			if (nextbno == NULLFSBLOCK)
 				break;
#1 lore raw
Quoted 2 lines · Ruben Porras

These functions, xfs_bmap_count_leaves and xfs_bmap_disk_count_leaves, return always 0. Therefore it is not necessary to test the return value.

If it always returns 0, why not make it void?

Josef 'Jeff' Sipek.

Signature · 2 lines
Hegh QaQ law'
quvHa'ghach QaQ puS
#2 lore raw

Am Freitag, den 28.03.2008, 11:46 -0400 schrieb Josef 'Jeff' Sipek:

Quoted 5 lines · Ruben Porras
Quoted 2 lines

These functions, xfs_bmap_count_leaves and xfs_bmap_disk_count_leaves, return always 0. Therefore it is not necessary to test the return value.

If it always returns 0, why not make it void?

better, patch attached.

Signature · 6 lines
Rubén Porras Campo
Telekommunikation Engineer

LinWorks GmbH
Robert-Koch-Straße 9; 64331 Weiterstadt
http://www.linworks.de

Index: fs/xfs/xfs_bmap.c
===================================================================
RCS file: /cvs/linux-2.6-xfs/fs/xfs/xfs_bmap.c,v
retrieving revision 1.387

xfs/xfs_bmap.c +5 -17
diff -u -r1.387 xfs_bmap.c
@@ -6356,13 +6356,9 @@
 	mp = ip->i_mount;
 	ifp = XFS_IFORK_PTR(ip, whichfork);
 	if ( XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_EXTENTS ) {
-		if (unlikely(xfs_bmap_count_leaves(ifp, 0,
+		xfs_bmap_count_leaves(ifp, 0,
 			ifp->if_bytes / (uint)sizeof(xfs_bmbt_rec_t),
-			count) < 0)) {
-			XFS_ERROR_REPORT("xfs_bmap_count_blocks(1)",
-					 XFS_ERRLEVEL_LOW, mp);
-			return XFS_ERROR(EFSCORRUPTED);
-		}
+			count);
 		return 0;
 	}
 
@@ -6443,13 +6439,7 @@
 		for (;;) {
 			nextbno = be64_to_cpu(block->bb_rightsib);
 			numrecs = be16_to_cpu(block->bb_numrecs);
-			if (unlikely(xfs_bmap_disk_count_leaves(0,
-					block, numrecs, count) < 0)) {
-				xfs_trans_brelse(tp, bp);
-				XFS_ERROR_REPORT("xfs_bmap_count_tree(2)",
-						 XFS_ERRLEVEL_LOW, mp);
-				return XFS_ERROR(EFSCORRUPTED);
-			}
+			xfs_bmap_disk_count_leaves(0, block, numrecs, count);
 			xfs_trans_brelse(tp, bp);
 			if (nextbno == NULLFSBLOCK)
 				break;
@@ -6467,7 +6457,7 @@
 /*
  * Count leaf blocks given a range of extent records.
  */
-STATIC int
+STATIC void
 xfs_bmap_count_leaves(
 	xfs_ifork_t		*ifp,
 	xfs_extnum_t		idx,
@@ -6480,14 +6470,13 @@
 		xfs_bmbt_rec_host_t *frp = xfs_iext_get_ext(ifp, idx + b);
 		*count += xfs_bmbt_get_blockcount(frp);
 	}
-	return 0;
 }
 
 /*
  * Count leaf blocks given a range of extent records originally
  * in btree format.
  */
-STATIC int
+STATIC void
 xfs_bmap_disk_count_leaves(
 	xfs_extnum_t		idx,
 	xfs_bmbt_block_t	*block,
@@ -6501,5 +6490,4 @@
 		frp = XFS_BTREE_REC_ADDR(xfs_bmbt, block, idx + b);
 		*count += xfs_bmbt_disk_get_blockcount(frp);
 	}
-	return 0;
 }