[pulseaudio-discuss] [PATCH 1/2] Properly initialise m->n_waiting_for_accept to prevent deadlock

Lennart Poettering lennart at poettering.net
Tue Jan 5 06:24:37 PST 2010


On Tue, 05.01.10 09:51, Colin Guthrie (gmane at colin.guthr.ie) wrote:

> 
> Would it be generally cleaner to just allocate the "m" struct with
> pa_xnew0() rather than pa_xnew()? That way neither n_waiting nor
> n_waiting_for_accept need to be explicitly set.

I didn't use to use pa_xnew0() for cases like this, because with
pa_xnew() missing field initializations would show up immediately in
valgrind, and this hence forces me to think about the proper
initializations for the fields.

But nowadays I tend to think differently about this and can only
recommend using pa_xnew0() since for every non-trivial object you'll
otherwise end up with a lot of pointless null assignments which makes
the code very much unreadable and hides which initializations actually
really matter. In the end code readability is more important than
valgrind friendliness.  Also, valgrind normally does not work on
fedora rawhide anyway anymore so optimizing for valgrind use is a
pointless excercise.

Lennart

-- 
Lennart Poettering                        Red Hat, Inc.
lennart [at] poettering [dot] net
http://0pointer.net/lennart/           GnuPG 0x1A015CC4



More information about the pulseaudio-discuss mailing list