If I want to use a function that may return an error, for example thread_mutexattr_init(&myAttr), if this function returns an error it will automatically set errno with the number of the error or should I set errno to the return of this function?
For example what is right to do?
if((errno = pthread_mutexattr_init(&myAttr)) != 0){ if(errno == EBUSY){ perror("some error message because of EBUSY"); }else{ perror("another error message"); } Or this:
if(pthread_mutexattr_init(&myAttr) < 0){ if(errno == EBUSY){ perror("some error message because of EBUSY"); }else{ perror("another error message"); } }