Skip to content

fix(hwgen): prevent prefix collisions when resolving source names - #7533

Merged
pfeerick merged 1 commit into
EdgeTX:mainfrom
norulers:fix/sl-switch-prefix-collision
Jul 10, 2026
Merged

fix(hwgen): prevent prefix collisions when resolving source names#7533
pfeerick merged 1 commit into
EdgeTX:mainfrom
norulers:fix/sl-switch-prefix-collision

Conversation

@norulers

@norulers norulers commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

The _lookup_input_idx, switchLookupIdx, and adcGetInputIdx functions used strncmp for prefix-only matching, causing SL (switch) to match SL1 (slider) before switch lookup. Fix by requiring exact length match via strlen check to prevent prefix collisions between analog input names and switch names.

Closes: mixer source changing from SL to S3 after power cycle on T22

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Three name-lookup functions (_lookup_input_idx, adcGetInputIdx, switchLookupIdx) now require an exact string-length match against the candidate name before applying strncmp, preventing false matches when the candidate name is longer than the provided prefix length.

Changes

Exact-length lookup checks

Layer / File(s) Summary
Analog input lookup
radio/src/analogs.cpp
_lookup_input_idx stores the candidate name locally, checks strlen(input_name) == len, then applies strncmp.
ADC input lookup
radio/src/hal/adc_driver.cpp
adcGetInputIdx stores the ADC input name locally and adds a strlen(input_name) == len check before strncmp.
Switch lookup
radio/src/switches.cpp
switchLookupIdx adds a strlen(sw_name) == len check before strncmp.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main bug fix in lookup matching.
Description check ✅ Passed The description clearly summarizes the fix and impact, though it doesn't follow the template headings exactly.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

The _lookup_input_idx, switchLookupIdx, and adcGetInputIdx functions used strncmp for prefix-only matching, causing 'SL' (switch) to match 'SL1' (slider) before switch lookup. Fix by requiring exact length match via strlen check to prevent prefix collisions between analog input names and switch names.
@norulers
norulers force-pushed the fix/sl-switch-prefix-collision branch from 4f1cdb3 to e4767ae Compare July 7, 2026 09:01
@pfeerick pfeerick added bug 🪲 Something isn't working compilation Related to compiling the firmware and firmware options labels Jul 10, 2026
@pfeerick pfeerick added this to the 2.12.3 milestone Jul 10, 2026
@pfeerick pfeerick changed the title fix: SL switch source incorrectly resolved as SL1 slider (S3) in mixer fix(gen): prevent prefix collisions when resolving source names Jul 10, 2026
@pfeerick pfeerick changed the title fix(gen): prevent prefix collisions when resolving source names fix(hwgen): prevent prefix collisions when resolving source names Jul 10, 2026
@pfeerick
pfeerick merged commit df1f827 into EdgeTX:main Jul 10, 2026
41 checks passed
@pfeerick pfeerick added the backport/2.12 To be backported to a 2.12 release also. label Jul 19, 2026
@norulers
norulers deleted the fix/sl-switch-prefix-collision branch July 23, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/2.12 To be backported to a 2.12 release also. bug 🪲 Something isn't working compilation Related to compiling the firmware and firmware options

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants