Skip to contentSkip to conversation

ALSA: trident: Suppress gcc string warning

PATCH New Takashi Iwai 1 participant 1 message Jul 26, 2018 Sound

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: trident: Suppress gcc string warning

The meddlesome gcc warns about the possible shortname string in
trident driver code:
sound/pci/trident/trident.c: In function ‘snd_trident_probe’:
sound/pci/trident/trident.c:126:2: warning: ‘strcat’ accessing 17 or more bytes at offsets 36 and 20 may overlap 1 byte at offset 36 [-Wrestrict] strcat(card->shortname, card->driver);

It happens since gcc calculates the possible string size from card->driver, but this can't be true since we did set the string just before that, and they are much shorter.

For shutting it up, use the exactly same string set to card->driver for strcat() to card->shortname, too.

---
 sound/pci/trident/trident.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/pci/trident/trident.c +1 -1
index cedf13b64803..2f18b1cdc2cd 100644
@@ -123,7 +123,7 @@ static int snd_trident_probe(struct pci_dev *pci,
 	} else {
 		strcpy(card->shortname, "Trident ");
 	}
-	strcat(card->shortname, card->driver);
+	strcat(card->shortname, str);
 	sprintf(card->longname, "%s PCI Audio at 0x%lx, irq %d",
 		card->shortname, trident->port, trident->irq);
 
Signature · 6 lines
2.18.0

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel