[PATCH] sparc: Use swap() to fix Coccinelle warning

Thorsten Blum posted 1 patch 1 year, 10 months ago
arch/sparc/include/asm/floppy_64.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
[PATCH] sparc: Use swap() to fix Coccinelle warning
Posted by Thorsten Blum 1 year, 10 months ago
Fixes the following Coccinelle/coccicheck warning reported by
swap.cocci:

	WARNING opportunity for swap()

Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
---
 arch/sparc/include/asm/floppy_64.h | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
index 6efeb24b0a92..83decacd0a2d 100644
--- a/arch/sparc/include/asm/floppy_64.h
+++ b/arch/sparc/include/asm/floppy_64.h
@@ -704,9 +704,7 @@ static unsigned long __init sun_floppy_init(void)
 			ns87303_modify(config, ASC, ASC_DRV2_SEL, 0);
 			ns87303_modify(config, FCR, 0, FCR_LDE);
 
-			config = sun_floppy_types[0];
-			sun_floppy_types[0] = sun_floppy_types[1];
-			sun_floppy_types[1] = config;
+			swap(sun_floppy_types[0], sun_floppy_types[1]);
 
 			if (sun_pci_broken_drive != -1) {
 				sun_pci_broken_drive = 1 - sun_pci_broken_drive;
-- 
2.44.0
Re: [PATCH] sparc: Use swap() to fix Coccinelle warning
Posted by Andreas Larsson 1 year, 9 months ago
On 2024-04-04 13:23, Thorsten Blum wrote:
> Fixes the following Coccinelle/coccicheck warning reported by
> swap.cocci:
> 
> 	WARNING opportunity for swap()
> 
> Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
> ---
>  arch/sparc/include/asm/floppy_64.h | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/arch/sparc/include/asm/floppy_64.h b/arch/sparc/include/asm/floppy_64.h
> index 6efeb24b0a92..83decacd0a2d 100644
> --- a/arch/sparc/include/asm/floppy_64.h
> +++ b/arch/sparc/include/asm/floppy_64.h
> @@ -704,9 +704,7 @@ static unsigned long __init sun_floppy_init(void)
>  			ns87303_modify(config, ASC, ASC_DRV2_SEL, 0);
>  			ns87303_modify(config, FCR, 0, FCR_LDE);
>  
> -			config = sun_floppy_types[0];
> -			sun_floppy_types[0] = sun_floppy_types[1];
> -			sun_floppy_types[1] = config;
> +			swap(sun_floppy_types[0], sun_floppy_types[1]);
>  
>  			if (sun_pci_broken_drive != -1) {
>  				sun_pci_broken_drive = 1 - sun_pci_broken_drive;

Reviewed-by: Andreas Larsson <andreas@gaisler.com>

Picking this up to my for-next

Thanks,
Andreas