compile-time enforcement of printf strings

only:uaefi
This commit is contained in:
Andrey 2024-06-10 19:36:41 -04:00
parent d79a258e23
commit dc6419f4c2
7 changed files with 12 additions and 12 deletions

View File

@ -419,7 +419,7 @@ static void assertTimeIsLinear() {
efitimems_t gapInMs = msNow - mostRecentMs;
// todo: lower gapInMs threshold?
if (gapInMs > 200) {
firmwareError(ObdCode::WATCH_DOG_SECONDS, "gap in time: mostRecentMs %dmS, now=%dmS, gap=%dmS",
firmwareError(ObdCode::WATCH_DOG_SECONDS, "gap in time: mostRecentMs %lumS, now=%lumS, gap=%lumS",
mostRecentMs, msNow, gapInMs);
}
}

View File

@ -14,7 +14,7 @@ uint32_t backupRamLoad(backup_ram_e idx) {
case backup_ram_e::IgnCounter:
return (RTCD1.rtc->BKP0R >> 16) & 0xff;
default:
criticalError("Invalid backup ram idx %d", idx);
criticalError("Invalid backup ram idx %d", (int)idx);
return 0;
}
#else
@ -32,7 +32,7 @@ void backupRamSave(backup_ram_e idx, uint32_t value) {
RTCD1.rtc->BKP0R = (RTCD1.rtc->BKP0R & ~0x00ff0000) | ((value & 0xff) << 16);
break;
default:
criticalError("Invalid backup ram idx %d, value 0x08x", idx, value);
criticalError("Invalid backup ram idx %d, value %lx", (int)idx, value);
break;
}
#endif /* HAL_USE_RTC */

View File

@ -247,9 +247,9 @@ void canHwInfo(CANDriver* cand)
}
uint32_t esr = cand->can->ESR;
efiPrintf("Receive error counter %d", (esr >> 24) & 0xff);
efiPrintf("Transmit error counter %d", (esr >> 16) & 0xff);
efiPrintf("Last error %d", (esr >> 4) & 0x7);
efiPrintf("Receive error counter %ld", (esr >> 24) & 0xff);
efiPrintf("Transmit error counter %ld", (esr >> 16) & 0xff);
efiPrintf("Last error %ld", (esr >> 4) & 0x7);
efiPrintf("Flags: %s %s %s",
(esr & 0x4) ? "BOFF" : "",
(esr & 0x2) ? "EPVF" : "",
@ -257,4 +257,4 @@ void canHwInfo(CANDriver* cand)
#endif
}
#endif /* EFI_CAN_SUPPORT */
#endif /* EFI_CAN_SUPPORT */

View File

@ -120,7 +120,7 @@ ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin) {
// huh why conditional on EFI_BOOTLOADER? some weird technical debt while does it fail only with debug options?
#ifndef EFI_BOOTLOADER
criticalError("%s: Invalid on-chip Gpio: %d", msg, brainPin);
criticalError("%s: Invalid on-chip Gpio: %d", msg, (int)brainPin);
#endif // EFI_BOOTLOADER
return EFI_ERROR_CODE;
}

View File

@ -36,14 +36,14 @@ public:
// These timers are only 16 bit - don't risk overflow
if (m_period > 0xFFF0) {
firmwareError(ObdCode::CUSTOM_OBD_LOW_FREQUENCY, "PWM Frequency too low %f hz on pin \"%s\"", frequency, msg);
firmwareError(ObdCode::CUSTOM_OBD_LOW_FREQUENCY, "PWM Frequency too low %.1f hz on pin \"%s\"", frequency, msg);
return;
}
// If we have too few usable bits, we run out of resolution, so don't allow that either.
// 200 counts = 0.5% resolution
if (m_period < 200) {
firmwareError(ObdCode::CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %d hz on pin \"%s\"", frequency, msg);
firmwareError(ObdCode::CUSTOM_OBD_HIGH_FREQUENCY, "PWM Frequency too high %.1f hz on pin \"%s\"", frequency, msg);
return;
}

View File

@ -293,7 +293,7 @@ void initAccelerometer() {
instance.start();
efiPrintf("accelerometer init OK");
} else {
efiPrintf("accelerometer init failed %d", ret);
efiPrintf("accelerometer init failed %d", (int)ret);
}
#endif /* HAL_USE_SPI */
}

View File

@ -87,7 +87,7 @@ void StepperMotorBase::setInitialPosition() {
efiPrintf("Stepper: savedStepperPos=%d forceStepperParking=%d (tps=%.2f)", m_currentPosition, (forceStepperParking ? 1 : 0), tpsPos);
if (m_currentPosition < 0 || forceStepperParking) {
efiPrintf("Stepper: starting parking time=%dms", getTimeNowMs());
efiPrintf("Stepper: starting parking time=%lums", getTimeNowMs());
// reset saved value
saveStepperPos(-1);