On 2022-04-11 11:16, Bruce Richardson wrote: > On Sun, Apr 10, 2022 at 03:51:38PM +0200, Mattias Rönnblom wrote: >> 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.ronnb...@ericsson.com> >> --- > > This is good to have, thanks. > > Series-acked-by: Bruce Richardson <bruce.richard...@intel.com>
There is one issue with this attribute in combination with GCC: a warn_unused_result warning cannot easily be suppressed in the source code of the caller. The usual cast-to-void trick doesn't work with this compiler (but does work with clang). This behavior limit the usefulness of this attribute to function where it's pretty much always a bug if you ignore the return value. I will update the macro doc string with some details around this.