switch to non-zero PTHREAD_*_INITIALIZER

Poul-Henning Kamp phk at phk.freebsd.dk
Mon Feb 11 11:06:27 UTC 2019


--------
In message <20190211103807.GX24863 at kib.kiev.ua>, Konstantin Belousov writes:
>On Mon, Feb 11, 2019 at 09:43:42AM +0000, Poul-Henning Kamp wrote:
>> 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 ?
>
>This would make the startup (or more) of current binaries too noisy and
>perhaps even break the applications that depend on specific output from
>the subordinate processes.

Right, we probably should make it tweakable with something like /etc/malloc.conf.


-- 
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