1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 20:35:33 +03:00

Fixed writing of empty signature.

This commit is contained in:
mikeller 2018-05-28 01:43:13 +12:00
parent 0bf4708033
commit b4c44d8a46

View file

@ -2284,8 +2284,8 @@ static void cliSignature(char *cmdline)
const unsigned int len = strlen(cmdline); const unsigned int len = strlen(cmdline);
char signatureStr[SIGNATURE_LENGTH * 2 + 1] = {0}; char signatureStr[SIGNATURE_LENGTH * 2 + 1] = {0};
if (len > 0) {
uint8_t signature[SIGNATURE_LENGTH]; uint8_t signature[SIGNATURE_LENGTH];
if (len > 0) {
#define BLOCK_SIZE 2 #define BLOCK_SIZE 2
for (unsigned i = 0; i < SIGNATURE_LENGTH; i++) { for (unsigned i = 0; i < SIGNATURE_LENGTH; i++) {
char temp[BLOCK_SIZE + 1]; char temp[BLOCK_SIZE + 1];
@ -2294,22 +2294,24 @@ static void cliSignature(char *cmdline)
signature[i] = strtoul(temp, NULL, 16); signature[i] = strtoul(temp, NULL, 16);
} }
#undef BLOCK_SIZE #undef BLOCK_SIZE
if (signatureIsSet() && memcmp(signature, getSignature(), SIGNATURE_LENGTH)) { }
if (len > 0 && signatureIsSet() && memcmp(signature, getSignature(), SIGNATURE_LENGTH)) {
writeSignature(signatureStr, getSignature()); writeSignature(signatureStr, getSignature());
cliPrintLinef(ERROR_MESSAGE, "signature", signatureStr); cliPrintLinef(ERROR_MESSAGE, "signature", signatureStr);
return;
} else { } else {
if (len > 0) { if (len > 0) {
setSignature(signature); setSignature(signature);
signatureUpdated = true; signatureUpdated = true;
}
}
}
writeSignature(signatureStr, getSignature()); writeSignature(signatureStr, getSignature());
} else if (signatureUpdated || signatureIsSet()) {
writeSignature(signatureStr, getSignature());
}
cliPrintLinef("signature %s", signatureStr); cliPrintLinef("signature %s", signatureStr);
}
} }
#endif #endif
@ -4089,13 +4091,13 @@ static void printConfig(char *cmdline, bool doDiff)
#if defined(USE_BOARD_INFO) #if defined(USE_BOARD_INFO)
cliBoardName(""); cliBoardName("");
cliManufacturerId(""); cliManufacturerId("");
#if defined(USE_SIGNATURE)
cliSignature("");
#endif #endif
#endif // USE_BOARD_INFO
if (dumpMask & DUMP_ALL) { if (dumpMask & DUMP_ALL) {
cliMcuId(NULL); cliMcuId(NULL);
#if defined(USE_BOARD_INFO) && defined(USE_SIGNATURE)
cliSignature("");
#endif
} }
if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) { if ((dumpMask & (DUMP_ALL | DO_DIFF)) == (DUMP_ALL | DO_DIFF)) {