cdc_host: fix undeclared 'idx' when only LINE_CONTROL_ON_ENUM is defined#3660
Draft
andrewleech wants to merge 1 commit into
Draft
cdc_host: fix undeclared 'idx' when only LINE_CONTROL_ON_ENUM is defined#3660andrewleech wants to merge 1 commit into
andrewleech wants to merge 1 commit into
Conversation
idx is used in the ENUM_SET_LINE_CONTROL path guarded by CFG_TUH_CDC_LINE_CONTROL_ON_ENUM, but was declared only under CFG_TUH_CDC_LINE_CODING_ON_ENUM. Defining LINE_CONTROL_ON_ENUM without LINE_CODING_ON_ENUM therefore failed to compile with an undeclared identifier. Guard the declaration under either macro. Signed-off-by: Andrew Leech <andrew@alelec.net>
|
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a compile error in the CDC host enumeration path when CFG_TUH_CDC_LINE_CONTROL_ON_ENUM is enabled without also enabling CFG_TUH_CDC_LINE_CODING_ON_ENUM, by ensuring idx is declared whenever either enum-time line-state feature is compiled in.
Changes:
- Broaden
idxdeclaration guard to cover bothCFG_TUH_CDC_LINE_CODING_ON_ENUMandCFG_TUH_CDC_LINE_CONTROL_ON_ENUM.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or 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
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.
A small compile fix in the CDC host on-enum line-state handling.
If you build the CDC host with
CFG_TUH_CDC_LINE_CONTROL_ON_ENUMset butCFG_TUH_CDC_LINE_CODING_ON_ENUMunset, it doesn't compile.set_line_state_on_enum()declaresidxonly underCFG_TUH_CDC_LINE_CODING_ON_ENUM, but it's also used in theENUM_SET_LINE_CONTROLcase (guarded byCFG_TUH_CDC_LINE_CONTROL_ON_ENUM), soidxis left undeclared in that branch.I ran into it while looking at turning on
CFG_TUH_CDC_LINE_CONTROL_ON_ENUMfor a host to assert DTR/RTS on enumerate without forcing a fixed line coding, which seems like a pretty reasonable combination but currently won't build.Fix just guards the declaration under either macro:
Testing: compile only so far. Built the CDC host class with all four combinations of the two macros (neither, coding only, control only, both); control-only failed before this change and builds after. Haven't runtime-tested the control-only enum path.