Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/main/fc/control_profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,13 @@ void changeControlProfile(uint8_t profileIndex)
setControlProfile(profileIndex);
activateControlConfig();
}

uint8_t getCurrentControlProfile(void) {
for (uint8_t index = 0; index < MAX_CONTROL_PROFILE_COUNT; index++) {
if (currentControlProfile == controlProfiles(index)) {
return index;
}
}

return 0;
}
Comment on lines +105 to +113
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Action required

1. Ambiguous 0 profile index 📘 Rule violation ≡ Correctness

getCurrentControlProfile() returns 0 when no matching profile is found, which is
indistinguishable from a valid profile index 0. This can cause callers to silently act on the
wrong control profile instead of detecting an invalid/no-match state.
Agent Prompt
## Issue description
`getCurrentControlProfile()` returns `0` when no profile matches `currentControlProfile`, which is ambiguous because `0` is also a valid profile index.

## Issue Context
This code runs in embedded/task paths where ambiguous defaults can lead to silent misbehavior.

## Fix Focus Areas
- src/main/fc/control_profile.c[105-113]

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools