Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: posix: timers: Fix unused function warning #87145

Merged
merged 1 commit into from
Mar 24, 2025

Conversation

thughes
Copy link
Contributor

@thughes thughes commented Mar 14, 2025

Building with clang warns:

tests/posix/timers/src/clock.c:37:20: error: unused function 'tv_to_ts'
[-Werror,-Wunused-function]
static inline void tv_to_ts(const struct timeval *tv, struct timespec *ts)
                   ^
tests/posix/timers/src/clock.c:51:16: error: unused function 'tp_eq'
[-Werror,-Wunused-function]
_decl_op(bool, tp_eq, ==);     /* a == b */
               ^
tests/posix/timers/src/clock.c:52:16: error: unused function 'tp_lt'
[-Werror,-Wunused-function]
_decl_op(bool, tp_lt, <);      /* a < b */
               ^
tests/posix/timers/src/clock.c:53:16: error: unused function 'tp_gt'
[-Werror,-Wunused-function]
_decl_op(bool, tp_gt, >);      /* a > b */
               ^
tests/posix/timers/src/clock.c:54:16: error: unused function 'tp_le'
[-Werror,-Wunused-function]
_decl_op(bool, tp_le, <=);     /* a <= b */

tests/posix/timers/src/clock.c:59:20: error: unused function
'tp_diff_in_range_ns' [-Werror,-Wunused-function]
static inline bool tp_diff_in_range_ns(const struct timespec *a,
                   ^                   const struct timespec *b,

tests/posix/timers/src/clock.c:49:20: error: unused function
'tp_diff_in_range_ns' [-Werror,-Wunused-function]
static inline bool tp_diff_in_range_ns(const struct timespec *a,
                   ^                   const struct timespec *b,

@thughes
Copy link
Contributor Author

thughes commented Mar 14, 2025

Alternatively, we could mark the function with __used, but it wasn't clear if there are immediate plans to use the dead code. If not, let's just remove it.

@thughes thughes force-pushed the push-ovyurqplwkto branch from 517d7bf to 2f03db3 Compare March 14, 2025 23:05
@thughes thughes marked this pull request as ready for review March 17, 2025 18:15
@zephyrbot zephyrbot added the area: POSIX POSIX API Library label Mar 17, 2025
@zephyrbot zephyrbot requested review from cfriedt and ycsin March 17, 2025 18:16
Copy link
Member

@cfriedt cfriedt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference would be to mark functions __used, since it's a pretty elegant way of solving a common class of problems, and dead code in tests really isn't as much of a concern as dead code in deployed products.

@thughes thughes force-pushed the push-ovyurqplwkto branch from 2f03db3 to 01fb58d Compare March 18, 2025 21:28
@thughes thughes requested a review from cfriedt March 18, 2025 21:29
cfriedt
cfriedt previously approved these changes Mar 21, 2025
@thughes
Copy link
Contributor Author

thughes commented Mar 21, 2025

@ycsin Can you take a look? Thanks!

@thughes thughes force-pushed the push-ovyurqplwkto branch from 01fb58d to 000d50d Compare March 21, 2025 16:52
ycsin
ycsin previously approved these changes Mar 21, 2025
Building with clang warns:

tests/posix/timers/src/clock.c:37:20: error: unused function 'tv_to_ts'
[-Werror,-Wunused-function]
static inline void tv_to_ts(const struct timeval *tv, struct timespec *ts)
                   ^
tests/posix/timers/src/clock.c:51:16: error: unused function 'tp_eq'
[-Werror,-Wunused-function]
_decl_op(bool, tp_eq, ==);     /* a == b */
               ^
tests/posix/timers/src/clock.c:52:16: error: unused function 'tp_lt'
[-Werror,-Wunused-function]
_decl_op(bool, tp_lt, <);      /* a < b */
               ^
tests/posix/timers/src/clock.c:53:16: error: unused function 'tp_gt'
[-Werror,-Wunused-function]
_decl_op(bool, tp_gt, >);      /* a > b */
               ^
tests/posix/timers/src/clock.c:54:16: error: unused function 'tp_le'
[-Werror,-Wunused-function]
_decl_op(bool, tp_le, <=);     /* a <= b */

tests/posix/timers/src/clock.c:59:20: error: unused function
'tp_diff_in_range_ns' [-Werror,-Wunused-function]
static inline bool tp_diff_in_range_ns(const struct timespec *a,
                   ^                   const struct timespec *b,

tests/posix/timers/src/clock.c:49:20: error: unused function
'tp_diff_in_range_ns' [-Werror,-Wunused-function]
static inline bool tp_diff_in_range_ns(const struct timespec *a,
                   ^                   const struct timespec *b,

Signed-off-by: Tom Hughes <tomhughes@chromium.org>
@thughes thughes force-pushed the push-ovyurqplwkto branch from 880e308 to 14adf68 Compare March 21, 2025 22:43
@thughes thughes requested review from cfriedt and ycsin March 21, 2025 22:45
@thughes
Copy link
Contributor Author

thughes commented Mar 21, 2025

@cfriedt and @ycsin I accidentally pushed an update to this PR. It's now reverted back to what it was when you approved.

@kartben kartben merged commit 424b255 into zephyrproject-rtos:main Mar 24, 2025
16 checks passed
@thughes thughes deleted the push-ovyurqplwkto branch March 24, 2025 17:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: mcumgr area: POSIX POSIX API Library area: Toolchains Toolchains area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants