All of lore.kernel.org
 help / color / mirror / Atom feed
* Question about card names
@ 2019-05-29  4:41 Kuninori Morimoto
  2019-05-29  4:56 ` Kuninori Morimoto
  2019-05-29  5:29 ` Takashi Iwai
  0 siblings, 2 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2019-05-29  4:41 UTC (permalink / raw)
  To: Linux-ALSA


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about card names
  2019-05-29  4:41 Question about card names Kuninori Morimoto
@ 2019-05-29  4:56 ` Kuninori Morimoto
  2019-05-29  5:29 ` Takashi Iwai
  1 sibling, 0 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2019-05-29  4:56 UTC (permalink / raw)
  To: Linux-ALSA


Hi

> 		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;
> 			}
(snip)
> 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 ??

Grr
This break is for "switch", not for "for"...


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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about card names
  2019-05-29  4:41 Question about card names Kuninori Morimoto
  2019-05-29  4:56 ` Kuninori Morimoto
@ 2019-05-29  5:29 ` Takashi Iwai
  2019-05-29  6:12   ` Kuninori Morimoto
  1 sibling, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2019-05-29  5:29 UTC (permalink / raw)
  To: Kuninori Morimoto; +Cc: Linux-ALSA

On Wed, 29 May 2019 06:41:35 +0200,
Kuninori Morimoto wrote:
> 
> 
> 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 ??

Do you mean the normalization of strings, or do you suggest to make
mandatory?  The normalization isn't needed for other name strings.
The driver name is somewhat special, as it's used as a key for
searches in the user-space.

> 	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".

We do replace the two '?' in the latter case, too.  It's a break
statement in a switch block, i.e. just skip the case.


Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question about card names
  2019-05-29  5:29 ` Takashi Iwai
@ 2019-05-29  6:12   ` Kuninori Morimoto
  0 siblings, 0 replies; 4+ messages in thread
From: Kuninori Morimoto @ 2019-05-29  6:12 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Linux-ALSA


Hi

> > 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 ??
> 
> Do you mean the normalization of strings, or do you suggest to make
> mandatory?  The normalization isn't needed for other name strings.
> The driver name is somewhat special, as it's used as a key for
> searches in the user-space.

Ahh, OK, I see.
Thank you for clearing it.
I want to have this explain at there (= I will post it, soon)

> > 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".
> 
> We do replace the two '?' in the latter case, too.  It's a break
> statement in a switch block, i.e. just skip the case.

Thanks.
My head is very spaghetting now...

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-05-29  6:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-29  4:41 Question about card names Kuninori Morimoto
2019-05-29  4:56 ` Kuninori Morimoto
2019-05-29  5:29 ` Takashi Iwai
2019-05-29  6:12   ` Kuninori Morimoto

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.