sound/firewire/dice/dice.c:120:35: warning: ') at ' directive output may be truncated writing 5 bytes into a region of size between 1 and 69

From: kernel test robot
Date: Sat Jan 06 2024 - 02:01:00 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 95c8a35f1c017327eab3b6a2ff5c04255737c856
commit: 47227d27e2fcb01a9e8f5958d8997cf47a820afc string.h: fix incompatibility between FORTIFY_SOURCE and KASAN
date: 3 years, 7 months ago
config: x86_64-randconfig-014-20240106 (https://download.01.org/0day-ci/archive/20240106/202401061446.Vh6laz5V-lkp@xxxxxxxxx/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240106/202401061446.Vh6laz5V-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401061446.Vh6laz5V-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

sound/firewire/dice/dice.c: In function 'dice_card_strings':
>> sound/firewire/dice/dice.c:120:35: warning: ') at ' directive output may be truncated writing 5 bytes into a region of size between 1 and 69 [-Wformat-truncation=]
120 | "%s %s (serial %u) at %s, S%d",
| ^~~~~
sound/firewire/dice/dice.c:119:9: note: 'snprintf' output 21 or more bytes (assuming 89) into a destination of size 80
119 | snprintf(card->longname, sizeof(card->longname),
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
120 | "%s %s (serial %u) at %s, S%d",
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
121 | vendor, model, dev->config_rom[4] & 0x3fffff,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122 | dev_name(&dice->unit->device), 100 << dev->max_speed);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +120 sound/firewire/dice/dice.c

82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 91
732d153fbeac17 sound/firewire/dice.c Takashi Sakamoto 2014-11-29 92 static void dice_card_strings(struct snd_dice *dice)
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 93 {
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 94 struct snd_card *card = dice->card;
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 95 struct fw_device *dev = fw_parent_device(dice->unit);
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 96 char vendor[32], model[32];
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 97 unsigned int i;
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 98 int err;
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 99
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 100 strcpy(card->driver, "DICE");
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 101
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 102 strcpy(card->shortname, "DICE");
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 103 BUILD_BUG_ON(NICK_NAME_SIZE < sizeof(card->shortname));
7c2d4c0cf5bacb sound/firewire/dice/dice.c Takashi Sakamoto 2014-11-29 104 err = snd_dice_transaction_read_global(dice, GLOBAL_NICK_NAME,
7c2d4c0cf5bacb sound/firewire/dice/dice.c Takashi Sakamoto 2014-11-29 105 card->shortname,
7c2d4c0cf5bacb sound/firewire/dice/dice.c Takashi Sakamoto 2014-11-29 106 sizeof(card->shortname));
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 107 if (err >= 0) {
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 108 /* DICE strings are returned in "always-wrong" endianness */
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 109 BUILD_BUG_ON(sizeof(card->shortname) % 4 != 0);
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 110 for (i = 0; i < sizeof(card->shortname); i += 4)
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 111 swab32s((u32 *)&card->shortname[i]);
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 112 card->shortname[sizeof(card->shortname) - 1] = '\0';
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 113 }
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 114
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 115 strcpy(vendor, "?");
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 116 fw_csr_string(dev->config_rom + 5, CSR_VENDOR, vendor, sizeof(vendor));
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 117 strcpy(model, "?");
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 118 fw_csr_string(dice->unit->directory, CSR_MODEL, model, sizeof(model));
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 119 snprintf(card->longname, sizeof(card->longname),
cbab328ddc7858 sound/firewire/dice.c Clemens Ladisch 2011-09-04 @120 "%s %s (serial %u) at %s, S%d",
cbab328ddc7858 sound/firewire/dice.c Clemens Ladisch 2011-09-04 121 vendor, model, dev->config_rom[4] & 0x3fffff,
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 122 dev_name(&dice->unit->device), 100 << dev->max_speed);
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 123
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 124 strcpy(card->mixername, "DICE");
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 125 }
82fbb4f7b47683 sound/firewire/dice.c Clemens Ladisch 2011-09-04 126

:::::: The code at line 120 was first introduced by commit
:::::: cbab328ddc78589233be8be2f1e6a5f9d97b81db ALSA: dice: fix device detection for other vendors

:::::: TO: Clemens Ladisch <clemens@xxxxxxxxxx>
:::::: CC: Clemens Ladisch <clemens@xxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki