I went through all of the thread safety warnings raised by clang but all
are false positives. Generally they arise from code which does
something like this:
if (cond) pthread_mutex_lock(m); ... if (cond) pthread_mutex_unlock(m);
Or a more complicated example in pci_xhci_handle_transfer():
retry: <usb xfer lock should be held here> ... if (!do_retry) pthread_mutex_unlock(usb xfer lock); ... if (do_retry) goto retry;
The lock_annotate() macro in cdefs.h is not very useful since it
seemingly can't be used to refer to function parameters, e.g.,
&sc->sc_mtx. To silence warnings I ended up having to annotate
functions with no_lock_analysis.
In my opinion the warnings aren't very useful and won't catch anything
but the most straightforward locking bugs, and they probably won't even
do that since many functions which have some non-trivial locking pattern
will be annotated with __no_lock_analysis anyway. So let's just turn
them off.