[alsa-devel] [PATCH 1/4] pulse: get rid of a number of assert()s

Colin Guthrie gmane at colin.guthr.ie
Fri Jul 31 16:48:32 CEST 2009


'Twas brillig, and Lennart Poettering at 31/07/09 15:01 did gyre and gimble:
> Instead of hitting an assert when any of the plugin functions is called
> in an invalid context we should return a clean error to make sure
> programs are not unnecessarily aborted.
> 
> This should fix issues such as http://pulseaudio.org/ticket/595
> ---
>  pulse/ctl_pulse.c |   35 +++++++++++++++++------
>  pulse/pcm_pulse.c |   79 +++++++++++++++++++++++++++++++++++++++++------------
>  pulse/pulse.c     |   34 ++++++++++++++++-------
>  3 files changed, 111 insertions(+), 37 deletions(-)
> 
> diff --git a/pulse/ctl_pulse.c b/pulse/ctl_pulse.c
> index c6cf9e2..1b057ef 100644
> --- a/pulse/ctl_pulse.c
> +++ b/pulse/ctl_pulse.c

> @@ -525,8 +542,8 @@ static int pulse_ctl_poll_revents(snd_ctl_ext_t * ext, struct pollfd *pfd,
>  	snd_ctl_pulse_t *ctl = ext->private_data;
>  	int err = 0;
>  
> -	assert(ctl);
> -	assert(ctl->p);
> +	if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
> +		return -EBADFD;
>  
>  	pa_threaded_mainloop_lock(ctl->p->mainloop);
>  


Just a smidge overzealous in this one (only one I spotted).


Couldn't find these commits in your alsa-plugins clone at 
git://git.0pointer.de/alsa-plugins.git so couldn't create a followup 
patch so here it is inline (against 1.2.20 so line numbers may be off):

--- alsa-plugins-1.0.20/pulse/ctl_pulse.c~	2009-07-31 15:39:22.000000000 
+0100
+++ alsa-plugins-1.0.20/pulse/ctl_pulse.c	2009-07-31 15:47:32.000000000 
+0100
@@ -542,6 +542,8 @@
  	snd_ctl_pulse_t *ctl = ext->private_data;
  	int err = 0;

+	assert(ctl);
+
  	if (!ctl->p || !ctl->p->mainloop || !ctl->p->context)
  		return -EBADFD;




Col.




-- 

Colin Guthrie
gmane(at)colin.guthr.ie
http://colin.guthr.ie/

Day Job:
   Tribalogic Limited [http://www.tribalogic.net/]
Open Source:
   Mandriva Linux Contributor [http://www.mandriva.com/]
   PulseAudio Hacker [http://www.pulseaudio.org/]
   Trac Hacker [http://trac.edgewall.org/]



More information about the Alsa-devel mailing list