1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-23 08:15:30 +03:00

fix-use-before-initiated

This commit is contained in:
cs8425 2017-10-30 17:09:25 +08:00
parent a75e71d012
commit 800fc570d3
2 changed files with 11 additions and 12 deletions

View file

@ -322,7 +322,7 @@ void activateConfig(void)
#endif // USE_OSD_SLAVE
}
void validateAndFixConfig(void)
static void validateAndFixConfig(void)
{
#if !defined(USE_QUAD_MIXER_ONLY) && !defined(USE_OSD_SLAVE)
// Reset unsupported mixer mode to default.
@ -345,9 +345,17 @@ void validateAndFixConfig(void)
if (systemConfig()->activeRateProfile >= CONTROL_RATE_PROFILE_COUNT) {
systemConfigMutable()->activeRateProfile = 0;
}
setControlRateProfile(systemConfig()->activeRateProfile);
if (systemConfig()->pidProfileIndex >= MAX_PROFILE_COUNT) {
systemConfigMutable()->pidProfileIndex = 0;
}
setPidProfile(systemConfig()->pidProfileIndex);
// Prevent invalid notch cutoff
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
currentPidProfile->dterm_notch_hz = 0;
}
if ((motorConfig()->dev.motorPwmProtocol == PWM_TYPE_BRUSHED) && (motorConfig()->mincommand < 1000)) {
motorConfigMutable()->mincommand = 1000;
@ -357,6 +365,8 @@ void validateAndFixConfig(void)
motorConfigMutable()->dev.motorPwmRate = BRUSHLESS_MOTORS_PWM_RATE;
}
validateAndFixGyroConfig();
if (!(featureConfigured(FEATURE_RX_PARALLEL_PWM) || featureConfigured(FEATURE_RX_PPM) || featureConfigured(FEATURE_RX_SERIAL) || featureConfigured(FEATURE_RX_MSP) || featureConfigured(FEATURE_RX_SPI))) {
featureSet(DEFAULT_RX_FEATURE);
}
@ -409,12 +419,6 @@ void validateAndFixConfig(void)
}
#endif // USE_SOFTSPI
// Prevent invalid notch cutoff
if (currentPidProfile->dterm_notch_cutoff >= currentPidProfile->dterm_notch_hz) {
currentPidProfile->dterm_notch_hz = 0;
}
validateAndFixGyroConfig();
#endif // USE_OSD_SLAVE
if (!isSerialConfigValid(serialConfig())) {
@ -606,10 +610,6 @@ void readEEPROM(void)
}
validateAndFixConfig();
#ifndef USE_OSD_SLAVE
setControlRateProfile(systemConfig()->activeRateProfile);
setPidProfile(systemConfig()->pidProfileIndex);
#endif
activateConfig();
#ifndef USE_OSD_SLAVE

View file

@ -113,7 +113,6 @@ void writeEEPROM(void);
void ensureEEPROMContainsValidData(void);
void saveConfigAndNotify(void);
void validateAndFixConfig(void);
void validateAndFixGyroConfig(void);
void activateConfig(void);