Message ID | 20240827091920.80449-1-shenlichuan@vivo.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [v1] fuse: use min() macro | expand |
On Tue, 27 Aug 2024 at 11:19, Shen Lichuan <shenlichuan@vivo.com> wrote: > > Use the min() macro to simplify the function and improve > its readability. > > Signed-off-by: Shen Lichuan <shenlichuan@vivo.com> > --- > fs/fuse/file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/fuse/file.c b/fs/fuse/file.c > index 8ead93e775f4..aedeaa6014a6 100644 > --- a/fs/fuse/file.c > +++ b/fs/fuse/file.c > @@ -977,7 +977,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(res, 0); I find it more readable the way it is, because it's not a mathematical minimum, rather a "if error, return error, otherwise return zero". Thanks, Miklos
diff --git a/fs/fuse/file.c b/fs/fuse/file.c index 8ead93e775f4..aedeaa6014a6 100644 --- a/fs/fuse/file.c +++ b/fs/fuse/file.c @@ -977,7 +977,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(res, 0); } fuse_readpages_end(fm, &ap->args, err); }
Use the min() macro to simplify the function and improve its readability. Signed-off-by: Shen Lichuan <shenlichuan@vivo.com> --- fs/fuse/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)