On Tue, 2008-09-02 16:23:32 +0100, Colin Guthrie <gmane at colin.guthr.ie> wrote: > Jan-Benedict Glaw wrote: > > Right, because error handling and assertions were mixed up. Error > > handling is for errors that could expectedly happen (eg. malloc() > > returns a NULL pointer, user requests an operation that's invalid in > > this context, ...) > > So when malloc fails, you should be able to recover? I would have > thought that if malloc fails you're pretty much screwed, no? Free() what you did already malloc() at the local scope and return NULL or whatever signals the calling party that we hit an OOM situation. Same for any other call that could fail, eg. open() calls, or anything network related, or ... > I mean if you cannot allocate memory then how are you going to compile a > string to display to the user what's wrong? (Unless you keep a > pre-malloced error buffer around I guess). You cannot. Either leave the calling function a *choice* to print out a prepared error message, or just kill the whole program. Maybe eg. initializing the sound system was only done to produce a beep that wasn't important at all? No problem, just ignore that part. You're an important sound application? Maybe you'd exit() out... With assert, you don't have that choice anymore. > > Assertions should be put on conditions that a user should *never* be > > able to provoke in *any* circumstance > > Is this a hard and fast "rule" of assertions in programming or an > opinion? Just curious :) I never thought about it, but that's my option, my opinion, and my rule, too :) > >> I'm not really sure of the value in disabling asserts. If they are being > >> hit, then this just means there are bugs to be fixed! > > I didn't mean disabling the asserts in pulse as it stands, I meant why > disable them at all? What does it actually gain? But I appreciate why > this could be useful now. You probably gain a minimum amount of speed or a bit less consumed CPU cycles with disabling the asserts. OTOH, disabling them will break error handling. MfG, JBG -- Jan-Benedict Glaw jbglaw at lug-owl.de +49-172-7608481 Signature of: They that give up essential liberty to obtain temporary safety, the second : deserve neither liberty nor safety. (Ben Franklin) -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 189 bytes Desc: Digital signature URL: <http://lists.freedesktop.org/archives/pulseaudio-discuss/attachments/20080902/af272ec3/attachment.pgp>