[alsa-devel] Question about card names

Kuninori Morimoto kuninori.morimoto.gx at renesas.com
Wed May 29 06:41:35 CEST 2019


Hi ALSA ML

snd_soc_instantiate_card() setups card->snd_card's
"shortname", "longname", "driver" names. (= 1,2,3).

But, it cares only card->snd_card->driver (= 4).
I think we need to care about all naming, but why only driver ??

	static int snd_soc_instantiate_card(struct snd_soc_card *card)
	{
		...
1=>		snprintf(card->snd_card->shortname, sizeof(card->snd_card->shortname),
			 "%s", card->name);
2=>		snprintf(card->snd_card->longname, sizeof(card->snd_card->longname),
			 "%s", card->long_name ? card->long_name : card->name);
3=>		snprintf(card->snd_card->driver, sizeof(card->snd_card->driver),
			 "%s", card->driver_name ? card->driver_name : card->name);
		for (i = 0; i < ARRAY_SIZE(card->snd_card->driver); i++) {
			switch (card->snd_card->driver[i]) {
x=>			case '_':
x=>			case '-':
			case '\0':
				break;
			default:
				if (!isalnum(card->snd_card->driver[i]))
4=>					card->snd_card->driver[i] = '_';
				break;
			}
		}
		...
	}

And, it seems in this loop, it breaks check if it finds "_" or "-" (= x).
If my understanding was correct,
the naming "abcd??efg" will be fixed to "abcd__efg",
but, it do nothing if name was for example "-abcd??efg".
Is this bug ??

Thank you for your help !!
Best regards
---
Kuninori Morimoto


More information about the Alsa-devel mailing list