Hi, developers, I have a suggestion about error handlings for locking. Would it be better to handle the possible errors that return from pthread_mutex_lock.
For example, this example does not check the value returned by pthread_mutex_lock() for errors. If pthread_mutex_lock() cannot acquire the mutex for any reason, the function may introduce a race condition into the program (CWE-413).
The manners of error handlings could be flagging any warnings or returning before accessing the critical region.
Hi, developers, I have a suggestion about error handlings for locking. Would it be better to handle the possible errors that return from
pthread_mutex_lock
.For example, this example does not check the value returned by pthread_mutex_lock() for errors. If pthread_mutex_lock() cannot acquire the mutex for any reason, the function may introduce a race condition into the program (CWE-413).
The manners of error handlings could be flagging any warnings or returning before accessing the critical region.
https://github.com/shlomif/fc-solve/blob/45efed24104b1c3ac80efb44904579d0fb238ae4/fc-solve/source/lock.h#L71-L74