diff mbox series

[net-next,8/8] net/ceph: Use min() to simplify the code

Message ID 20240824074033.2134514-9-lihongbo22@huawei.com
State New
Headers show
Series Use max/min to simplify the code | expand

Commit Message

Hongbo Li Aug. 24, 2024, 7:40 a.m. UTC
Let's use min() to simplify the code and fix the
Coccinelle/coccicheck warning reported by minmax.cocci.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
---
 net/ceph/osd_client.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman Aug. 28, 2024, 2:11 p.m. UTC | #1
On Sat, Aug 24, 2024 at 03:40:33PM +0800, Hongbo Li wrote:
> Let's use min() to simplify the code and fix the
> Coccinelle/coccicheck warning reported by minmax.cocci.
> 
> Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
> ---
>  net/ceph/osd_client.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index 9d078b37fe0b..450eb3be48b0 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -3058,7 +3058,7 @@ static void linger_reg_commit_complete(struct ceph_osd_linger_request *lreq,
>  				       int result)
>  {
>  	if (!completion_done(&lreq->reg_commit_wait)) {
> -		lreq->reg_commit_error = (result <= 0 ? result : 0);
> +		lreq->reg_commit_error = min(result, 0);
>  		complete_all(&lreq->reg_commit_wait);
>  	}
>  }

As per my comment on 2/8 [*], I think it would be best to drop this patch.

[*] https://lore.kernel.org/all/20240828135310.GC1368797@kernel.org/
diff mbox series

Patch

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 9d078b37fe0b..450eb3be48b0 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -3058,7 +3058,7 @@  static void linger_reg_commit_complete(struct ceph_osd_linger_request *lreq,
 				       int result)
 {
 	if (!completion_done(&lreq->reg_commit_wait)) {
-		lreq->reg_commit_error = (result <= 0 ? result : 0);
+		lreq->reg_commit_error = min(result, 0);
 		complete_all(&lreq->reg_commit_wait);
 	}
 }