1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 11:59:58 +03:00

Fixed warnings when no custom defaults are found.

This commit is contained in:
mikeller 2019-08-13 23:27:19 +12:00
parent 52173c7981
commit 0e2f7bcc3f
2 changed files with 98 additions and 98 deletions

View file

@ -306,75 +306,6 @@ typedef struct serialPassthroughPort_e {
serialPort_t *port; serialPort_t *port;
} serialPassthroughPort_t; } serialPassthroughPort_t;
static void backupPgConfig(const pgRegistry_t *pg)
{
memcpy(pg->copy, pg->address, pg->size);
}
static void restorePgConfig(const pgRegistry_t *pg)
{
memcpy(pg->address, pg->copy, pg->size);
}
static void backupConfigs(void)
{
if (configIsInCopy) {
return;
}
// make copies of configs to do differencing
PG_FOREACH(pg) {
backupPgConfig(pg);
}
configIsInCopy = true;
}
static void restoreConfigs(void)
{
if (!configIsInCopy) {
return;
}
PG_FOREACH(pg) {
restorePgConfig(pg);
}
configIsInCopy = false;
}
#if defined(USE_RESOURCE_MGMT) || defined(USE_TIMER_MGMT)
static bool isReadingConfigFromCopy()
{
return configIsInCopy;
}
#endif
static bool isWritingConfigToCopy()
{
return configIsInCopy
#if defined(USE_CUSTOM_DEFAULTS)
&& !processingCustomDefaults
#endif
;
}
static void backupAndResetConfigs(const bool useCustomDefaults)
{
backupConfigs();
// reset all configs to defaults to do differencing
resetConfigs();
#if defined(USE_CUSTOM_DEFAULTS)
if (useCustomDefaults) {
cliProcessCustomDefaults();
}
#else
UNUSED(useCustomDefaults);
#endif
}
static void cliWriterFlush() static void cliWriterFlush()
{ {
if (cliWriter) { if (cliWriter) {
@ -687,6 +618,77 @@ static const char *cliPrintSectionHeading(dumpFlags_t dumpMask, bool outputFlag,
} }
} }
static void backupPgConfig(const pgRegistry_t *pg)
{
memcpy(pg->copy, pg->address, pg->size);
}
static void restorePgConfig(const pgRegistry_t *pg)
{
memcpy(pg->address, pg->copy, pg->size);
}
static void backupConfigs(void)
{
if (configIsInCopy) {
return;
}
// make copies of configs to do differencing
PG_FOREACH(pg) {
backupPgConfig(pg);
}
configIsInCopy = true;
}
static void restoreConfigs(void)
{
if (!configIsInCopy) {
return;
}
PG_FOREACH(pg) {
restorePgConfig(pg);
}
configIsInCopy = false;
}
#if defined(USE_RESOURCE_MGMT) || defined(USE_TIMER_MGMT)
static bool isReadingConfigFromCopy()
{
return configIsInCopy;
}
#endif
static bool isWritingConfigToCopy()
{
return configIsInCopy
#if defined(USE_CUSTOM_DEFAULTS)
&& !processingCustomDefaults
#endif
;
}
static void backupAndResetConfigs(const bool useCustomDefaults)
{
backupConfigs();
// reset all configs to defaults to do differencing
resetConfigs();
#if defined(USE_CUSTOM_DEFAULTS)
if (useCustomDefaults) {
if (!cliProcessCustomDefaults()) {
cliPrintLine("###WARNING: NO CUSTOM DEFAULTS FOUND###");
}
}
#else
UNUSED(useCustomDefaults);
#endif
}
static uint8_t getPidProfileIndexToUse() static uint8_t getPidProfileIndexToUse()
{ {
return pidProfileIndexToUse == CURRENT_PROFILE_INDEX ? getCurrentPidProfileIndex() : pidProfileIndexToUse; return pidProfileIndexToUse == CURRENT_PROFILE_INDEX ? getCurrentPidProfileIndex() : pidProfileIndexToUse;
@ -4211,7 +4213,7 @@ static void cliDefaults(char *cmdline)
} }
} }
} else { } else {
cliPrintError("NO DEFAULTS FOUND"); cliPrintError("NO CUSTOM DEFAULTS FOUND");
} }
return; return;
@ -6450,36 +6452,34 @@ void cliProcess(void)
} }
#if defined(USE_CUSTOM_DEFAULTS) #if defined(USE_CUSTOM_DEFAULTS)
void cliProcessCustomDefaults(void) bool cliProcessCustomDefaults(void)
{ {
if (processingCustomDefaults) {
return;
}
char *customDefaultsPtr = customDefaultsStart; char *customDefaultsPtr = customDefaultsStart;
if (isDefaults(customDefaultsPtr)) { if (processingCustomDefaults || !isDefaults(customDefaultsPtr)) {
#if !defined(DEBUG_CUSTOM_DEFAULTS) return false;
bufWriter_t *cliWriterTemp = cliWriter;
cliWriter = NULL;
#endif
memcpy(cliBufferTemp, cliBuffer, sizeof(cliBuffer));
uint32_t bufferIndexTemp = bufferIndex;
bufferIndex = 0;
processingCustomDefaults = true;
while (*customDefaultsPtr && *customDefaultsPtr != 0xFF && customDefaultsPtr < customDefaultsEnd) {
processCharacter(*customDefaultsPtr++);
}
processingCustomDefaults = false;
#if !defined(DEBUG_CUSTOM_DEFAULTS)
cliWriter = cliWriterTemp;
#endif
memcpy(cliBuffer, cliBufferTemp, sizeof(cliBuffer));
bufferIndex = bufferIndexTemp;
} else {
cliPrintError("NO DEFAULTS FOUND");
} }
#if !defined(DEBUG_CUSTOM_DEFAULTS)
bufWriter_t *cliWriterTemp = cliWriter;
cliWriter = NULL;
#endif
memcpy(cliBufferTemp, cliBuffer, sizeof(cliBuffer));
uint32_t bufferIndexTemp = bufferIndex;
bufferIndex = 0;
processingCustomDefaults = true;
while (*customDefaultsPtr && *customDefaultsPtr != 0xFF && customDefaultsPtr < customDefaultsEnd) {
processCharacter(*customDefaultsPtr++);
}
processingCustomDefaults = false;
#if !defined(DEBUG_CUSTOM_DEFAULTS)
cliWriter = cliWriterTemp;
#endif
memcpy(cliBuffer, cliBufferTemp, sizeof(cliBuffer));
bufferIndex = bufferIndexTemp;
return true;
} }
#endif #endif

View file

@ -25,6 +25,6 @@
extern bool cliMode; extern bool cliMode;
void cliProcess(void); void cliProcess(void);
void cliProcessCustomDefaults(void); bool cliProcessCustomDefaults(void);
struct serialPort_s; struct serialPort_s;
void cliEnter(struct serialPort_s *serialPort); void cliEnter(struct serialPort_s *serialPort);