* [PATCH] xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
@ 2021-01-27 9:24 Chandan Babu R
2021-01-27 16:34 ` Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Chandan Babu R @ 2021-01-27 9:24 UTC (permalink / raw)
To: linux-xfs; +Cc: Chandan Babu R, sandeen, Darrick J . Wong
This commit introduces a check to verify that correct bulkstat structures are
being processed by qsort's cmp() function.
Suggested-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
---
fsr/xfs_fsr.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
index b885395e..de7e8190 100644
--- a/fsr/xfs_fsr.c
+++ b/fsr/xfs_fsr.c
@@ -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);
}
/*
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp()
2021-01-27 9:24 [PATCH] xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp() Chandan Babu R
@ 2021-01-27 16:34 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2021-01-27 16:34 UTC (permalink / raw)
To: Chandan Babu R; +Cc: linux-xfs, sandeen
On Wed, Jan 27, 2021 at 02:54:05PM +0530, Chandan Babu R wrote:
> This commit introduces a check to verify that correct bulkstat structures are
> being processed by qsort's cmp() function.
>
> Suggested-by: Darrick J. Wong <djwong@kernel.org>
> Signed-off-by: Chandan Babu R <chandanrlinux@gmail.com>
> ---
> fsr/xfs_fsr.c | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c
> index b885395e..de7e8190 100644
> --- a/fsr/xfs_fsr.c
> +++ b/fsr/xfs_fsr.c
> @@ -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
> +
> + return (bs2->bs_extents - bs1->bs_extents);
> }
>
> /*
> --
> 2.29.2
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-01-27 16:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-01-27 9:24 [PATCH] xfsprogs: xfs_fsr: Verify bulkstat version information in qsort's cmp() Chandan Babu R
2021-01-27 16:34 ` Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox