[PATCH 46/51] xfs_scrub: cleanup fsmap keys initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Christoph Hellwig <hch@xxxxxx>

Use the good old array notations instead of pointer arithmetics.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
[djwong: fold scan_rtg_rmaps cleanups into next patch]
Signed-off-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
---
 scrub/phase6.c   |   17 ++++++++---------
 scrub/spacemap.c |   32 +++++++++++++++-----------------
 2 files changed, 23 insertions(+), 26 deletions(-)


diff --git a/scrub/phase6.c b/scrub/phase6.c
index e4f26e7f1dd93e..fc63f5aad0bd7b 100644
--- a/scrub/phase6.c
+++ b/scrub/phase6.c
@@ -495,7 +495,7 @@ report_ioerr(
 	uint64_t			length,
 	void				*arg)
 {
-	struct fsmap			keys[2];
+	struct fsmap			keys[2] = { };
 	struct ioerr_filerange		fr = {
 		.physical		= start,
 		.length			= length,
@@ -506,14 +506,13 @@ report_ioerr(
 	dev = disk_to_dev(dioerr->ctx, dioerr->disk);
 
 	/* Go figure out which blocks are bad from the fsmap. */
-	memset(keys, 0, sizeof(struct fsmap) * 2);
-	keys->fmr_device = dev;
-	keys->fmr_physical = start;
-	(keys + 1)->fmr_device = dev;
-	(keys + 1)->fmr_physical = start + length - 1;
-	(keys + 1)->fmr_owner = ULLONG_MAX;
-	(keys + 1)->fmr_offset = ULLONG_MAX;
-	(keys + 1)->fmr_flags = UINT_MAX;
+	keys[0].fmr_device = dev;
+	keys[0].fmr_physical = start;
+	keys[1].fmr_device = dev;
+	keys[1].fmr_physical = start + length - 1;
+	keys[1].fmr_owner = ULLONG_MAX;
+	keys[1].fmr_offset = ULLONG_MAX;
+	keys[1].fmr_flags = UINT_MAX;
 	return -scrub_iterate_fsmap(dioerr->ctx, keys, report_ioerr_fsmap,
 			&fr);
 }
diff --git a/scrub/spacemap.c b/scrub/spacemap.c
index e35756db2eed43..4b7fae252d86ca 100644
--- a/scrub/spacemap.c
+++ b/scrub/spacemap.c
@@ -96,21 +96,20 @@ scan_ag_rmaps(
 {
 	struct scrub_ctx	*ctx = (struct scrub_ctx *)wq->wq_ctx;
 	struct scan_blocks	*sbx = arg;
-	struct fsmap		keys[2];
+	struct fsmap		keys[2] = { };
 	off_t			bperag;
 	int			ret;
 
 	bperag = (off_t)ctx->mnt.fsgeom.agblocks *
 		 (off_t)ctx->mnt.fsgeom.blocksize;
 
-	memset(keys, 0, sizeof(struct fsmap) * 2);
-	keys->fmr_device = ctx->fsinfo.fs_datadev;
-	keys->fmr_physical = agno * bperag;
-	(keys + 1)->fmr_device = ctx->fsinfo.fs_datadev;
-	(keys + 1)->fmr_physical = ((agno + 1) * bperag) - 1;
-	(keys + 1)->fmr_owner = ULLONG_MAX;
-	(keys + 1)->fmr_offset = ULLONG_MAX;
-	(keys + 1)->fmr_flags = UINT_MAX;
+	keys[0].fmr_device = ctx->fsinfo.fs_datadev;
+	keys[0].fmr_physical = agno * bperag;
+	keys[1].fmr_device = ctx->fsinfo.fs_datadev;
+	keys[1].fmr_physical = ((agno + 1) * bperag) - 1;
+	keys[1].fmr_owner = ULLONG_MAX;
+	keys[1].fmr_offset = ULLONG_MAX;
+	keys[1].fmr_flags = UINT_MAX;
 
 	if (sbx->aborted)
 		return;
@@ -135,16 +134,15 @@ scan_dev_rmaps(
 	dev_t			dev,
 	struct scan_blocks	*sbx)
 {
-	struct fsmap		keys[2];
+	struct fsmap		keys[2] = { };
 	int			ret;
 
-	memset(keys, 0, sizeof(struct fsmap) * 2);
-	keys->fmr_device = dev;
-	(keys + 1)->fmr_device = dev;
-	(keys + 1)->fmr_physical = ULLONG_MAX;
-	(keys + 1)->fmr_owner = ULLONG_MAX;
-	(keys + 1)->fmr_offset = ULLONG_MAX;
-	(keys + 1)->fmr_flags = UINT_MAX;
+	keys[0].fmr_device = dev;
+	keys[1].fmr_device = dev;
+	keys[1].fmr_physical = ULLONG_MAX;
+	keys[1].fmr_owner = ULLONG_MAX;
+	keys[1].fmr_offset = ULLONG_MAX;
+	keys[1].fmr_flags = UINT_MAX;
 
 	if (sbx->aborted)
 		return;





[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux