Since HPI6205_TIMEOUT is a constant, time_out is always true,
so unneeded judgments are removed.
Signed-off-by: liujing <liujing@cmss.chinamobile.com>
diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
index c7d7eff86727..391cce428a11 100644
--- a/sound/pci/asihpi/hpi6205.c
+++ b/sound/pci/asihpi/hpi6205.c
@@ -2127,22 +2127,20 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
time_out = HPI6205_TIMEOUT;
/* read the result */
- if (time_out) {
- if (interface->u.response_buffer.response.size <= phr->size)
- memcpy(phr, &interface->u.response_buffer,
- interface->u.response_buffer.response.size);
- else {
- HPI_DEBUG_LOG(ERROR,
+ if (interface->u.response_buffer.response.size <= phr->size)
+ memcpy(phr, &interface->u.response_buffer,
+ interface->u.response_buffer.response.size);
+ else {
+ HPI_DEBUG_LOG(ERROR,
"response len %d too big for buffer %d\n",
interface->u.response_buffer.response.size,
phr->size);
- memcpy(phr, &interface->u.response_buffer,
+ memcpy(phr, &interface->u.response_buffer,
sizeof(struct hpi_response_header));
- phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
- phr->specific_error =
- interface->u.response_buffer.response.size;
- phr->size = sizeof(struct hpi_response_header);
- }
+ phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
+ phr->specific_error =
+ interface->u.response_buffer.response.size;
+ phr->size = sizeof(struct hpi_response_header);
}
/* set interface back to idle */
send_dsp_command(phw, H620_HIF_IDLE);
diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
index 7ceaf6a7a77e..cac5fcaef08b 100644
--- a/sound/pci/mixart/mixart.c
+++ b/sound/pci/mixart/mixart.c
@@ -1320,12 +1320,12 @@ static int snd_mixart_probe(struct pci_dev *pci,
idx = index[dev];
else
idx = index[dev] + i;
- snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
+ snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
0, &card);
if (err < 0) {
- dev_err(&pci->dev, "cannot allocate the card %d\n", i);
+ dev_err(&pci->dev, "cannot allocate the card %u\n", i);
snd_mixart_free(mgr);
return err;
}
@@ -1334,7 +1334,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
snprintf(card->shortname, sizeof(card->shortname),
"Digigram miXart [PCM #%d]", i);
snprintf(card->longname, sizeof(card->longname),
- "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]",
+ "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%u]",
mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i);
err = snd_mixart_create(mgr, card, i);
--
2.27.0
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@intel.com/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@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202412041936.OygWNCmW-lkp@intel.com/
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
On Tue, 03 Dec 2024 16:46:35 +0100,
liujing wrote:
>
> Since HPI6205_TIMEOUT is a constant, time_out is always true,
> so unneeded judgments are removed.
>
> Signed-off-by: liujing <liujing@cmss.chinamobile.com>
Keeping it allows to remove the time_out for experiments, and compiler
would optimize things in anyway, so there must be no code difference
in the end.
Since this doesn't improve things so significantly, I'd rather leave
as is.
And you mixed different fixes (the conversion of printf format) in a
single patch without explanation, too. Please split, if any.
thanks,
Takashi
>
> diff --git a/sound/pci/asihpi/hpi6205.c b/sound/pci/asihpi/hpi6205.c
> index c7d7eff86727..391cce428a11 100644
> --- a/sound/pci/asihpi/hpi6205.c
> +++ b/sound/pci/asihpi/hpi6205.c
> @@ -2127,22 +2127,20 @@ static u16 message_response_sequence(struct hpi_adapter_obj *pao,
> time_out = HPI6205_TIMEOUT;
>
> /* read the result */
> - if (time_out) {
> - if (interface->u.response_buffer.response.size <= phr->size)
> - memcpy(phr, &interface->u.response_buffer,
> - interface->u.response_buffer.response.size);
> - else {
> - HPI_DEBUG_LOG(ERROR,
> + if (interface->u.response_buffer.response.size <= phr->size)
> + memcpy(phr, &interface->u.response_buffer,
> + interface->u.response_buffer.response.size);
> + else {
> + HPI_DEBUG_LOG(ERROR,
> "response len %d too big for buffer %d\n",
> interface->u.response_buffer.response.size,
> phr->size);
> - memcpy(phr, &interface->u.response_buffer,
> + memcpy(phr, &interface->u.response_buffer,
> sizeof(struct hpi_response_header));
> - phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
> - phr->specific_error =
> - interface->u.response_buffer.response.size;
> - phr->size = sizeof(struct hpi_response_header);
> - }
> + phr->error = HPI_ERROR_RESPONSE_BUFFER_TOO_SMALL;
> + phr->specific_error =
> + interface->u.response_buffer.response.size;
> + phr->size = sizeof(struct hpi_response_header);
> }
> /* set interface back to idle */
> send_dsp_command(phw, H620_HIF_IDLE);
> diff --git a/sound/pci/mixart/mixart.c b/sound/pci/mixart/mixart.c
> index 7ceaf6a7a77e..cac5fcaef08b 100644
> --- a/sound/pci/mixart/mixart.c
> +++ b/sound/pci/mixart/mixart.c
> @@ -1320,12 +1320,12 @@ static int snd_mixart_probe(struct pci_dev *pci,
> idx = index[dev];
> else
> idx = index[dev] + i;
> - snprintf(tmpid, sizeof(tmpid), "%s-%d", id[dev] ? id[dev] : "MIXART", i);
> + snprintf(tmpid, sizeof(tmpid), "%s-%u", id[dev] ? id[dev] : "MIXART", i);
> err = snd_card_new(&pci->dev, idx, tmpid, THIS_MODULE,
> 0, &card);
>
> if (err < 0) {
> - dev_err(&pci->dev, "cannot allocate the card %d\n", i);
> + dev_err(&pci->dev, "cannot allocate the card %u\n", i);
> snd_mixart_free(mgr);
> return err;
> }
> @@ -1334,7 +1334,7 @@ static int snd_mixart_probe(struct pci_dev *pci,
> snprintf(card->shortname, sizeof(card->shortname),
> "Digigram miXart [PCM #%d]", i);
> snprintf(card->longname, sizeof(card->longname),
> - "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%d]",
> + "Digigram miXart at 0x%lx & 0x%lx, irq %i [PCM #%u]",
> mgr->mem[0].phys, mgr->mem[1].phys, mgr->irq, i);
>
> err = snd_mixart_create(mgr, card, i);
> --
> 2.27.0
>
>
>
© 2016 - 2025 Red Hat, Inc.