docs(msp): fix enum doc generator double-counting exclusive #ifdef branches - #11844
docs(msp): fix enum doc generator double-counting exclusive #ifdef branches#11844sensei-hacker wants to merge 2 commits into
Conversation
…anches The enum-body parser advanced the auto-increment counter through both members of mutually-exclusive branches (#ifdef X / #ifndef X siblings, and #else / #elif within one family), so values in the alternate branch were inflated. E.g. MIXERAT_PHASE_DONE generated as (5) but is 3 in any build where it exists. Track the counter base per open branch and reset to it when an exclusive alternate branch is entered; regenerate the MSP enum reference docs (which also picks up enum drift since the last regen).
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
PR Summary by QodoFix conditional enum numbering in MSP documentation generator
AI Description
Diagram
High-Level Assessment
Files changed (4)
|
Code Review by Qodo
1.
|
Only adjacent #ifdef/#ifndef blocks are exclusive alternates. A member parsed between them advances the counter in every build, so a later opposite-polarity block must continue from that value instead of restarting from the earlier branch's base (e.g. A, #ifdef X B, #endif, C = 10, #ifndef X D -> D must be 11, not 1).
|
Addressed the review finding in f62230c: the sibling-branch cache is now invalidated by |
Summary
Fixes
docs/development/msp/gen_enum_md.pyso mutually-exclusive preprocessor branches inside an enum body don't double-count the auto-increment counter.The bug: for
mixerProfileATState_einsrc/main/flight/mixer_profile.h:MIXERAT_PHASE_DONEexists only in builds withoutUSE_AUTO_TRANSITION, where its true value is3— but the generator auto-incremented straight through both branches and emitted(5), double-counting the two members that can never coexist with it.The fix:
ConditionStackframes now record the auto-increment base each branch started from. When an exclusive alternate branch is entered — a sibling#ifndef Xafter#ifdef Xat the same nesting level, or an#else/#elifwithin one#iffamily — the counter resets to that base instead of continuing through the other branch's members.Verification:
MIXERAT_PHASE_DONEnow generates as(3)✓#ifdef/#ifndefpairs in both orders,#else/#eliffamilies, and nested pairs (verified with synthetic cases); two consecutive same-symbol#ifdef Xblocks (not mutually exclusive) are correctly left sequential ✓inav_enums_ref.md/inav_enums.jsonviagen_docs.sh; the remaining diff is enum/MSP drift picked up from source since the last regen (new enums likedronecanAsyncState_e, INA226 sensors) ✓Tests
all_enums.h: exactly one line changed#else,#elif, nested pair, explicit-value reset, same-symbol non-pairNo firmware code touched; docs tooling + regenerated docs only.