All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: zlang@redhat.com, djwong@kernel.org
Cc: linux-xfs@vger.kernel.org, fstests@vger.kernel.org, guan@eryu.me
Subject: [PATCH 1/7] fsx: fix indenting of columns in bad buffers report
Date: Tue, 02 May 2023 13:08:11 -0700	[thread overview]
Message-ID: <168305809174.331137.660744527774559430.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <168305808594.331137.16455277063177572891.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

When file corruption is detected, make the columns of the report line
up correctly even in the diff output.  Although the .out.bad file
contains this (with spaces to demonstrate unequivocally what happens
when tabs are formatted as 8-column indent):

OFFSET  GOOD    BAD     RANGE
0x2c000 0x0000  0xd6c1  0x00000

diffing the good and bad golden output yields poorly formatted output:

+OFFSET GOOD    BAD     RANGE
+0x2c000        0x0000  0xd6c1  0x00000

Replace the tabs with columns indented with printf width specifiers so
that the test output gets this:

OFFSET      GOOD    BAD     RANGE
0x2c000     0x0000  0xd6c1  0x0

...which always lines up the columns regardless of the user's tab
display settings or diff inserting plus signs.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
 ltp/fsx.c |    9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)


diff --git a/ltp/fsx.c b/ltp/fsx.c
index c76b06ca76..ffa64cfa00 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -669,17 +669,18 @@ check_buffers(char *buf, unsigned offset, unsigned size)
 	if (memcmp(good_buf + offset, buf, size) != 0) {
 		prt("READ BAD DATA: offset = 0x%x, size = 0x%x, fname = %s\n",
 		    offset, size, fname);
-		prt("OFFSET\tGOOD\tBAD\tRANGE\n");
+		prt("%-10s  %-6s  %-6s  %s\n", "OFFSET", "GOOD", "BAD", "RANGE");
 		while (size > 0) {
 			c = good_buf[offset];
 			t = buf[i];
 			if (c != t) {
 			        if (n < 16) {
 					bad = short_at(&buf[i]);
-				        prt("0x%05x\t0x%04x\t0x%04x", offset,
-				            short_at(&good_buf[offset]), bad);
+				        prt("0x%-8x  0x%04x  0x%04x  0x%x\n",
+					    offset,
+					    short_at(&good_buf[offset]), bad,
+					    n);
 					op = buf[offset & 1 ? i+1 : i];
-				        prt("\t0x%05x\n", n);
 					if (op)
 						prt("operation# (mod 256) for "
 						  "the bad data may be %u\n",


  reply	other threads:[~2023-05-02 20:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02 20:08 [PATCHSET 0/7] fstests: random fixes for v2023.05.01 Darrick J. Wong
2023-05-02 20:08 ` Darrick J. Wong [this message]
2023-05-02 20:08 ` [PATCH 2/7] xfs/262: remove dangerous labels Darrick J. Wong
2023-05-02 20:08 ` [PATCH 3/7] generic/724,xfs/791: adjust test preconditions for post-EOF stripe zeroing Darrick J. Wong
2023-05-02 20:08 ` [PATCH 4/7] xfs/{243,245,272,274}: ignore raid alignment flags in bmap output Darrick J. Wong
2023-05-02 20:08 ` [PATCH 5/7] fiemap-tester: holes can be backed by unwritten extents Darrick J. Wong
2023-05-02 20:08 ` [PATCH 6/7] fiemap: FIEMAP_EXTENT_LAST denotes the last record in the recordset Darrick J. Wong
2023-05-02 20:08 ` [PATCH 7/7] generic/{094,225}: drop the file allocation unit requirements Darrick J. Wong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=168305809174.331137.660744527774559430.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=fstests@vger.kernel.org \
    --cc=guan@eryu.me \
    --cc=linux-xfs@vger.kernel.org \
    --cc=zlang@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.