[2/3] eal: emit warning for unused trylock return value

Message ID 20220411151559.164217-2-mattias.ronnblom@ericsson.com (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [1/3] eal: add macro to warn for unused function return values |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Mattias Rönnblom April 11, 2022, 3:15 p.m. UTC
  Mark the trylock family of spinlock functions with
__rte_warn_unused_result.

Acked-by: Bruce Richardson <bruce.richardson@intel.com>

Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
---
 lib/eal/include/generic/rte_spinlock.h | 4 ++++
 1 file changed, 4 insertions(+)
  

Comments

Morten Brørup April 11, 2022, 3:29 p.m. UTC | #1
> From: Mattias Rönnblom [mailto:mattias.ronnblom@ericsson.com]
> Sent: Monday, 11 April 2022 17.16
> 
> Mark the trylock family of spinlock functions with
> __rte_warn_unused_result.
> 
> Acked-by: Bruce Richardson <bruce.richardson@intel.com>
> 
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom@ericsson.com>
> ---
>  lib/eal/include/generic/rte_spinlock.h | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/lib/eal/include/generic/rte_spinlock.h
> b/lib/eal/include/generic/rte_spinlock.h
> index 40fe49d5ad..73ed4bfbdc 100644
> --- a/lib/eal/include/generic/rte_spinlock.h
> +++ b/lib/eal/include/generic/rte_spinlock.h
> @@ -97,6 +97,7 @@ rte_spinlock_unlock (rte_spinlock_t *sl)
>   * @return
>   *   1 if the lock is successfully taken; 0 otherwise.
>   */
> +__rte_warn_unused_result
>  static inline int
>  rte_spinlock_trylock (rte_spinlock_t *sl);
> 
> @@ -174,6 +175,7 @@ rte_spinlock_unlock_tm(rte_spinlock_t *sl);
>   *   1 if the hardware memory transaction is successfully started
>   *   or lock is successfully taken; 0 otherwise.
>   */
> +__rte_warn_unused_result
>  static inline int
>  rte_spinlock_trylock_tm(rte_spinlock_t *sl);
> 
> @@ -243,6 +245,7 @@ static inline void
> rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)
>   * @return
>   *   1 if the lock is successfully taken; 0 otherwise.
>   */
> +__rte_warn_unused_result
>  static inline int
> rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr)
>  {
>  	int id = rte_gettid();
> @@ -299,6 +302,7 @@ static inline void
> rte_spinlock_recursive_unlock_tm(
>   *   1 if the hardware memory transaction is successfully started
>   *   or lock is successfully taken; 0 otherwise.
>   */
> +__rte_warn_unused_result
>  static inline int rte_spinlock_recursive_trylock_tm(
>  	rte_spinlock_recursive_t *slr);
> 
> --
> 2.25.1
> 

Acked-by: Morten Brørup <mb@smartsharesystems.com>
  

Patch

diff --git a/lib/eal/include/generic/rte_spinlock.h b/lib/eal/include/generic/rte_spinlock.h
index 40fe49d5ad..73ed4bfbdc 100644
--- a/lib/eal/include/generic/rte_spinlock.h
+++ b/lib/eal/include/generic/rte_spinlock.h
@@ -97,6 +97,7 @@  rte_spinlock_unlock (rte_spinlock_t *sl)
  * @return
  *   1 if the lock is successfully taken; 0 otherwise.
  */
+__rte_warn_unused_result
 static inline int
 rte_spinlock_trylock (rte_spinlock_t *sl);
 
@@ -174,6 +175,7 @@  rte_spinlock_unlock_tm(rte_spinlock_t *sl);
  *   1 if the hardware memory transaction is successfully started
  *   or lock is successfully taken; 0 otherwise.
  */
+__rte_warn_unused_result
 static inline int
 rte_spinlock_trylock_tm(rte_spinlock_t *sl);
 
@@ -243,6 +245,7 @@  static inline void rte_spinlock_recursive_unlock(rte_spinlock_recursive_t *slr)
  * @return
  *   1 if the lock is successfully taken; 0 otherwise.
  */
+__rte_warn_unused_result
 static inline int rte_spinlock_recursive_trylock(rte_spinlock_recursive_t *slr)
 {
 	int id = rte_gettid();
@@ -299,6 +302,7 @@  static inline void rte_spinlock_recursive_unlock_tm(
  *   1 if the hardware memory transaction is successfully started
  *   or lock is successfully taken; 0 otherwise.
  */
+__rte_warn_unused_result
 static inline int rte_spinlock_recursive_trylock_tm(
 	rte_spinlock_recursive_t *slr);