public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
From: Shinichiro Kawasaki <shinichiro.kawasaki@wdc.com>
To: Bart Van Assche <bvanassche@acm.org>
Cc: Damien Le Moal <dlemoal@kernel.org>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Keith Busch <kbusch@kernel.org>
Subject: Re: [PATCH blktests] src/dio-offsets.c: Fix err() usage
Date: Sat, 4 Apr 2026 08:35:52 +0000	[thread overview]
Message-ID: <adDM7QhRRlnntRB5@shinmob> (raw)
In-Reply-To: <20260326173632.3259254-1-bvanassche@acm.org>

On Mar 26, 2026 / 10:36, Bart Van Assche wrote:
> If the dio-offsets program detects data corruption, it reports the
> following message:
> 
> dio-offsets: test_unaligned_vectors: data corruption: Success
> 
> The "Success" part in this message is confusing and is reported because
> the err() macro is used incorrectly. errno must be set before err() is
> used instead of passing an error number as first argument. Fix usage of
> the err() macro as follows:
> - Change the first argument into EXIT_FAILURE (1). According to POSIX,
>   exit codes 1 - 125 mean failure and > 128 means that a program was
>   terminated by a signal. Hence, exit with code 1 instead of -1 if
>   ioctl() fails.
> - Use the err_errno() macro to set the error code instead of passing an
>   error code as first argument to err().

Bart, thanks for the patch. Overall, it looks good to me.

One thing I found is that one more err(EIO,...) is left in __compare() after
applying the patch. Should we convert it also into err_errno()? If so, I will
fold-in the hunk below.

diff --git a/src/dio-offsets.c b/src/dio-offsets.c
index 9fc7b92..c40ce68 100644
--- a/src/dio-offsets.c
+++ b/src/dio-offsets.c
@@ -131,7 +131,7 @@ static void __compare(void *a, void *b, size_t size, const char *test)
 {
 	if (!memcmp(a, b, size))
 		return;
-	err(EIO, "%s: data corruption", test);
+	err_errno(EIO, "%s: data corruption", test);
 }
 #define compare(a, b, size) __compare(a, b, size, __func__)
 

  parent reply	other threads:[~2026-04-04  8:36 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-26 17:36 [PATCH blktests] src/dio-offsets.c: Fix err() usage Bart Van Assche
2026-03-26 17:42 ` Keith Busch
2026-04-04  8:35 ` Shinichiro Kawasaki [this message]
2026-04-06 13:51   ` Bart Van Assche
2026-04-07  3:37     ` Shinichiro Kawasaki

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=adDM7QhRRlnntRB5@shinmob \
    --to=shinichiro.kawasaki@wdc.com \
    --cc=bvanassche@acm.org \
    --cc=dlemoal@kernel.org \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox