]> git.proxmox.com Git - mirror_ovs.git/commitdiff
ovs-thread: Add thread safety annotation to cond_wait.
authorIlya Maximets <i.maximets@samsung.com>
Mon, 10 Dec 2018 17:05:23 +0000 (20:05 +0300)
committerBen Pfaff <blp@ovn.org>
Mon, 10 Dec 2018 17:52:55 +0000 (09:52 -0800)
This fixes build with clang on FreeBSD:

  lib/ovs-thread.c:266:13: error:

  calling function 'pthread_cond_wait' requires holding mutex \
  'mutex->lock' exclusively [-Werror,-Wthread-safety-analysis]

      error = pthread_cond_wait(cond, &mutex->lock);
              ^

Fixes: 97be153858b4 ("clang: Add annotations for thread safety check.")
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
include/openvswitch/thread.h
lib/ovs-thread.c

index 5ffc290677f33fbd313d040553cc41b8b001b215..2987db37c9dcbaebb8b5baba5115e11eb1d899e0 100644 (file)
@@ -68,7 +68,8 @@ int ovs_mutex_trylock_at(const struct ovs_mutex *mutex, const char *where)
 #define ovs_mutex_trylock(mutex) \
         ovs_mutex_trylock_at(mutex, OVS_SOURCE_LOCATOR)
 
-void ovs_mutex_cond_wait(pthread_cond_t *, const struct ovs_mutex *);
+void ovs_mutex_cond_wait(pthread_cond_t *, const struct ovs_mutex *mutex)
+    OVS_REQUIRES(mutex);
 \f
 /* Convenient once-only execution.
  *
index b5f7424b7f8a99608570ab15fa861e3d94d4f749..c8d92bc1b923985cc07dcfbc378f5e153172ca9f 100644 (file)
@@ -257,6 +257,7 @@ ovs_rwlock_init(const struct ovs_rwlock *l_)
  * call with calls to ovsrcu_quiesce_start() and ovsrcu_quiesce_end().  */
 void
 ovs_mutex_cond_wait(pthread_cond_t *cond, const struct ovs_mutex *mutex_)
+    OVS_NO_THREAD_SAFETY_ANALYSIS
 {
     struct ovs_mutex *mutex = CONST_CAST(struct ovs_mutex *, mutex_);
     int error;