Re: [PATCH] ext4: replace ternary operator with min()
From: Sergey Senozhatsky
Date: Tue Oct 25 2022 - 21:18:02 EST
On (22/10/25 22:51), wangkailong@xxxxxxx wrote:
[..]
> @@ -879,7 +879,7 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level)
>
> err = oplock_break_pending(brk_opinfo, req_op_level);
> if (err)
> - return err < 0 ? err : 0;
> + return min(err, 0);
>
> if (brk_opinfo->open_trunc) {
> /*
> @@ -913,7 +913,7 @@ static int oplock_break(struct oplock_info *brk_opinfo, int req_op_level)
> } else {
> err = oplock_break_pending(brk_opinfo, req_op_level);
> if (err)
> - return err < 0 ? err : 0;
> + return min(err, 0);
Honestly, I don't know. My personal preference would be to keep it as is.
"return min(err, 0)" is a bit unusually looking code. Just my 2 cents.