nuttx: Suppress UNUSED potential warnings#18719
nuttx: Suppress UNUSED potential warnings#18719pbarada wants to merge 1 commit intoapache:masterfrom
Conversation
Update UNUSED(a) for GCC to cast 'a' to void to suppress potential "address of 'xxx' will always evaluate to true" warning when enabling warnings in system headers. Signed-off-by Peter Barada <peter.barada@gmail.com>
|
@xiaoxiang781216 what are the consequences of this change? looking at git history, changes in this macro were made by Xiaomi, so they probably had some purpose:
|
my change try to avoid evaluating the argument to generate the side effect, but @pbarada said other OS(e.g. Linux) always evaluate the argument. so it's fine restore the change to align the behaviour. |
|
Its not that the expression generates code to evaluate it, more that the semantics of the expression involving the address of the variable always evaluates to true - which GCC potentially will warn about. Note this change is only enabled for GCC(and derivatives). |
Summary
Update UNUSED(a) for GCC to cast 'a' to void to suppress potential "address of 'xxx' will always evaluate to true" warning when enabling warnings in system headers.
Impact
User experience: No adaptation required.
Build: No impact.
Hardware: Should not affect GCC builds.
Documentation: No impact.
Security: No impact.
Compatibility: No impact.
Testing
Build Host:
Target: None
Built all ARM builds using modified tools/testbuild.sh script with increased warnings (-Wall -Wextra -Wsystem-headers), verified no warnings from invocations of UNUSED() macro.