xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
PATCH v2 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]>
---
V1 -> V2:
1. Include XFS_BULKSTAT_VERSION_V1 as a possible bulkstat version number.
2. Fix coding style issue.
fsr/xfs_fsr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
fsr/xfs_fsr.c +9 -2
@@ -582,8 +582,15 @@ 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_V1 && + bs2->bs_version ==XFS_BULKSTAT_VERSION_V1 ) || + (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 5 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]>
Looks good.
Reviewed-by Chaitanya Kulkarni <[email protected]>
Quoted 6 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]>---
Looks good to me,
Reviewed-by Darrick J. Wong <[email protected]>
--D
Quoted 33 lines
V1 -> V2:
1. IncludeXFS_BULKSTAT_VERSION_V1as a possible bulkstat version number.
2. Fix coding style issue.fsr/xfs_fsr.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)fsr/xfs_fsr.c +9
-2@@ -582,8 +582,15 @@ 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_V1 && + bs2->bs_version ==XFS_BULKSTAT_VERSION_V1 ) || + (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