Linux Kernel Mentees list
 help / color / mirror / Atom feed
From: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
To: Miklos Szeredi <miklos@szeredi.hu>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org,
	Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
Subject: [PATCH] fuse: use min_t() instead of ternary operator
Date: Sun,  7 Jun 2026 22:58:32 +0500	[thread overview]
Message-ID: <20260607175832.14378-1-mahad.ibrahim.dev@gmail.com> (raw)

Replace existing ternary operators for finding minimum value with min_t
macro to adhere to kernel coding standards and improve readability.

Fix coccinelle warning:
  WARNING opportunity for min()

Testing: Tested at runtime via sshfs with file creation, appendating
and reading.

Signed-off-by: Mahad Ibrahim <mahad.ibrahim.dev@gmail.com>
---
 fs/fuse/file.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fs/fuse/file.c b/fs/fuse/file.c
index f94f3dc082c6..67bab59bc6a7 100644
--- a/fs/fuse/file.c
+++ b/fs/fuse/file.c
@@ -14,6 +14,7 @@
 #include <linux/sched.h>
 #include <linux/sched/signal.h>
 #include <linux/module.h>
+#include <linux/minmax.h>
 #include <linux/swap.h>
 #include <linux/falloc.h>
 #include <linux/uio.h>
@@ -1066,7 +1067,7 @@ static void fuse_send_readpages(struct fuse_io_args *ia, struct file *file,
 			return;
 	} else {
 		res = fuse_simple_request(fm, &ap->args);
-		err = res < 0 ? res : 0;
+		err = min_t(int, res, 0);
 	}
 	fuse_readpages_end(fm, &ap->args, err);
 }
@@ -2895,7 +2896,7 @@ fuse_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
 	if (io->async) {
 		bool blocking = io->blocking;
 
-		fuse_aio_complete(io, ret < 0 ? ret : 0, -1);
+		fuse_aio_complete(io, min_t(int, ret, 0), -1);
 
 		/* we have a non-extending, async request, so return */
 		if (!blocking)
-- 
2.47.3


             reply	other threads:[~2026-06-07 17:58 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-07 17:58 Mahad Ibrahim [this message]
2026-06-09 14:48 ` [PATCH] fuse: use min_t() instead of ternary operator Miklos Szeredi

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=20260607175832.14378-1-mahad.ibrahim.dev@gmail.com \
    --to=mahad.ibrahim.dev@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    /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