[alsa-devel] [PATCH 25/29] ALSA: oxfw: Add support for Behringer/Mackie devices

Takashi Sakamoto o-takashi at sakamocchi.jp
Tue Nov 18 16:24:40 CET 2014


Hi Clemens,

On Nov 17 2014 05:57, Clemens Ladisch wrote:
> Takashi Sakamoto wrote:
>> +++ b/sound/firewire/oxfw/oxfw.c
>> +static bool detect_loud_models(struct fw_unit *unit)
>> +{
>> +	const char *const models[] = {
>> +		"Onyxi",
>> +		"Onyx-i",
>> +		"d.Pro",
>> +		"Mackie Onyx Satellite",
>> +		"Tapco LINK.firewire 4x6",
>> +		"U.420"};
>> +	char model[32] = {0};
> 
> This initialization is not needed.
> 
>> +	unsigned int i;
>> +	int err;
>> +
>> +	err = fw_csr_string(unit->directory, CSR_MODEL,
>> +			    model, sizeof(model));
>> +	if (err < 0)
>> +		return err;
>> +
>> +	model[31] = '\0';
> 
> The returned string is guaranteed to be zero-terminated.
> 
>> +	for (i = 0; i < ARRAY_SIZE(models); i++) {
>> +		if (strncmp(models[i], model, strlen(model) == 0))
> 
> Why not simply strcmp()?
> 
>>  static int name_card(struct snd_oxfw *oxfw)
>>  {
>>  	struct fw_device *fw_dev = fw_parent_device(oxfw->unit);
>> +	char vendor[24] = {0};
>> +	char model[32] = {0};
> 
> Same unneeded initialization.

I forgot that fw_csr_string() guarantees to return string with
null-terminated...


Thanks

Takashi Sakamoto



More information about the Alsa-devel mailing list