Skip to contentSkip to conversation

ALSA: hda: Improve local variable data type in snd_hda_get_num_devices()

PATCH In review Thorsten Blum 2 participants 2 messages Aug 13, 2025 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda: Improve local variable data type in snd_hda_get_num_devices()

Use 'int' instead of 'unsigned int' because the local variable 'parm' can be negative.

While an unsigned integer is harmless in practice due to the implicit type conversion, it's safer and more idiomatic to use a signed integer to properly check for -1.

---
 sound/hda/common/codec.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/hda/common/codec.c +1 -1
index eb268d442201..cab479111603 100644
@@ -300,7 +300,7 @@ EXPORT_SYMBOL_GPL(snd_hda_get_conn_index);
 unsigned int snd_hda_get_num_devices(struct hda_codec *codec, hda_nid_t nid)
 {
 	unsigned int wcaps = get_wcaps(codec, nid);
-	unsigned int parm;
+	int parm;
 
 	if (!codec->dp_mst || !(wcaps & AC_WCAP_DIGITAL) ||
 	    get_wcaps_type(wcaps) != AC_WID_PIN)
Signature · 1 line
2.50.1
#1 lore raw
Quoted 9 lines · Thorsten Blum

Use 'int' instead of 'unsigned int' because the local variable 'parm' can be negative.

While an unsigned integer is harmless in practice due to the implicit type conversion, it's safer and more idiomatic to use a signed integer to properly check for -1.

Applied now. Thanks.

Takashi