[alsa-devel] [PATCH v3 2/2] ASoC: dapm: harden use of lookup tables

Takashi Iwai tiwai at suse.de
Mon Feb 4 21:31:35 CET 2019


On Mon, 04 Feb 2019 21:27:10 +0100,
Pierre-Louis Bossart wrote:
> 
>  static void dapm_assert_locked(struct snd_soc_dapm_context *dapm)
> @@ -1425,11 +1425,22 @@ static int dapm_seq_compare(struct snd_soc_dapm_widget *a,
>  {
>  	int *sort;
>  
> +	WARN_ONCE(ARRAY_SIZE(dapm_up_seq) != SND_SOC_DAPM_TYPE_LAST,
> +		  "bad size for dapm_up_seq, expected %d\n",
> +		  SND_SOC_DAPM_TYPE_LAST);
> +
> +	WARN_ONCE(ARRAY_SIZE(dapm_down_seq) != SND_SOC_DAPM_TYPE_LAST,
> +		  "bad size for dapm_down_seq, expected %d\n",
> +		  SND_SOC_DAPM_TYPE_LAST);

Would BUILD_BUG_ON() work for these instead?
It's not available, but if it works, better than the runtime check.


thanks,

Takashi


More information about the Alsa-devel mailing list