mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Merge pull request #6280 from etracer65/smix_reverse
Fix null pointer reference for "smix reverse"
This commit is contained in:
commit
521ab88d5c
1 changed files with 9 additions and 6 deletions
|
@ -1891,8 +1891,7 @@ static void cliServoMix(char *cmdline)
|
||||||
enum {SERVO = 0, INPUT, REVERSE, ARGS_COUNT};
|
enum {SERVO = 0, INPUT, REVERSE, ARGS_COUNT};
|
||||||
char *ptr = strchr(cmdline, ' ');
|
char *ptr = strchr(cmdline, ' ');
|
||||||
|
|
||||||
len = strlen(ptr);
|
if (ptr == NULL) {
|
||||||
if (len == 0) {
|
|
||||||
cliPrintf("s");
|
cliPrintf("s");
|
||||||
for (uint32_t inputSource = 0; inputSource < INPUT_SOURCE_COUNT; inputSource++)
|
for (uint32_t inputSource = 0; inputSource < INPUT_SOURCE_COUNT; inputSource++)
|
||||||
cliPrintf("\ti%d", inputSource);
|
cliPrintf("\ti%d", inputSource);
|
||||||
|
@ -1900,8 +1899,9 @@ static void cliServoMix(char *cmdline)
|
||||||
|
|
||||||
for (uint32_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
for (uint32_t servoIndex = 0; servoIndex < MAX_SUPPORTED_SERVOS; servoIndex++) {
|
||||||
cliPrintf("%d", servoIndex);
|
cliPrintf("%d", servoIndex);
|
||||||
for (uint32_t inputSource = 0; inputSource < INPUT_SOURCE_COUNT; inputSource++)
|
for (uint32_t inputSource = 0; inputSource < INPUT_SOURCE_COUNT; inputSource++) {
|
||||||
cliPrintf("\t%s ", (servoParams(servoIndex)->reversedSources & (1 << inputSource)) ? "r" : "n");
|
cliPrintf("\t%s ", (servoParams(servoIndex)->reversedSources & (1 << inputSource)) ? "r" : "n");
|
||||||
|
}
|
||||||
cliPrintLinefeed();
|
cliPrintLinefeed();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
@ -1922,12 +1922,15 @@ static void cliServoMix(char *cmdline)
|
||||||
if (args[SERVO] >= 0 && args[SERVO] < MAX_SUPPORTED_SERVOS
|
if (args[SERVO] >= 0 && args[SERVO] < MAX_SUPPORTED_SERVOS
|
||||||
&& args[INPUT] >= 0 && args[INPUT] < INPUT_SOURCE_COUNT
|
&& args[INPUT] >= 0 && args[INPUT] < INPUT_SOURCE_COUNT
|
||||||
&& (*ptr == 'r' || *ptr == 'n')) {
|
&& (*ptr == 'r' || *ptr == 'n')) {
|
||||||
if (*ptr == 'r')
|
if (*ptr == 'r') {
|
||||||
servoParamsMutable(args[SERVO])->reversedSources |= 1 << args[INPUT];
|
servoParamsMutable(args[SERVO])->reversedSources |= 1 << args[INPUT];
|
||||||
else
|
} else {
|
||||||
servoParamsMutable(args[SERVO])->reversedSources &= ~(1 << args[INPUT]);
|
servoParamsMutable(args[SERVO])->reversedSources &= ~(1 << args[INPUT]);
|
||||||
} else
|
}
|
||||||
|
} else {
|
||||||
cliShowParseError();
|
cliShowParseError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
cliServoMix("reverse");
|
cliServoMix("reverse");
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue