[PATCH] ALSA: rawmidi: Fix inconsistent indenting warning reported by smatch

hariconscious@gmail.com posted 1 patch 5 hours ago
There is a newer version of this series
sound/core/rawmidi.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
[PATCH] ALSA: rawmidi: Fix inconsistent indenting warning reported by smatch
Posted by hariconscious@gmail.com 5 hours ago
From: HariKrishna Sagala <hariconscious@gmail.com>

Fix smatch reported inconsistent indenting warning in rawmidi.
sound/core/rawmidi.c:2115 alsa_rawmidi_init() warn: inconsistent
indenting.
No functional changes were introduced.

Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
---
This patch fixes the below smatch reported warning
sound/core/rawmidi.c:2115 alsa_rawmidi_init() warn: inconsistent
indenting.
Re-ran the smatch to confirm warning is cleared and no functional
changes were introduced.

Thank you.

 sound/core/rawmidi.c | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
index 20d36a346cca..5d90341cc18f 100644
--- a/sound/core/rawmidi.c
+++ b/sound/core/rawmidi.c
@@ -2106,25 +2106,25 @@ EXPORT_SYMBOL(snd_rawmidi_set_ops);
 
 static int __init alsa_rawmidi_init(void)
 {
-
 	snd_ctl_register_ioctl(snd_rawmidi_control_ioctl);
 	snd_ctl_register_ioctl_compat(snd_rawmidi_control_ioctl);
 #ifdef CONFIG_SND_OSSEMUL
-	{ int i;
-	/* check device map table */
-	for (i = 0; i < SNDRV_CARDS; i++) {
-		if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
-			pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
-			       i, midi_map[i]);
-			midi_map[i] = 0;
-		}
-		if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
-			pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
-			       i, amidi_map[i]);
-			amidi_map[i] = 1;
+	{
+		int i;
+		/* check device map table */
+		for (i = 0; i < SNDRV_CARDS; i++) {
+			if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
+				pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
+					i, midi_map[i]);
+				midi_map[i] = 0;
+			}
+			if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
+				pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
+					i, amidi_map[i]);
+				amidi_map[i] = 1;
+			}
 		}
 	}
-	}
 #endif /* CONFIG_SND_OSSEMUL */
 	return 0;
 }

base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
-- 
2.43.0
Re: [PATCH] ALSA: rawmidi: Fix inconsistent indenting warning reported by smatch
Posted by Takashi Iwai 5 hours ago
On Mon, 01 Dec 2025 15:46:21 +0100,
hariconscious@gmail.com wrote:
> 
> From: HariKrishna Sagala <hariconscious@gmail.com>
> 
> Fix smatch reported inconsistent indenting warning in rawmidi.
> sound/core/rawmidi.c:2115 alsa_rawmidi_init() warn: inconsistent
> indenting.
> No functional changes were introduced.
> 
> Signed-off-by: HariKrishna Sagala <hariconscious@gmail.com>
> ---
> This patch fixes the below smatch reported warning
> sound/core/rawmidi.c:2115 alsa_rawmidi_init() warn: inconsistent
> indenting.
> Re-ran the smatch to confirm warning is cleared and no functional
> changes were introduced.

Just move "int i" into the for() and drop braces instead -- which is
allowed in the recent versions, and it's much nicer than shifting way
too many texts just for a minor smatch warning.


thanks,

Takashi

> 
> Thank you.
> 
>  sound/core/rawmidi.c | 28 ++++++++++++++--------------
>  1 file changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/sound/core/rawmidi.c b/sound/core/rawmidi.c
> index 20d36a346cca..5d90341cc18f 100644
> --- a/sound/core/rawmidi.c
> +++ b/sound/core/rawmidi.c
> @@ -2106,25 +2106,25 @@ EXPORT_SYMBOL(snd_rawmidi_set_ops);
>  
>  static int __init alsa_rawmidi_init(void)
>  {
> -
>  	snd_ctl_register_ioctl(snd_rawmidi_control_ioctl);
>  	snd_ctl_register_ioctl_compat(snd_rawmidi_control_ioctl);
>  #ifdef CONFIG_SND_OSSEMUL
> -	{ int i;
> -	/* check device map table */
> -	for (i = 0; i < SNDRV_CARDS; i++) {
> -		if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
> -			pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
> -			       i, midi_map[i]);
> -			midi_map[i] = 0;
> -		}
> -		if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
> -			pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
> -			       i, amidi_map[i]);
> -			amidi_map[i] = 1;
> +	{
> +		int i;
> +		/* check device map table */
> +		for (i = 0; i < SNDRV_CARDS; i++) {
> +			if (midi_map[i] < 0 || midi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
> +				pr_err("ALSA: rawmidi: invalid midi_map[%d] = %d\n",
> +					i, midi_map[i]);
> +				midi_map[i] = 0;
> +			}
> +			if (amidi_map[i] < 0 || amidi_map[i] >= SNDRV_RAWMIDI_DEVICES) {
> +				pr_err("ALSA: rawmidi: invalid amidi_map[%d] = %d\n",
> +					i, amidi_map[i]);
> +				amidi_map[i] = 1;
> +			}
>  		}
>  	}
> -	}
>  #endif /* CONFIG_SND_OSSEMUL */
>  	return 0;
>  }
> 
> base-commit: 7d0a66e4bb9081d75c82ec4957c50034cb0ea449
> -- 
> 2.43.0
>