[RFC 1/3] eal: add macro to warn for unused function return values
Morten Brørup
mb at smartsharesystems.com
Mon Apr 11 09:17:38 CEST 2022
> From: Mattias Rönnblom [mailto:mattias.ronnblom at ericsson.com]
> Sent: Sunday, 10 April 2022 15.52
>
> This patch adds a wrapper macro __rte_warn_unused_result for the
> warn_unused_result function attribute.
>
> Marking a function __rte_warn_unused_result will make the compiler
> emit a warning in case the caller does not use the function's return
> value.
>
> Signed-off-by: Mattias Rönnblom <mattias.ronnblom at ericsson.com>
> ---
> lib/eal/include/rte_common.h | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/lib/eal/include/rte_common.h
> b/lib/eal/include/rte_common.h
> index 4a399cc7c8..544e7de2e7 100644
> --- a/lib/eal/include/rte_common.h
> +++ b/lib/eal/include/rte_common.h
> @@ -222,6 +222,11 @@ static void
> __attribute__((destructor(RTE_PRIO(prio)), used)) func(void)
> */
> #define __rte_noreturn __attribute__((noreturn))
>
> +/**
> + * Issue warning in case the function's return value is ignore
Typo: ignore -> ignored
Consider: warning -> a warning
> + */
> +#define __rte_warn_unused_result __attribute__((warn_unused_result))
> +
> /**
> * Force a function to be inlined
> */
> --
> 2.25.1
>
Reviewed-by: Morten Brørup <mb at smartsharesystems.com>
More information about the dev
mailing list