I checked the return value of the library function pthread_mutex_init ().
At work, I was looking at the code written by BP (Business Partner). Then check the return value of pthead_mutex_init ()
hoge.c
if (r == -1)
{
//Error handling
}
Was written.
I "... -1 !?"
It varies depending on the page, but it was roughly the following three.
-Pthread_mutex_init () always returns 0. or -Pthread_mutex_init () returns 0 when normal and -1 when abnormal. or -Pthread_mutex_init () returns 0 when normal and nonzero when abnormal.
Is it environment-dependent?
For the time being, regarding the check of the return value
hoge.c
if (r != 0)
{
//Error handling
}
I wonder if it should be non-zero.
Recommended Posts