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

Clemens Ladisch clemens at ladisch.de
Sun Nov 16 21:57:36 CET 2014


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.


Regards,
Clemens


More information about the Alsa-devel mailing list