posix_tls: refine error handling