xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
PATCH 1/1 xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
This commit introduces a check to verify that correct bulkstat structures are being processed by qsort's cmp() function.
Suggested-by Darrick J. Wong <[email protected]>
Signed-off-by Chandan Babu R <[email protected]>
--- fsr/xfs_fsr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
fsr/xfs_fsr.c +7 -2
@@ -582,8 +582,13 @@ fsrall_cleanup(int timeout)static int cmp (const void *s1,const void *s2) { -return ( ((struct xfs_bulkstat *)s2)->bs_extents - - ((struct xfs_bulkstat *)s1)->bs_extents); +const struct xfs_bulkstat *bs1 = s1; +const struct xfs_bulkstat *bs2 = s2; + +ASSERT (bs1->bs_version ==XFS_BULKSTAT_VERSION_V5 + && bs2->bs_version ==XFS_BULKSTAT_VERSION_V5 ); + +return (bs2->bs_extents - bs1->bs_extents); }/*
Signature · 1 line
2.29.2
Quoted 14 lines · Chandan Babu R
This commit introduces a check to verify that correct bulkstat structures are being processed by qsort's
cmp()function.Suggested-by Darrick J. Wong <[email protected]>Signed-off-by Chandan Babu R <[email protected]>--- fsr/xfs_fsr.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)fsr/xfs_fsr.c +0
-0
fsr/xfs_fsr.c fsrall_cleanup(int timeout) · line 589
Quoted 10 lines
fsr/xfs_fsr.c +5
-2@@ -582,8 +582,13 @@ fsrall_cleanup(int timeout)static int cmp (const void *s1,const void *s2) { -return ( ((struct xfs_bulkstat *)s2)->bs_extents - - ((struct xfs_bulkstat *)s1)->bs_extents); +const struct xfs_bulkstat *bs1 = s1; +const struct xfs_bulkstat *bs2 = s2; + +ASSERT (bs1->bs_version ==XFS_BULKSTAT_VERSION_V5 + && bs2->bs_version ==XFS_BULKSTAT_VERSION_V5 );
Stylistic nit: the '&&' goes on the previous line; and bs_version can also be XFS_BULKSTAT_VERSION_V1.
--D
Quoted 8 lines
fsr/xfs_fsr.c +2
-0+ +return (bs2->bs_extents - bs1->bs_extents); }/* Signature · 1 line
2.29.2