switch to non-zero PTHREAD_*_INITIALIZER

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Feb 11 09:43:52 UTC 2019


Right now most of our PTHREAD_*_INITIALIZER macros are defined as NULL.

This is a bad choice from a code quality point of view, because it means
that

	pthread_t my_mutex;

and

	pthread_t my_mutes = PTHREAD_MUTEX_INITIALIZER;

act the same, which they are not.

I suggest that we should change the macros to a non-NULL value, and
add a check for NULL values which emit a warning about the lack of
initialization.

Comments ?

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-arch mailing list