ALSA: core: Use dev_name of card_dev as debugfs directory name
authorPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Tue, 12 Sep 2023 11:01:13 +0000 (14:01 +0300)
committerTakashi Iwai <tiwai@suse.de>
Tue, 12 Sep 2023 13:30:37 +0000 (15:30 +0200)
commit091c2848b0f7643eeb44abc1e7ba8f9ef5eb366f
tree3dfcadcb0d66e6a7e2d1369a8d6a0961ea7d6275
parentfb6254df09bba303db2a1002085f6c0b90a456ed
ALSA: core: Use dev_name of card_dev as debugfs directory name

There is no need to use temporary string for the debugfs directory name as
we can use the device name of the card.

This change will also fixes the following compiler warning/error (W=1):

sound/core/init.c: In function ‘snd_card_init’:
sound/core/init.c:367:28: error: ‘%d’ directive writing between 1 and 10 bytes into a region of size 4 [-Werror=format-overflow=]
  367 |         sprintf(name, "card%d", idx);
      |                            ^~
sound/core/init.c:367:23: note: directive argument in the range [0, 2147483646]
  367 |         sprintf(name, "card%d", idx);
      |                       ^~~~~~~~
sound/core/init.c:367:9: note: ‘sprintf’ output between 6 and 15 bytes into a destination of size 8
  367 |         sprintf(name, "card%d", idx);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

The idx is guarantied to be less than SNDRV_CARDS (max 256 or 8) by the
code in snd_card_init(), however the compiler does not see that.

The warnings got brought to light by a recent patch upstream:
commit 6d4ab2e97dcf ("extrawarn: enable format and stringop overflow warnings in W=1")

Suggested-by: Arnd Bergmann <arnd@arndb.de>
Suggested-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20230912110113.3166-1-peter.ujfalusi@linux.intel.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/core/init.c