Skip to content

nuttx: Suppress UNUSED potential warnings#18719

Open
pbarada wants to merge 1 commit intoapache:masterfrom
pbarada:test/warnings
Open

nuttx: Suppress UNUSED potential warnings#18719
pbarada wants to merge 1 commit intoapache:masterfrom
pbarada:test/warnings

Conversation

@pbarada
Copy link
Copy Markdown
Contributor

@pbarada pbarada commented Apr 12, 2026

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:

  • OS: Ubuntu 24.04.4 LTS
  • Compiler: arm-none-eabi-gcc 13.2.1

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.

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>
@github-actions github-actions bot added Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small labels Apr 12, 2026
@raiden00pl
Copy link
Copy Markdown
Member

@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:

  1. change from ((void)(a)) to ((void)(1 || (a))):
    fs/lfs: Update version to 2.4.0 #3212
commit 3813634dc98f3b77122bb1fcc17f818f08521225
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Mon Mar 29 14:08:03 2021 +0800

    Refine UNUSED macro to avoid any side effect
    
    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
    Change-Id: I35d858fc6fb2e0e24b993ab7dd2203c9dd35232a

  1. change from ((void)(1 || (a))) to ((void)(1 || &(a))):
    optimize UNUSED macro #6779
commit 0083a2e4f29ac8574eeda895803f2a7447d89680
Author: liyi <liyi25@xiaomi.com>
Date:   Thu Aug 4 14:54:31 2022 +0800

    optimize UNUSED macro
    
    Signed-off-by: liyi <liyi25@xiaomi.com>

@xiaoxiang781216
Copy link
Copy Markdown
Contributor

@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:

  1. change from ((void)(a)) to ((void)(1 || (a))):
    fs/lfs: Update version to 2.4.0 #3212
commit 3813634dc98f3b77122bb1fcc17f818f08521225
Author: Xiang Xiao <xiaoxiang@xiaomi.com>
Date:   Mon Mar 29 14:08:03 2021 +0800

    Refine UNUSED macro to avoid any side effect
    
    Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
    Change-Id: I35d858fc6fb2e0e24b993ab7dd2203c9dd35232a

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.

@pbarada
Copy link
Copy Markdown
Contributor Author

pbarada commented Apr 13, 2026

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: OS Components OS Components issues Size: XS The size of the change in this PR is very small

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants