fuse: use min_t() instead of ternary operator
Subsystems (2)
PATCH 1/1 fuse: use min_t() instead of ternary operator
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 <[email protected]>
--- fs/fuse/file.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/fuse/file.c +3 -2
@@ -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)
Signature · 1 line
2.47.3
Miklos Szeredi
maintainerQuoted 3 lines · Mahad Ibrahim
Replace existing ternary operators for finding minimum value with
min_tmacro 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