compile-time enforcement of printf strings

only:uaefi
This commit is contained in:
Matthew Kennedy 2024-06-10 03:51:14 -04:00 committed by Andrey
parent be8b5501e1
commit 27e0a80c82
19 changed files with 36 additions and 38 deletions

View File

@ -137,7 +137,7 @@ static void runCommands(SerialTsChannelBase* tsChannel) {
return;
}
efiPrintf("Restarting at %d", baudRates[baudIdx].rate);
efiPrintf("Restarting at %lu", baudRates[baudIdx].rate);
tsChannel->start(baudRates[baudIdx].rate);
chThdSleepMilliseconds(10); // safety

View File

@ -230,6 +230,7 @@ void TunerStudio::handleCrc32Check(TsChannelBase *tsChannel, uint16_t offset, ui
uint32_t crc = SWAP_UINT32(crc32(start, count));
tsChannel->sendResponse(TS_CRC, (const uint8_t *) &crc, 4);
efiPrintf("TS <- Get CRC offset %d count %d result %08x", offset, count, (unsigned int)crc);
}
#if EFI_TS_SCATTER
@ -591,7 +592,7 @@ static int tsProcessOne(TsChannelBase* tsChannel) {
/* send error only if previously we were in sync */
if (tsChannel->in_sync) {
efiPrintf("TunerStudio: command %c actual CRC %x/expected %x", tsChannel->scratchBuffer[0],
actualCrc, expectedCrc);
(unsigned int)actualCrc, (unsigned int)expectedCrc);
tunerStudioError(tsChannel, "ERROR: CRC issue");
sendErrorCode(tsChannel, TS_RESPONSE_CRC_FAILURE);
tsChannel->in_sync = false;

View File

@ -191,7 +191,7 @@ static void cmd_threads() {
while (tp) {
int freeBytes = CountFreeStackSpace(tp->wabase);
efiPrintf("%s\t%08x\t%lu\t%d", tp->name, tp->wabase, tp->time, freeBytes);
efiPrintf("%s\t%08x\t%lu\t%d", tp->name, (unsigned int)tp->wabase, tp->time, freeBytes);
if (freeBytes < 100) {
criticalError("Ran out of stack on thread %s, %d bytes remain", tp->name, freeBytes);

View File

@ -99,7 +99,7 @@ static void printRusefiVersion(const char *engineTypeName, const char *firmwareB
getRusEfiVersion(), SIGNATURE_HASH,
firmwareBuildId,
engineTypeName,
getTimeNowS());
(uint32_t)getTimeNowS());
}
#if EFI_PROD_CODE

View File

@ -376,7 +376,7 @@ void Engine::OnTriggerSynchronization(bool wasSynchronized, bool isDecodingError
if (isDecodingError) {
#if EFI_PROD_CODE
if (engineConfiguration->verboseTriggerSynchDetails || (triggerCentral.triggerState.someSortOfTriggerError() && !engineConfiguration->silentTriggerError)) {
efiPrintf("error: synchronizationPoint @ index %d expected %d/%d got %d/%d",
efiPrintf("error: synchronizationPoint @ index %lu expected %d/%d got %d/%d",
triggerCentral.triggerState.currentCycle.current_index,
triggerCentral.triggerShape.getExpectedEventCount(TriggerWheel::T_PRIMARY),
triggerCentral.triggerShape.getExpectedEventCount(TriggerWheel::T_SECONDARY),

View File

@ -40,11 +40,11 @@ void resetMaxValues() {
}
void printRuntimeStats(void) {
efiPrintf("maxSchedulingPrecisionLoss=%d", maxSchedulingPrecisionLoss);
efiPrintf("maxSchedulingPrecisionLoss=%lu", maxSchedulingPrecisionLoss);
#if EFI_CLOCK_LOCKS
efiPrintf("maxLockedDuration=%d / maxTriggerReentrant=%d", maxLockedDuration, maxTriggerReentrant);
efiPrintf("maxLockedDuration=%lu / maxTriggerReentrant=%d", maxLockedDuration, maxTriggerReentrant);
#endif // EFI_CLOCK_LOCKS
efiPrintf("maxEventCallbackDuration=%d", maxEventCallbackDuration);
efiPrintf("maxEventCallbackDuration=%lu", maxEventCallbackDuration);
}

View File

@ -80,7 +80,7 @@ void checkLastBootError() {
sramState->Err.BootCount = 0;
}
efiPrintf("Power cycle count: %d", sramState->Err.BootCount);
efiPrintf("Power cycle count: %lu", sramState->Err.BootCount);
sramState->Err.BootCount++;
#endif // EFI_BACKUP_SRAM
}

View File

@ -67,7 +67,7 @@ void PrimeController::onIgnitionStateChanged(bool ignitionOn) {
auto startTime = getTimeNowNt() + primeDelayNt;
getExecutorInterface()->scheduleByTimestampNt("primingDelay", nullptr, startTime, { PrimeController::onPrimeStartAdapter, this });
} else {
efiPrintf("Skipped priming pulse since ignSwitchCounter = %d", ignSwitchCounter);
efiPrintf("Skipped priming pulse since ignSwitchCounter = %lu", ignSwitchCounter);
}
// we'll reset it later when the engine starts

View File

@ -312,7 +312,7 @@ void readFromFlash() {
break;
case FlashState::IncompatibleVersion:
// Preserve engine type from old config
efiPrintf("Resetting due to version mismatch but preserving engine type [%d]", engineConfiguration->engineType);
efiPrintf("Resetting due to version mismatch but preserving engine type [%d]", (int)engineConfiguration->engineType);
resetConfigurationExt(engineConfiguration->engineType);
break;
case FlashState::Ok:

View File

@ -31,7 +31,7 @@ void addLuaCanRxFilter(int32_t eid, uint32_t mask, int bus, int callback) {
criticalError("Too many Lua CAN RX filters");
}
efiPrintf("Added Lua CAN RX filter id 0x%x mask 0x%x with%s custom function", eid, mask, (callback == -1 ? "out" : ""));
efiPrintf("Added Lua CAN RX filter id 0x%x mask 0x%x with%s custom function", (unsigned int)eid, (unsigned int)mask, (callback == -1 ? "out" : ""));
filters[filterCount].Id = eid;
filters[filterCount].Mask = mask;

View File

@ -949,11 +949,11 @@ void triggerInfo(void) {
TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_PRIMARY)),
TRIGGER_WAVEFORM(getExpectedEventCount(TriggerWheel::T_SECONDARY)));
efiPrintf("trigger type=%d/need2ndChannel=%s", engineConfiguration->trigger.type,
efiPrintf("trigger type=%d/need2ndChannel=%s", (int)engineConfiguration->trigger.type,
boolToString(TRIGGER_WAVEFORM(needSecondTriggerInput)));
efiPrintf("synchronizationNeeded=%s/isError=%s/total errors=%d ord_err=%d/total revolutions=%d/self=%s",
efiPrintf("synchronizationNeeded=%s/isError=%s/total errors=%lu ord_err=%lu/total revolutions=%d/self=%s",
boolToString(ts->isSynchronizationNeeded),
boolToString(tc->isTriggerDecoderError()),
tc->triggerState.totalTriggerErrorCounter,
@ -1000,7 +1000,7 @@ void triggerInfo(void) {
efiPrintf("secondary logic input: %s", hwPortname(engineConfiguration->logicAnalyzerPins[1]));
efiPrintf("totalTriggerHandlerMaxTime=%d", triggerMaxDuration);
efiPrintf("totalTriggerHandlerMaxTime=%lu", triggerMaxDuration);
#endif /* EFI_PROD_CODE */

View File

@ -482,16 +482,13 @@ expected<TriggerDecodeResult> TriggerDecoderBase::decodeTriggerEvent(
float gap = 1.0 * toothDurations[i] / toothDurations[i + 1];
if (cisnan(gap)) {
efiPrintf("%s index=%d NaN gap, you have noise issues?",
i,
prefix
);
efiPrintf("%s index=%d NaN gap, you have noise issues?", prefix, i);
} else {
float ratioTo = triggerShape.synchronizationRatioTo[i];
bool gapOk = isInRange(ratioFrom, gap, ratioTo);
efiPrintf("%s %srpm=%d time=%d eventIndex=%d gapIndex=%d: %s gap=%.3f expected from %.3f to %.3f error=%s",
efiPrintf("%s %srpm=%d time=%d eventIndex=%lu gapIndex=%d: %s gap=%.3f expected from %.3f to %.3f error=%s",
prefix,
triggerConfiguration.PrintPrefix,
(int)Sensor::getOrZero(SensorType::Rpm),

View File

@ -119,7 +119,7 @@ int WaveChart::getSize() {
#if ! EFI_UNIT_TEST
static void printStatus() {
efiPrintf("engine sniffer: %s", boolToString(getTriggerCentral()->isEngineSnifferEnabled));
efiPrintf("engine sniffer size=%d", engineConfiguration->engineChartSize);
efiPrintf("engine sniffer size=%lu", engineConfiguration->engineChartSize);
}
void setChartSize(int newSize) {

View File

@ -325,7 +325,7 @@ static void printAdcChannedReport(const char *prefix, int internalIndex, adc_cha
void printFullAdcReport(void) {
#if EFI_USE_FAST_ADC
efiPrintf("fast %d samples", fastAdc.conversionCount);
efiPrintf("fast %lu samples", fastAdc.conversionCount);
for (int internalIndex = 0; internalIndex < fastAdc.size(); internalIndex++) {
adc_channel_e hwChannel = fastAdc.getAdcChannelByInternalIndex(internalIndex);
@ -333,7 +333,7 @@ void printFullAdcReport(void) {
printAdcChannedReport("F", internalIndex, hwChannel);
}
#endif // EFI_USE_FAST_ADC
efiPrintf("slow %d samples", slowAdcConversionCount);
efiPrintf("slow %lu samples", slowAdcConversionCount);
/* we assume that all slow ADC channels are enabled */
for (int internalIndex = 0; internalIndex < ADC_MAX_CHANNELS_COUNT; internalIndex++) {

View File

@ -81,9 +81,9 @@ CanTxMessage::~CanTxMessage() {
getCanCategory(category),
busIndex,
#ifndef STM32H7XX
(m_frame.IDE == CAN_IDE_EXT) ? CAN_EID(m_frame) : CAN_SID(m_frame),
(unsigned int)((m_frame.IDE == CAN_IDE_EXT) ? CAN_EID(m_frame) : CAN_SID(m_frame)),
#else
m_frame.common.XTD ? CAN_EID(m_frame) : CAN_SID(m_frame),
(unsigned int)(m_frame.common.XTD ? CAN_EID(m_frame) : CAN_SID(m_frame)),
#endif
m_frame.DLC,
m_frame.data8[0], m_frame.data8[1],

View File

@ -510,8 +510,8 @@ void sent_channel::Info(void) {
uint8_t stat;
uint16_t sig0, sig1;
efiPrintf("Unit time %d CPU ticks %f uS", tickPerUnit, TicksToUs(getTickTime()));
efiPrintf("Total pulses %d", pulseCounter);
efiPrintf("Unit time %lu CPU ticks %f uS", tickPerUnit, TicksToUs(getTickTime()));
efiPrintf("Total pulses %lu", pulseCounter);
if (GetSignals(&stat, &sig0, &sig1) == 0) {
efiPrintf("Last valid fast msg Status 0x%01x Sig0 0x%03x Sig1 0x%03x", stat, sig0, sig1);
@ -527,11 +527,11 @@ void sent_channel::Info(void) {
}
#if SENT_STATISTIC_COUNTERS
efiPrintf("Restarts %d", statistic.RestartCnt);
efiPrintf("Interval errors %d short, %d long", statistic.ShortIntervalErr, statistic.LongIntervalErr);
efiPrintf("Total frames %d with CRC error %d (%f%%)", statistic.FrameCnt, statistic.CrcErrCnt, statistic.CrcErrCnt * 100.0 / statistic.FrameCnt);
efiPrintf("Total slow channel messages %d with crc6 errors %d (%f%%)", statistic.sc, statistic.scCrcErr, statistic.scCrcErr * 100.0 / statistic.sc);
efiPrintf("Sync errors %d", statistic.SyncErr);
efiPrintf("Restarts %lu", statistic.RestartCnt);
efiPrintf("Interval errors %lu short, %lu long", statistic.ShortIntervalErr, statistic.LongIntervalErr);
efiPrintf("Total frames %lu with CRC error %lu (%f%%)", statistic.FrameCnt, statistic.CrcErrCnt, statistic.CrcErrCnt * 100.0 / statistic.FrameCnt);
efiPrintf("Total slow channel messages %lu with crc6 errors %lu (%f%%)", statistic.sc, statistic.scCrcErr, statistic.scCrcErr * 100.0 / statistic.sc);
efiPrintf("Sync errors %lu", statistic.SyncErr);
#endif
}

View File

@ -280,7 +280,7 @@ static void listDirectory(const char *path) {
if ((fno.fattrib & AM_DIR) || mystrncasecmp(RUSEFI_LOG_PREFIX, fno.fname, sizeof(RUSEFI_LOG_PREFIX) - 1)) {
continue;
}
efiPrintf("logfile%lu:%s", fno.fsize, fno.fname);
efiPrintf("logfile %lu:%s", (uint32_t)fno.fsize, fno.fname);
count++;
// efiPrintf("%c%c%c%c%c %u/%02u/%02u %02u:%02u %9lu %-12s", (fno.fattrib & AM_DIR) ? 'D' : '-',

View File

@ -42,7 +42,7 @@ static const char * const monthAbbrs[] = {
void printRtcDateTime() {
efidatetime_t dateTime = getRtcDateTime();
// prints the date like: 19 sep 2022 21:19:55
efiPrintf("Current RTC time: %02u %s %04u %02u:%02u:%02u",
efiPrintf("Current RTC time: %02u %s %04lu %02u:%02u:%02u",
dateTime.day, monthAbbrs[dateTime.month - 1], dateTime.year,
dateTime.hour, dateTime.minute, dateTime.second);
}

View File

@ -47,14 +47,14 @@ static void testBinary() {
}
timeNew = getTimeNowLowerNt() - start;
}
efiPrintf("for v=%d old=%d ticks", v, timeOld);
efiPrintf("for v=%d new=%d ticks", v, timeNew);
efiPrintf("for v=%d old=%lu ticks", v, timeOld);
efiPrintf("for v=%d new=%lu ticks", v, timeNew);
totalOld += timeOld;
totalNew += timeNew;
}
efiPrintf("totalOld=%d ticks", totalOld);
efiPrintf("totalNew=%d ticks", totalNew);
efiPrintf("totalOld=%lu ticks", totalOld);
efiPrintf("totalNew=%lu ticks", totalNew);
}