diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-18 12:08:29 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-07-19 09:06:12 +0200 |
commit | 8a08eaedfb2c9a6c002220a61c5b1f8ce1130f54 (patch) | |
tree | 12037afc12827a72160a2055d2f9e3c181032844 /sal/osl/unx | |
parent | cdbe8a8700d5460e41d80b00310c6ff8977bc492 (diff) |
coverity concurrency annotation attempt
Let us see what happens if we annotate our mutex code,
https://scan.coverity.com/models
Change-Id: I7baf44d1a252f19b4ae47f3a6b318f7ccd9629d7
Reviewed-on: https://gerrit.libreoffice.org/75851
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sal/osl/unx')
-rw-r--r-- | sal/osl/unx/mutex.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sal/osl/unx/mutex.cxx b/sal/osl/unx/mutex.cxx index 72bcc370eebb..8cdc2a071376 100644 --- a/sal/osl/unx/mutex.cxx +++ b/sal/osl/unx/mutex.cxx @@ -85,6 +85,12 @@ void SAL_CALL osl_destroyMutex(oslMutex pMutex) } } +#ifdef __COVERITY__ + extern void __coverity_recursive_lock_acquire__(void*); + extern void __coverity_recursive_lock_release__(void*); + extern void __coverity_assert_locked__(void*); +#endif + sal_Bool SAL_CALL osl_acquireMutex(oslMutex pMutex) { SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); @@ -97,6 +103,9 @@ sal_Bool SAL_CALL osl_acquireMutex(oslMutex pMutex) SAL_WARN("sal.osl.mutex", "pthread_mutex_lock failed: " << UnixErrnoString(nRet)); return false; } +#ifdef __COVERITY__ + __coverity_recursive_lock_acquire__(pMutex); +#endif return true; } @@ -114,7 +123,12 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex pMutex) { int nRet = pthread_mutex_trylock(&(pMutex->mutex)); if ( nRet == 0 ) + { +#ifdef __COVERITY__ + __coverity_recursive_lock_acquire__(pMutex); +#endif result = true; + } } return result; @@ -122,6 +136,9 @@ sal_Bool SAL_CALL osl_tryToAcquireMutex(oslMutex pMutex) sal_Bool SAL_CALL osl_releaseMutex(oslMutex pMutex) { +#ifdef __COVERITY__ + __coverity_assert_locked__(pMutex); +#endif SAL_WARN_IF(!pMutex, "sal.osl.mutex", "null pMutex"); if ( pMutex ) @@ -133,6 +150,9 @@ sal_Bool SAL_CALL osl_releaseMutex(oslMutex pMutex) return false; } +#ifdef __COVERITY__ + __coverity_recursive_lock_release__(pMutex); +#endif return true; } |