]> www.infradead.org Git - users/hch/misc.git/commitdiff
ALSA: hda: Improve local variable data type in print_device_list()
authorThorsten Blum <thorsten.blum@linux.dev>
Wed, 13 Aug 2025 21:00:57 +0000 (23:00 +0200)
committerTakashi Iwai <tiwai@suse.de>
Thu, 14 Aug 2025 06:40:01 +0000 (08:40 +0200)
Use 'unsigned int' instead of 'int' for the local variable 'devlist_len'
because snd_hda_get_devices() returns an 'unsigned int' and the length
cannot be negative. Update the print format specifier and the if
condition accordingly.

Reformat calling snd_hda_codec_read() to fit in a single line while
we're at it.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
Link: https://patch.msgid.link/20250813210059.215912-2-thorsten.blum@linux.dev
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/hda/common/proc.c

index 00c2eeb2c472d22348362dcac5f74ad4800e1286..d36195f73d45b3125e4f9ce083519156496da380 100644 (file)
@@ -716,16 +716,15 @@ static void print_device_list(struct snd_info_buffer *buffer,
 {
        int i, curr = -1;
        u8 dev_list[AC_MAX_DEV_LIST_LEN];
-       int devlist_len;
+       unsigned int devlist_len;
 
        devlist_len = snd_hda_get_devices(codec, nid, dev_list,
                                        AC_MAX_DEV_LIST_LEN);
-       snd_iprintf(buffer, "  Devices: %d\n", devlist_len);
-       if (devlist_len <= 0)
+       snd_iprintf(buffer, "  Devices: %u\n", devlist_len);
+       if (devlist_len == 0)
                return;
 
-       curr = snd_hda_codec_read(codec, nid, 0,
-                               AC_VERB_GET_DEVICE_SEL, 0);
+       curr = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_DEVICE_SEL, 0);
 
        for (i = 0; i < devlist_len; i++) {
                if (i == curr)