public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: tytso@mit.edu
Cc: linux-ext4@vger.kernel.org
Subject: [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp
Date: Thu, 24 Apr 2025 14:39:13 -0700	[thread overview]
Message-ID: <174553064491.1160047.2269966041756188067.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <174553064436.1160047.577374015997116030.stgit@frogsfrogsfrogs>

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

Remove this pointless aliasing of error stream pointers.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 misc/fuse2fs.c |   22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)


diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index 18ae442c7ece03..f2d0e1f2441f83 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -89,6 +89,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */
 		break; \
 	}
 
+#define err_printf(fuse2fs, format, ...) \
+	do { \
+		fprintf(stderr, "FUSE2FS (%s): " format, (fuse2fs)->shortdev, ##__VA_ARGS__); \
+		fflush(stderr); \
+	} while (0)
+
 #if FUSE_VERSION >= FUSE_MAKE_VERSION(2, 8)
 # ifdef _IOR
 #  ifdef _IOW
@@ -344,7 +350,6 @@ struct fuse2fs {
 	int alloc_all_blocks;
 	int norecovery;
 	unsigned long offset;
-	FILE *err_fp;
 	unsigned int next_generation;
 };
 
@@ -3839,13 +3844,13 @@ int main(int argc, char *argv[])
 	/* Set up error logging */
 	logfile = getenv("FUSE2FS_LOGFILE");
 	if (logfile) {
-		fctx.err_fp = fopen(logfile, "a");
-		if (!fctx.err_fp) {
+		FILE *fp = fopen(logfile, "a");
+		if (!fp) {
 			perror(logfile);
 			goto out;
 		}
-	} else
-		fctx.err_fp = stderr;
+		stderr = fp;
+	}
 
 	/* Will we allow users to allocate every last block? */
 	if (getenv("FUSE2FS_ALLOC_ALL_BLOCKS")) {
@@ -4052,14 +4057,11 @@ static int __translate_error(ext2_filsys fs, errcode_t err, ext2_ino_t ino,
 		return ret;
 
 	if (ino)
-		fprintf(ff->err_fp, "FUSE2FS (%s): %s (inode #%d) at %s:%d.\n",
-			fs->device_name ? fs->device_name : "???",
+		err_printf(ff, "%s (inode #%d) at %s:%d.\n",
 			error_message(err), ino, file, line);
 	else
-		fprintf(ff->err_fp, "FUSE2FS (%s): %s at %s:%d.\n",
-			fs->device_name ? fs->device_name : "???",
+		err_printf(ff, "%s at %s:%d.\n",
 			error_message(err), file, line);
-	fflush(ff->err_fp);
 
 	/* Make a note in the error log */
 	get_now(&now);


  parent reply	other threads:[~2025-04-24 21:39 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-24 21:38 [PATCHSET 1/5] fuse2fs: better logging Darrick J. Wong
2025-04-24 21:38 ` [PATCH 1/5] fuse2fs: enable runtime debugging Darrick J. Wong
2025-04-24 21:39 ` Darrick J. Wong [this message]
2025-07-20  8:27   ` [PATCH 2/5] fuse2fs: stop aliasing stderr with ff->err_fp Sam James
2025-07-20 18:51     ` Darrick J. Wong
2025-07-21  5:42       ` Darrick J. Wong
2025-07-21 11:41         ` Theodore Ts'o
2025-07-21 17:01           ` Darrick J. Wong
2025-04-24 21:39 ` [PATCH 3/5] fuse2fs: use error logging macro for mount errors Darrick J. Wong
2025-04-24 21:39 ` [PATCH 4/5] fuse2fs: make other logging consistent Darrick J. Wong
2025-04-24 21:40 ` [PATCH 5/5] fuse2fs: redirect all messages when FUSE2FS_LOGFILE is set Darrick J. Wong
2025-05-21 14:51 ` [PATCHSET 1/5] fuse2fs: better logging Theodore Ts'o

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=174553064491.1160047.2269966041756188067.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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