Linux Kernel Mentees list
 help / color / mirror / Atom feed
* [PATCH] fuse: use min_t() instead of ternary operator
@ 2026-06-07 17:58 Mahad Ibrahim
  2026-06-09 14:48 ` Miklos Szeredi
  0 siblings, 1 reply; 2+ messages in thread
From: Mahad Ibrahim @ 2026-06-07 17:58 UTC (permalink / raw)
  To: Miklos Szeredi
  Cc: linux-fsdevel, linux-kernel, linux-kernel-mentees, Mahad Ibrahim

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] fuse: use min_t() instead of ternary operator
  2026-06-07 17:58 [PATCH] fuse: use min_t() instead of ternary operator Mahad Ibrahim
@ 2026-06-09 14:48 ` Miklos Szeredi
  0 siblings, 0 replies; 2+ messages in thread
From: Miklos Szeredi @ 2026-06-09 14:48 UTC (permalink / raw)
  To: Mahad Ibrahim; +Cc: linux-fsdevel, linux-kernel, linux-kernel-mentees

On Sun, 7 Jun 2026 at 19:58, Mahad Ibrahim <mahad.ibrahim.dev@gmail.com> wrote:
>
> Replace existing ternary operators for finding minimum value with min_t
> macro to adhere to kernel coding standards and improve readability.

Doesn't improve readability, on the contrary, it obfuscates the real
meaning (return error or zero).

Thanks,
Miklos

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-09 14:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-07 17:58 [PATCH] fuse: use min_t() instead of ternary operator Mahad Ibrahim
2026-06-09 14:48 ` Miklos Szeredi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox