Re: [PATCH] ALSA: asihpi: Delete redundant judgments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hi liujing,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tiwai-sound/for-next]
[also build test WARNING on tiwai-sound/for-linus linus/master v6.13-rc1 next-20241203]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/liujing/ALSA-asihpi-Delete-redundant-judgments/20241204-113552
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git for-next
patch link:    https://lore.kernel.org/r/20241203154635.2512-1-liujing%40cmss.chinamobile.com
patch subject: [PATCH] ALSA: asihpi: Delete redundant judgments
config: x86_64-randconfig-161 (https://download.01.org/0day-ci/archive/20241204/202412041936.OygWNCmW-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/20241204/202412041936.OygWNCmW-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/202412041936.OygWNCmW-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

   sound/pci/mixart/mixart.c: In function 'snd_mixart_probe':
>> sound/pci/mixart/mixart.c:1323:52: warning: '%u' directive output may be truncated writing between 1 and 10 bytes into a region of size between 9 and 15 [-Wformat-truncation=]
    1323 |                 snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
         |                                                    ^~
   sound/pci/mixart/mixart.c:1323:48: note: directive argument in the range [0, 4294967294]
    1323 |                 snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
         |                                                ^~~~~~~
   sound/pci/mixart/mixart.c:1323:17: note: 'snprintf' output 3 or more bytes (assuming 18) into a destination of size 16
    1323 |                 snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
         |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


vim +1323 sound/pci/mixart/mixart.c

  1225	
  1226	
  1227	/*
  1228	 *    probe function - creates the card manager
  1229	 */
  1230	static int snd_mixart_probe(struct pci_dev *pci,
  1231				    const struct pci_device_id *pci_id)
  1232	{
  1233		static int dev;
  1234		struct mixart_mgr *mgr;
  1235		unsigned int i;
  1236		int err;
  1237		size_t size;
  1238	
  1239		/*
  1240		 */
  1241		if (dev >= SNDRV_CARDS)
  1242			return -ENODEV;
  1243		if (! enable[dev]) {
  1244			dev++;
  1245			return -ENOENT;
  1246		}
  1247	
  1248		/* enable PCI device */
  1249		err = pci_enable_device(pci);
  1250		if (err < 0)
  1251			return err;
  1252		pci_set_master(pci);
  1253	
  1254		/* check if we can restrict PCI DMA transfers to 32 bits */
  1255		if (dma_set_mask(&pci->dev, DMA_BIT_MASK(32)) < 0) {
  1256			dev_err(&pci->dev,
  1257				"architecture does not support 32bit PCI busmaster DMA\n");
  1258			pci_disable_device(pci);
  1259			return -ENXIO;
  1260		}
  1261	
  1262		/*
  1263		 */
  1264		mgr = kzalloc(sizeof(*mgr), GFP_KERNEL);
  1265		if (! mgr) {
  1266			pci_disable_device(pci);
  1267			return -ENOMEM;
  1268		}
  1269	
  1270		mgr->pci = pci;
  1271		mgr->irq = -1;
  1272	
  1273		/* resource assignment */
  1274		err = pci_request_regions(pci, CARD_NAME);
  1275		if (err < 0) {
  1276			kfree(mgr);
  1277			pci_disable_device(pci);
  1278			return err;
  1279		}
  1280		for (i = 0; i < 2; i++) {
  1281			mgr->mem[i].phys = pci_resource_start(pci, i);
  1282			mgr->mem[i].virt = pci_ioremap_bar(pci, i);
  1283			if (!mgr->mem[i].virt) {
  1284				dev_err(&pci->dev, "unable to remap resource 0x%lx\n",
  1285				       mgr->mem[i].phys);
  1286				snd_mixart_free(mgr);
  1287				return -EBUSY;
  1288			}
  1289		}
  1290	
  1291		if (request_threaded_irq(pci->irq, snd_mixart_interrupt,
  1292					 snd_mixart_threaded_irq, IRQF_SHARED,
  1293					 KBUILD_MODNAME, mgr)) {
  1294			dev_err(&pci->dev, "unable to grab IRQ %d\n", pci->irq);
  1295			snd_mixart_free(mgr);
  1296			return -EBUSY;
  1297		}
  1298		mgr->irq = pci->irq;
  1299	
  1300		/* init mailbox  */
  1301		mgr->msg_fifo_readptr = 0;
  1302		mgr->msg_fifo_writeptr = 0;
  1303	
  1304		mutex_init(&mgr->lock);
  1305		mutex_init(&mgr->msg_lock);
  1306		init_waitqueue_head(&mgr->msg_sleep);
  1307		atomic_set(&mgr->msg_processed, 0);
  1308	
  1309		/* init setup mutex*/
  1310		mutex_init(&mgr->setup_mutex);
  1311	
  1312		/* card assignment */
  1313		mgr->num_cards = MIXART_MAX_CARDS; /* 4  FIXME: configurable? */
  1314		for (i = 0; i < mgr->num_cards; i++) {
  1315			struct snd_card *card;
  1316			char tmpid[16];
  1317			int idx;
  1318	
  1319			if (index[dev] < 0)
  1320				idx = index[dev];
  1321			else
  1322				idx = index[dev] + i;
> 1323			snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
  1324			err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
  1325					   0, &card);
  1326	
  1327			if (err < 0) {
  1328				dev_err(&pci->dev, "cannot allocate the card %u\n", i);
  1329				snd_mixart_free(mgr);
  1330				return err;
  1331			}
  1332	
  1333			strcpy(card->driver, CARD_NAME);
  1334			snprintf(card->shortname, sizeof(card->shortname),
  1335				 "Digigram miXart [PCM #%d]", i);
  1336			snprintf(card->longname, sizeof(card->longname),
  1337				"Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%u]",
  1338				mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i);
  1339	
  1340			err = snd_mixart_create(mgr, card, i);
  1341			if (err < 0) {
  1342				snd_card_free(card);
  1343				snd_mixart_free(mgr);
  1344				return err;
  1345			}
  1346	
  1347			if(i==0) {
  1348				/* init proc interface only for chip0 */
  1349				snd_mixart_proc_init(mgr->chip[i]);
  1350			}
  1351	
  1352			err = snd_card_register(card);
  1353			if (err < 0) {
  1354				snd_mixart_free(mgr);
  1355				return err;
  1356			}
  1357		}
  1358	
  1359		/* init firmware status (mgr->dsp_loaded reset in hwdep_new) */
  1360		mgr->board_type = MIXART_DAUGHTER_TYPE_NONE;
  1361	
  1362		/* create array of streaminfo */
  1363		size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
  1364				    sizeof(struct mixart_flowinfo)) );
  1365		if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
  1366					size, &mgr->flowinfo) < 0) {
  1367			snd_mixart_free(mgr);
  1368			return -ENOMEM;
  1369		}
  1370		/* init streaminfo_array */
  1371		memset(mgr->flowinfo.area, 0, size);
  1372	
  1373		/* create array of bufferinfo */
  1374		size = PAGE_ALIGN( (MIXART_MAX_STREAM_PER_CARD * MIXART_MAX_CARDS *
  1375				    sizeof(struct mixart_bufferinfo)) );
  1376		if (snd_dma_alloc_pages(SNDRV_DMA_TYPE_DEV, &pci->dev,
  1377					size, &mgr->bufferinfo) < 0) {
  1378			snd_mixart_free(mgr);
  1379			return -ENOMEM;
  1380		}
  1381		/* init bufferinfo_array */
  1382		memset(mgr->bufferinfo.area, 0, size);
  1383	
  1384		/* set up firmware */
  1385		err = snd_mixart_setup_firmware(mgr);
  1386		if (err < 0) {
  1387			snd_mixart_free(mgr);
  1388			return err;
  1389		}
  1390	
  1391		pci_set_drvdata(pci, mgr);
  1392		dev++;
  1393		return 0;
  1394	}
  1395	

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




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux