[PATCH] s390/smp: Use min() to fix Coccinelle warning

Thorsten Blum posted 1 patch 1 year, 10 months ago
arch/s390/kernel/smp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH] s390/smp: Use min() to fix Coccinelle warning
Posted by Thorsten Blum 1 year, 10 months ago
Fixes the following Coccinelle/coccicheck warning reported by
minmax.cocci:

	WARNING opportunity for min()

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 arch/s390/kernel/smp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
index 0324649aae0a..d69cf2475744 100644
--- a/arch/s390/kernel/smp.c
+++ b/arch/s390/kernel/smp.c
@@ -1205,7 +1205,7 @@ static int __init s390_smp_init(void)
 
 	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online",
 			       smp_cpu_online, smp_cpu_pre_down);
-	rc = rc <= 0 ? rc : 0;
+	rc = min(rc, 0);
 out:
 	return rc;
 }
-- 
2.44.0
Re: [PATCH] s390/smp: Use min() to fix Coccinelle warning
Posted by Heiko Carstens 1 year, 10 months ago
On Mon, Apr 08, 2024 at 12:51:25PM +0200, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> minmax.cocci:
> 
> 	WARNING opportunity for min()
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  arch/s390/kernel/smp.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/arch/s390/kernel/smp.c b/arch/s390/kernel/smp.c
> index 0324649aae0a..d69cf2475744 100644
> --- a/arch/s390/kernel/smp.c
> +++ b/arch/s390/kernel/smp.c
> @@ -1205,7 +1205,7 @@ static int __init s390_smp_init(void)
>  
>  	rc = cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "s390/smp:online",
>  			       smp_cpu_online, smp_cpu_pre_down);
> -	rc = rc <= 0 ? rc : 0;
> +	rc = min(rc, 0);

No. This decreases readability. Please do not send such patches just
because Coccinelle reports something.