News for hackers. Stuff that matters.
Re:fork() can fail by unwind on Thursday August 21, 2014 @03:35AM (#8206255)
Huh? You do realize that the standard assert() macro already is compiled out if NDEBUG is defined, right?

Your code could just as well be written as

    assert(pthread_mutex_unlock(&lock) == 0);
which of course has the added benefit of not inventing anything new, i.e. being standard and immediately understood by anyone who knows the language and its libraries reasonably well.
Re:fork() can fail by unwind on Thursday August 21, 2014 @06:08AM (#8206626)
Replying to self since I can't edit: d'oh. Yes, I totally mis-read the original code. I should have relized why the other comment questioning this practice had been down-voted, heh.

Of course not unlocking the mutex in non-debug builds would be a problem.

Thanks, and sorry.

Re:fork() can fail by screwt on Thursday August 21, 2014 @04:05AM (#8206344)
As per jacquesm's comment below[0], your example would, by default, be compiled out if NDEBUG is defined. So in production you'd never release the lock.

[0] https://news.ycombinator.com/item?id=8206258

Re:fork() can fail by quotemstr on Thursday August 21, 2014 @04:09AM (#8206362)
You're misreading the code. When NDEBUG is defined, we don't use assert, but instead always evaluate the expression. The overall effect is that we always evaluate VERIFY's argument, but only check it in debug builds.
Re:fork() can fail by baruch on Thursday August 21, 2014 @04:05AM (#8206343)
Be very careful with that. When compiled under NDEBUG and the assert gone, the mutex unlock will be gone too and you'll wonder why the application stops working.