cdc host: ACM-only config fails to build, cdch_process_set_config() unused without a vendor serial driver

Open Beginner friendly
#4,551 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Start in src/class/cdc/cdc_host.c at the cdch_process_set_config() declaration and definition, then check the vendor-driver set-config callers guarded by CFG_TUH_CDC_FTDI, CFG_TUH_CDC_CP210X, CFG_TUH_CDC_CH34X, and CFG_TUH_CDC_PL2303. Build a host example with CFG_TUH_CDC enabled and all four vendor drivers disabled using -Wall -Wextra -Werror. Done means the ACM-only configuration builds and has build coverage to prevent regression.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

Found while building a USBHS v1 host bench app for #4308 (nanoch32v305, -DWCH_HOST_USBIP=usbhs).

Problem

A host configuration with CFG_TUH_CDC 1 and none of the vendor serial drivers, which is the default since CFG_TUH_CDC_FTDI, CFG_TUH_CDC_CP210X, CFG_TUH_CDC_CH34X and CFG_TUH_CDC_PL2303 all default to 0 in src/tusb_option.h, does not build with the examples' warning flags:

src/class/cdc/cdc_host.c:839:13: error: 'cdch_process_set_config' defined but not used [-Werror=unused-function]

cdch_process_set_config() is declared and defined unconditionally (master a5c175d82: src/class/cdc/cdc_host.c:95 and :815), but every caller is a vendor driver's set-config step inside #if CFG_TUH_CDC_FTDI / CP210X / CH34X / PL2303. A plain CDC-ACM host therefore has no caller.

Reproduce with any host example whose tusb_config.h keeps #define CFG_TUH_CDC 1 and removes the four vendor serial defines, built with the family's default flags (-Wall -Wextra -Werror). Seen with riscv-none-elf-gcc 13.2.0 on nanoch32v305.

CI does not catch it because every host example that enables CDC also enables all four vendor drivers.

Proposed fix

Compile cdch_process_set_config() (declaration and definition) only when at least one vendor serial driver is enabled, e.g. #if CFG_TUH_CDC_FTDI || CFG_TUH_CDC_CP210X || CFG_TUH_CDC_CH34X || CFG_TUH_CDC_PL2303. Add build coverage for an ACM-only host configuration, for example in a host unit test or one example variant, so the combination stays compiled.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.