Skip to content

Commit 2832993

Browse files
committed
ALSA: cmipci: Fix -Wformat-truncation warning
CMIPCI driver got compile warnings with -Wformat-truncation at a couple of plain sprintf() usages. Use scnprintf() for filling the longname string for avoiding the warnings. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent ea77850 commit 2832993

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

sound/pci/cmipci.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3102,11 +3102,13 @@ static int snd_cmipci_create(struct snd_card *card, struct pci_dev *pci,
31023102
}
31033103
sprintf(card->shortname, "C-Media CMI%d", val);
31043104
if (cm->chip_version < 68)
3105-
sprintf(modelstr, " (model %d)", cm->chip_version);
3105+
scnprintf(modelstr, sizeof(modelstr),
3106+
" (model %d)", cm->chip_version);
31063107
else
31073108
modelstr[0] = '\0';
3108-
sprintf(card->longname, "%s%s at %#lx, irq %i",
3109-
card->shortname, modelstr, cm->iobase, cm->irq);
3109+
scnprintf(card->longname, sizeof(card->longname),
3110+
"%s%s at %#lx, irq %i",
3111+
card->shortname, modelstr, cm->iobase, cm->irq);
31103112

31113113
if (cm->chip_version >= 39) {
31123114
val = snd_cmipci_read_b(cm, CM_REG_MPU_PCI + 1);

0 commit comments

Comments
 (0)