-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Re-enable -Wunused-function
for clang
#83830
Draft
thughes
wants to merge
25
commits into
zephyrproject-rtos:main
Choose a base branch
from
thughes:fix-unused-function-warnings
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Re-enable -Wunused-function
for clang
#83830
thughes
wants to merge
25
commits into
zephyrproject-rtos:main
from
thughes:fix-unused-function-warnings
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a394858
to
758302f
Compare
-Wunused-function
for clang
758302f
to
f35aa62
Compare
These macros allow disabling compiler warnings for all compilers or only gcc or only clang. Signed-off-by: Tom Hughes <[email protected]>
In order to support new toolchains that are not compatible with gcc/clang (e.g., IAR), we need to add a level of indirection for the name of warnings. Signed-off-by: Tom Hughes <[email protected]>
f35aa62
to
a86cec3
Compare
Building with clang warns: subsys/net/ip/ipv6_nbr.c:137:31: error: unused function 'get_nbr_from_data' [-Werror,-Wunused-function] static inline struct net_nbr *get_nbr_from_data(struct net_ipv6_nbr_data ^ *data) Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: subsys/net/lib/coap/coap_link_format.c:39:20: error: unused function 'append_be16' [-Werror,-Wunused-function] static inline bool append_be16(struct coap_packet *cpkt, uint16_t data) Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: subsys/net/lib/http/http_hpack.c:21:20: error: unused function 'http_hpack_key_is_dynamic' [-Werror,-Wunused-function] static inline bool http_hpack_key_is_dynamic(uint32_t key) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: subsys/net/ip/utils.c:600:24: error: unused function 'pkt_calc_chksum' [-Werror,-Wunused-function] static inline uint16_t pkt_calc_chksum(struct net_pkt *pkt, uint16_t sum) ^ pkt_calc_chksum is called by net_calc_chksum, which only exists when CONFIG_NET_NATIVE_IP is defined. Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/modem/modem_cmd_handler.c:102:31: error: unused function 'read_rx_allocator' [-Werror,-Wunused-function] static inline struct net_buf *read_rx_allocator(k_timeout_t timeout, ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/sensor/st/iis2iclx/iis2iclx.c:68:19: error: unused function 'iis2iclx_reboot' [-Werror,-Wunused-function] static inline int iis2iclx_reboot(const struct device *dev) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/sensor/st/ism330dhcx/ism330dhcx.c:107:19: error: unused function 'ism330dhcx_reboot' [-Werror,-Wunused-function] static inline int ism330dhcx_reboot(const struct device *dev) Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/sensor/st/lsm9ds0_mfd/lsm9ds0_mfd.c:42:19: error: unused function 'lsm9ds0_mfd_accel_set_odr_raw' [-Werror,-Wunused-function] static inline int lsm9ds0_mfd_accel_set_odr_raw(const struct device *dev, ^ lsm9ds0_mfd_accel_set_odr_raw is only used by code that was guarded by defined(CONFIG_LSM9DS0_MFD_ACCEL_SAMPLING_RATE_RUNTIME) in addition to !defined(LSM9DS0_MFD_ACCEL_DISABLED). Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/sensor/st/lsm6dso/lsm6dso.c:89:19: error: unused function 'lsm6dso_reboot' [-Werror,-Wunused-function] static inline int lsm6dso_reboot(const struct device *dev) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/sensor/st/lsm6dso16is/lsm6dso16is.c:83:19: error: unused function 'lsm6dso16is_reboot' [-Werror,-Wunused-function] static inline int lsm6dso16is_reboot(const struct device *dev) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/flash/spi_nor.c:306:20: error: unused function 'delay_until_exit_dpd_ok' [-Werror,-Wunused-function] static inline void delay_until_exit_dpd_ok(const struct device *const dev) ^ delay_until_exit_dpd_ok is only used when ANY_INST_HAS_DPD is defined. Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: drivers/dma/dma_emul.c:73:20: error: unused function 'dma_emul_xfer_is_error_status' [-Werror,-Wunused-function] static inline bool dma_emul_xfer_is_error_status(int status) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: tests/net/udp/src/main.c:112:31: error: unused function 'if_get_addr' [-Werror,-Wunused-function] static inline struct in_addr *if_get_addr(struct net_if *iface) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: tests/net/arp/src/main.c:152:31: error: unused function 'if_get_addr' [-Werror,-Wunused-function] static inline struct in_addr *if_get_addr(struct net_if *iface) ^ Signed-off-by: Tom Hughes <[email protected]>
Building with clang warns: tests/net/shell/src/main.c:110:31: error: unused function 'if_get_addr' [-Werror,-Wunused-function] static inline struct in_addr *if_get_addr(struct net_if *iface) ^ Signed-off-by: Tom Hughes <[email protected]>
a86cec3
to
f7e531b
Compare
Building with clang warns: drivers/gpio/gpio_pca95xx.c:256:19: error: unused function 'update_input_reg' [-Werror,-Wunused-function] static inline int update_input_reg(const struct device *dev, uint8_t pin, ^ drivers/gpio/gpio_pca95xx.c:120:12: error: unused function 'read_port_reg' [-Werror,-Wunused-function] static int read_port_reg(const struct device *dev, uint8_t reg, ^ uint8_t pin, Signed-off-by: Tom Hughes <[email protected]>
3f959ef
to
0bbc5c8
Compare
Building with clang warns: drivers/ieee802154/ieee802154_dw1000.c:277:24: error: unused function 'dwt_reg_read_u16' [-Werror,-Wunused-function] static inline uint16_t dwt_reg_read_u16(const struct device *dev, ^ Signed-off-by: Tom Hughes <[email protected]>
0bbc5c8
to
519d89d
Compare
Building with clang warns: drivers/sensor/st/lis2dw12/lis2dw12.c:194:23: error: unused function 'sensor_ms2_to_mg' [-Werror,-Wunused-function] static inline int32_t sensor_ms2_to_mg(const struct sensor_value *ms2) ^ Move the function to include/zephyr/drivers/sensor.h with the other sensor_ms2_to* functions. Signed-off-by: Tom Hughes <[email protected]>
519d89d
to
575bc6d
Compare
Building with clang warns: subsys/net/l2/ethernet/ethernet.c:178:18: error: unused function 'ethernet_check_ipv4_bcast_addr' [-Werror,-Wunused-function] enum net_verdict ethernet_check_ipv4_bcast_addr(struct net_pkt *pkt, ^ ethernet_check_ipv4_bcast_addr is called by ethernet_ip_recv, which only exists when CONFIG_NET_IPV4 or CONFIG_NET_IPV6 is defined. Signed-off-by: Tom Hughes <[email protected]>
The warning emitted is: tests/net/lib/http_server/core/src/main.c:1400:19: error: variable 'http1_header_capture_common_response' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const char http1_header_capture_common_response[] ^ = "HTTP/1.1 200\r\n" However, this variable is needed at compile-time since it's referenced via sizeof(). This appears to be the same as this clang bug: llvm/llvm-project#25458. This warning only started being emitted when I re-enabled the -Wunused-function warning for clang. Signed-off-by: Tom Hughes <[email protected]>
tests/subsys/usb/bos/src/test_bos.c:24:22: error: variable 'dummy_descriptor' is not needed and will not be emitted [-Werror,-Wunneeded-internal-declaration] static const uint8_t dummy_descriptor[] = { ^ Signed-off-by: Tom Hughes <[email protected]>
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 <[email protected]>
All warnings in the code base have been resolved. Signed-off-by: Tom Hughes <[email protected]>
575bc6d
to
481d2f5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Re-enable the
-Wunused-function
warning when building withclang
. Unlikegcc
,clang
generates warnings before optimizations, so it catches more.Depends on #84063