Skip to content

Conversation

tpambor
Copy link
Contributor

@tpambor tpambor commented Sep 23, 2025

Move cdc_acm_send_notification behind the #ifdef CONFIG_UART_LINE_CTRL to avoid unused function warning when config option CONFIG_UART_LINE_CTRL is deactivated.

/home/user/west_workspace/zephyr/subsys/usb/device_next/class/usbd_cdc_acm.c:572:19: warning: unused function 'cdc_acm_send_notification' [-Wunused-function]
  572 | static inline int cdc_acm_send_notification(const struct device *dev,
      |                   ^~~~~~~~~~~~~~~~~~~~~~~~~

@zephyrbot zephyrbot added the area: USB Universal Serial Bus label Sep 23, 2025
Copy link
Contributor

@jfischer-no jfischer-no left a comment

Choose a reason for hiding this comment

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

There are no "unused function warning when line coding is disabled".

Move cdc_acm_send_notification behind the #ifdef CONFIG_UART_LINE_CTRL
to avoid unused function warning when config option CONFIG_UART_LINE_CTRL
is deactivated.

Signed-off-by: Tim Pambor <[email protected]>
@tpambor tpambor force-pushed the usb-device-unused-func branch from f74f052 to b6fe7aa Compare September 23, 2025 08:13
@tpambor tpambor requested a review from jfischer-no September 23, 2025 08:15
Copy link

Copy link
Contributor

@jfischer-no jfischer-no left a comment

Choose a reason for hiding this comment

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

@tpambor
Copy link
Contributor Author

tpambor commented Sep 23, 2025

There are no "unused function warning when line coding is disabled".

Do you mind explaining a bit more? Is your comment about the commit message? I corrected the commit message to "when config option CONFIG_UART_LINE_CTRL is deactivated."

@tpambor
Copy link
Contributor Author

tpambor commented Sep 30, 2025

@jfischer-no You can reproduce the warning compiling samples/subsys/usb/cdc_acm using clang with CONFIG_UART_LINE_CTRL=n.

I tested this using the upcoming zephyr-sdk 0.18.0-alpha4 which includes clang 19.1.7 with
west build -b stm32h573i_dk -- -DZEPHYR_TOOLCHAIN_VARIANT=zephyr/llvm

@jfischer-no
Copy link
Contributor

@jfischer-no You can reproduce the warning compiling samples/subsys/usb/cdc_acm using clang with CONFIG_UART_LINE_CTRL=n.

I tested this using the upcoming zephyr-sdk 0.18.0-alpha4 which includes clang 19.1.7 with west build -b stm32h573i_dk -- -DZEPHYR_TOOLCHAIN_VARIANT=zephyr/llvm

Then it should be fixed in the upcoming toolchain.

@tpambor
Copy link
Contributor Author

tpambor commented Sep 30, 2025

@jfischer-no You can reproduce the warning compiling samples/subsys/usb/cdc_acm using clang with CONFIG_UART_LINE_CTRL=n.
I tested this using the upcoming zephyr-sdk 0.18.0-alpha4 which includes clang 19.1.7 with west build -b stm32h573i_dk -- -DZEPHYR_TOOLCHAIN_VARIANT=zephyr/llvm

Then it should be fixed in the upcoming toolchain.

@jfischer-no I don't get what the issue is here. There is only a single user of cdc_acm_send_notification which is cdc_acm_line_ctrl_set which is only used when CONFIG_UART_LINE_CTRL=y. So cdc_acm_send_notification is certainly unused when CONFIG_UART_LINE_CTRL=n. gcc does not output a warning because this function is static inline but this is just a decision by gcc to not issue unused function warnings for inline functions. Clang issues unused function warnings also for inline functions. This is not a issue of the compiler and clang is a supported compiler as well. The warning can also be reproduced compiling using https://docs.zephyrproject.org/latest/develop/toolchains/arm_toolchain_for_embedded.html.

@ClaCodes
Copy link
Contributor

Then it should be fixed in the upcoming toolchain.

@jfischer-no Could you please bring the debate about, whether or not an unused static inline merits a diagnostic upstream to the clang-compiler-team?

In the mean-time i do not see why this tiny fix should be blocked, could you explain or accept this for the benefit of the project?

@tpambor
Copy link
Contributor Author

tpambor commented Oct 2, 2025

@jfischer-no You can reproduce the warning compiling samples/subsys/usb/cdc_acm using clang with CONFIG_UART_LINE_CTRL=n.
I tested this using the upcoming zephyr-sdk 0.18.0-alpha4 which includes clang 19.1.7 with west build -b stm32h573i_dk -- -DZEPHYR_TOOLCHAIN_VARIANT=zephyr/llvm

Then it should be fixed in the upcoming toolchain.

/cc @stephanosio @keith-packard

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: USB Universal Serial Bus
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants