[igt-dev] [PATCH i-g-t 1/2] lib/igt_audio: add more assertions

Ser, Simon simon.ser at intel.com
Mon May 27 10:22:36 UTC 2019


On Mon, 2019-05-27 at 13:07 +0300, Martin Peres wrote:
> 
> On 23/05/2019 13:56, Simon Ser wrote:
> > - Make sure an audio signal isn't created with zero channels
> > - Make sure each channel has at least one frequency when synthesizing
> > 
> > Signed-off-by: Simon Ser <simon.ser at intel.com>
> > ---
> >  lib/igt_audio.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/lib/igt_audio.c b/lib/igt_audio.c
> > index 376e04ba6ed6..1677dd09c029 100644
> > --- a/lib/igt_audio.c
> > +++ b/lib/igt_audio.c
> > @@ -80,6 +80,7 @@ struct audio_signal *audio_signal_init(int channels, int sampling_rate)
> >  {
> >  	struct audio_signal *signal;
> >  
> > +	igt_assert(channels > 0);
> >  	igt_assert(channels <= CHANNELS_MAX);
> >  
> >  	signal = malloc(sizeof(struct audio_signal));
> > @@ -267,8 +268,10 @@ void audio_signal_fill(struct audio_signal *signal, double *buffer,
> >  
> >  	memset(buffer, 0, sizeof(double) * signal->channels * samples);
> >  
> > -	for (i = 0; i < signal->channels; i++)
> > +	for (i = 0; i < signal->channels; i++) {
> >  		freqs_per_channel[i] = audio_signal_count_freqs(signal, i);
> > +		igt_assert(freqs_per_channel[i]);
> 
> IMO, adding > 0 would be clearer.

Ah. I prefer adding explicit conditions like this too, but I had a
feeling the hardcore computer touchers out there wouldn't like it. :)

Will change it.

> With this done, the series is:
> 
> Reviewed-by: Martin Peres <martin.peres at linux.intel.com>
> 
> > +	}
> >  
> >  	for (i = 0; i < signal->freqs_count; i++) {
> >  		freq = &signal->freqs[i];
> > 


More information about the igt-dev mailing list