The POSIX standard does not explicitly define that this parameter can be NULL.
To prevent any possible problems, allow NULL but when NULL is received, use a temporary variable in its place.
#ifndef _di_f_thread_cancel_state_set_
f_status_t f_thread_cancel_state_set(const int state, int *previous) {
- const int error = pthread_setcancelstate(state, previous);
+ int error = 0;
+
+ // POSIX doesn't allow this to be NULL, so make POSIX happy.
+ if (previous == 0) {
+ int ignore = 0;
+
+ error = pthread_setcancelstate(state, &ignore);
+ }
+ else {
+ error = pthread_setcancelstate(state, previous);
+ }
if (error) {
if (error == EINVAL) return F_status_set_error(F_parameter);
* @param previous
* (optional) The previously assigned cancellation state.
* Set to NULL to not use.
- * (Note: Linux allows this to be optional/NULL but POSIX does not explicitly defined this and there may be portability issues.)
*
* @return
* F_none on success.