[PATCH v2 2/6] thread.h: Fix Coverity version of qemu_cond_timedwait()

Peter Maydell posted 6 patches 5 years, 10 months ago
Maintainers: Peter Maydell <peter.maydell@linaro.org>, Riku Voipio <riku.voipio@iki.fi>, Laurent Vivier <laurent@vivier.eu>
[PATCH v2 2/6] thread.h: Fix Coverity version of qemu_cond_timedwait()
Posted by Peter Maydell 5 years, 10 months ago
For Coverity's benefit, we provide simpler versions of functions like
qemu_mutex_lock(), qemu_cond_wait() and qemu_cond_timedwait().  When
we added qemu_cond_timedwait() in commit 3dcc9c6ec4ea, a cut and
paste error meant that the Coverity version of qemu_cond_timedwait()
was using the wrong _impl function, which makes the Coverity parser
complain:

"/qemu/include/qemu/thread.h", line 159: warning #140: too many arguments in
          function call
      return qemu_cond_timedwait(cond, mutex, ms);
             ^

"/qemu/include/qemu/thread.h", line 159: warning #120: return value type does
          not match the function type
      return qemu_cond_timedwait(cond, mutex, ms);
             ^

"/qemu/include/qemu/thread.h", line 156: warning #1563: function
          "qemu_cond_timedwait" not emitted, consider modeling it or review
          parse diagnostics to improve fidelity
  static inline bool (qemu_cond_timedwait)(QemuCond *cond, QemuMutex *mutex,
                      ^

These aren't fatal, but reduce the scope of the analysis. Fix the error.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 include/qemu/thread.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/qemu/thread.h b/include/qemu/thread.h
index 047db0307e7..10262c63f58 100644
--- a/include/qemu/thread.h
+++ b/include/qemu/thread.h
@@ -67,7 +67,7 @@ extern QemuCondTimedWaitFunc qemu_cond_timedwait_func;
 #define qemu_cond_wait(c, m)                                            \
             qemu_cond_wait_impl(c, m, __FILE__, __LINE__);
 #define qemu_cond_timedwait(c, m, ms)                                   \
-            qemu_cond_wait_impl(c, m, ms, __FILE__, __LINE__);
+            qemu_cond_timedwait_impl(c, m, ms, __FILE__, __LINE__);
 #else
 #define qemu_mutex_lock(m) ({                                           \
             QemuMutexLockFunc _f = atomic_read(&qemu_mutex_lock_func);  \
-- 
2.20.1


Re: [PATCH v2 2/6] thread.h: Fix Coverity version of qemu_cond_timedwait()
Posted by Philippe Mathieu-Daudé 5 years, 10 months ago
On 3/19/20 8:33 PM, Peter Maydell wrote:
> For Coverity's benefit, we provide simpler versions of functions like
> qemu_mutex_lock(), qemu_cond_wait() and qemu_cond_timedwait().  When
> we added qemu_cond_timedwait() in commit 3dcc9c6ec4ea, a cut and
> paste error meant that the Coverity version of qemu_cond_timedwait()
> was using the wrong _impl function, which makes the Coverity parser
> complain:
> 
> "/qemu/include/qemu/thread.h", line 159: warning #140: too many arguments in
>            function call
>        return qemu_cond_timedwait(cond, mutex, ms);
>               ^
> 
> "/qemu/include/qemu/thread.h", line 159: warning #120: return value type does
>            not match the function type
>        return qemu_cond_timedwait(cond, mutex, ms);
>               ^
> 
> "/qemu/include/qemu/thread.h", line 156: warning #1563: function
>            "qemu_cond_timedwait" not emitted, consider modeling it or review
>            parse diagnostics to improve fidelity
>    static inline bool (qemu_cond_timedwait)(QemuCond *cond, QemuMutex *mutex,
>                        ^
> 
> These aren't fatal, but reduce the scope of the analysis. Fix the error.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   include/qemu/thread.h | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/qemu/thread.h b/include/qemu/thread.h
> index 047db0307e7..10262c63f58 100644
> --- a/include/qemu/thread.h
> +++ b/include/qemu/thread.h
> @@ -67,7 +67,7 @@ extern QemuCondTimedWaitFunc qemu_cond_timedwait_func;
>   #define qemu_cond_wait(c, m)                                            \
>               qemu_cond_wait_impl(c, m, __FILE__, __LINE__);
>   #define qemu_cond_timedwait(c, m, ms)                                   \
> -            qemu_cond_wait_impl(c, m, ms, __FILE__, __LINE__);
> +            qemu_cond_timedwait_impl(c, m, ms, __FILE__, __LINE__);
>   #else
>   #define qemu_mutex_lock(m) ({                                           \
>               QemuMutexLockFunc _f = atomic_read(&qemu_mutex_lock_func);  \
> 

Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>


Re: [PATCH v2 2/6] thread.h: Fix Coverity version of qemu_cond_timedwait()
Posted by Richard Henderson 5 years, 10 months ago
On 3/19/20 12:33 PM, Peter Maydell wrote:
> For Coverity's benefit, we provide simpler versions of functions like
> qemu_mutex_lock(), qemu_cond_wait() and qemu_cond_timedwait().  When
> we added qemu_cond_timedwait() in commit 3dcc9c6ec4ea, a cut and
> paste error meant that the Coverity version of qemu_cond_timedwait()
> was using the wrong _impl function, which makes the Coverity parser
> complain:
> 
> "/qemu/include/qemu/thread.h", line 159: warning #140: too many arguments in
>           function call
>       return qemu_cond_timedwait(cond, mutex, ms);
>              ^
> 
> "/qemu/include/qemu/thread.h", line 159: warning #120: return value type does
>           not match the function type
>       return qemu_cond_timedwait(cond, mutex, ms);
>              ^
> 
> "/qemu/include/qemu/thread.h", line 156: warning #1563: function
>           "qemu_cond_timedwait" not emitted, consider modeling it or review
>           parse diagnostics to improve fidelity
>   static inline bool (qemu_cond_timedwait)(QemuCond *cond, QemuMutex *mutex,
>                       ^
> 
> These aren't fatal, but reduce the scope of the analysis. Fix the error.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  include/qemu/thread.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~