Thread (9 messages) 9 messages, 3 authors, 2021-02-02

Re: [PATCH 1/2] xfsprogs: xfs_fsr: Interpret arguments of qsort's compare function correctly

From: Chandan Babu R <hidden>
Date: 2021-01-26 23:03:56

On 26 Jan 2021 at 23:28, Darrick J. Wong wrote:
On Mon, Jan 25, 2021 at 03:28:08PM +0530, Chandan Babu R wrote:
quoted
The first argument passed to qsort() in fsrfs() is an array of "struct
xfs_bulkstat". Hence the two arguments to the cmp() function must be
interpreted as being of type "struct xfs_bulkstat *" as against "struct
xfs_bstat *" that is being used to currently typecast them.

Signed-off-by: Chandan Babu R <redacted>
---
 fsr/xfs_fsr.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index 77a10a1d..635e4c70 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -702,9 +702,8 @@ out0:
 int
 cmp(const void *s1, const void *s2)
 {
-	return( ((struct xfs_bstat *)s2)->bs_extents -
-	        ((struct xfs_bstat *)s1)->bs_extents);
-
+	return( ((struct xfs_bulkstat *)s2)->bs_extents -
+	        ((struct xfs_bulkstat *)s1)->bs_extents);
It might be a good idea to check bs_version here to avoid future
maintainer screwups <coughs this maintainer>
Sure, I will write a new patch to add that.
Thanks for catching this,
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
-- 
chandan
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help