Skip to content

AI generated issue ticket: config.c - Runtime bounds check for failsafe_procedure enum #1101

@nerdCopter

Description

@nerdCopter

Issue

When migrating configs between builds with different USE_GPS_RESCUE defines, an out-of-range numeric enum value can persist in failsafeConfig()->failsafe_procedure.

Current code uses compile-time guard #if defined(USE_GPS_RESCUE) to conditionally normalize the value, but this leaves stale/invalid enum values intact when that flag is not defined.

Proposed Fix

Replace compile-time guard with runtime numeric bounds check:

  • Compare failsafeConfig()->failsafe_procedure against FAILSAFE_PROCEDURE_COUNT
  • If value >= FAILSAFE_PROCEDURE_COUNT, set failsafeConfigMutable()->failsafe_procedure = FAILSAFE_PROCEDURE_DROP_IT
  • Normalize invalid/stale values regardless of build flags

Location

src/main/fc/config.c around lines 255-259

Impact

Ensures failsafe state remains valid across build configurations.


This is an AI-generated issue for code review recommendations.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions