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

Fix unused function warnings #83830

Draft
wants to merge 23 commits into
base: main
Choose a base branch
from

Conversation

thughes
Copy link

@thughes thughes commented Jan 10, 2025

Re-enable the -Wunused-function warning when building with clang. Unlike gcc, clang generates warnings before optimizations, so it catches more.

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/ip/net_pkt.c:496:34: error: unused function 'get_tx_slab'
[-Werror,-Wunused-function]
static inline struct k_mem_slab *get_tx_slab(struct net_context *context)
                                 ^
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:

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

zephyr/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)
                      ^

sensor_ms2_to_mg is only called when (ONFIG_LIS2DW12_SLEEP or
CONFIG_LIS2DW12_WAKEUP is defined.

Signed-off-by: Tom Hughes <[email protected]>
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,
                  ^

Signed-off-by: Tom Hughes <[email protected]>
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,
                  ^

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/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, &lt;);      /* a &lt; b */
               ^
tests/posix/timers/src/clock.c:53:16: error: unused function 'tp_gt'
[-Werror,-Wunused-function]
_decl_op(bool, tp_gt, &gt;);      /* a &gt; b */
               ^
tests/posix/timers/src/clock.c:54:16: error: unused function 'tp_le'
[-Werror,-Wunused-function]
_decl_op(bool, tp_le, &lt;=);     /* a &lt;= 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,
                   ^

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:

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:

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:

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]>
Building with clang warns:

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]>
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]>
@thughes thughes force-pushed the fix-unused-function-warnings branch from a07bb9e to 671f6d3 Compare January 10, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant