Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix -Wformat violations #81618

Merged
merged 1 commit into from
Feb 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions src/coreclr/pal/tests/palsuite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ endif()

list(APPEND COMMON_TEST_LIBRARIES coreclrpal)

# Skip validation of printf format flags.
add_compile_options(-Wno-format)

if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers)
add_compile_options(-Wno-int-to-void-pointer-cast)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/pal/tests/palsuite/common/palsuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ typedef unsigned short char16_t;
#include <pal.h>
#include <palprivate.h>
#include <minipal/utils.h>
#include <minipal/types.h>

#define PALTEST(testfunc, testname) \
int __cdecl testfunc(int argc, char* argv[]); \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ PALTEST(miscellaneous_GlobalMemoryStatusEx_test1_paltest_globalmemorystatusex_te
}

printf("GlobalMemoryStatusEx:\n");
printf(" ullTotalPhys: %llu\n", memoryStatus.ullTotalPhys);
printf(" ullAvailPhys: %llu\n", memoryStatus.ullAvailPhys);
printf(" ullTotalVirtual: %llu\n", memoryStatus.ullTotalVirtual);
printf(" ullAvailVirtual: %llu\n", memoryStatus.ullAvailVirtual);
printf(" ullTotalPageFile: %llu\n", memoryStatus.ullTotalPageFile);
printf(" ullAvailPageFile: %llu\n", memoryStatus.ullAvailPageFile);
printf(" ullAvailExtendedVirtual: %llu\n", memoryStatus.ullAvailExtendedVirtual);
printf(" ullTotalPhys: %" PRIu64 "\n", memoryStatus.ullTotalPhys);
printf(" ullAvailPhys: %" PRIu64 "\n", memoryStatus.ullAvailPhys);
printf(" ullTotalVirtual: %" PRIu64 "\n", memoryStatus.ullTotalVirtual);
printf(" ullAvailVirtual: %" PRIu64 "\n", memoryStatus.ullAvailVirtual);
printf(" ullTotalPageFile: %" PRIu64 "\n", memoryStatus.ullTotalPageFile);
printf(" ullAvailPageFile: %" PRIu64 "\n", memoryStatus.ullAvailPageFile);
printf(" ullAvailExtendedVirtual: %" PRIu64 "\n", memoryStatus.ullAvailExtendedVirtual);
printf(" dwMemoryLoad: %u\n", memoryStatus.dwMemoryLoad);

if (memoryStatus.ullTotalPhys == 0 ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,19 @@ PALTEST(threading_QueryThreadCycleTime_test1_paltest_querythreadcycletime_test1,

LONG64 trial = (LONG64)SecondCount - (LONG64)FirstCount;
if (trial < 0){
printf("Negative value %llu measured", trial);
printf("Negative value %" PRIu64 " measured", trial);
}
Actual += (trial);

}



if(llabs(Expected - Actual) > Delta)
{
Fail("ERROR: The measured time (%llu millisecs) was not within Delta %llu "
"of the expected time (%llu millisecs).\n",
Fail("ERROR: The measured time (%" PRIu64 " millisecs) was not within Delta %" PRIu64 " "
"of the expected time (%" PRIu64 " millisecs).\n",
(Actual / MSEC_TO_NSEC), (Delta / MSEC_TO_NSEC), (Expected / MSEC_TO_NSEC));
}
//printf("%llu, %llu\n", Expected, Actual);
//printf("%" PRIu64 ", %" PRIu64 "\n", Expected, Actual);
PAL_Terminate();
ret = PASS;
}
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/tools/superpmi/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
if (CLR_CMAKE_HOST_UNIX)
add_compile_options(-Wno-format)
endif(CLR_CMAKE_HOST_UNIX)

add_subdirectory(superpmi)
add_subdirectory(mcs)
add_subdirectory(superpmi-shim-collector)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/tools/superpmi/mcs/verbdumptoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ int verbDumpToc::DoWork(const char* nameOfInput)
for (size_t i = 0; i < tf.GetTocCount(); i++)
{
const TOCElement* te = tf.GetElementPtr(i);
printf("%4u: %016llX ", te->Number, te->Offset);
printf("%4u: %016" PRIX64 " ", te->Number, te->Offset);

for (size_t j = 0; j < sizeof(te->Hash); j++)
{
Expand Down
47 changes: 24 additions & 23 deletions src/coreclr/tools/superpmi/superpmi-shared/compileresult.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,12 @@ void CompileResult::recAllocMemCapture()

AllocMem->Add(0, value);
}

void CompileResult::dmpAllocMem(DWORD key, const Agnostic_AllocMemDetails& value)
{
printf("AllocMem key 0, value hotCodeSize-%u coldCodeSize-%u roDataSize-%u xcptnsCount-%u flag-%08X "
"hotCodeBlock_offset-%u coldCodeBlock_offset-%u roDataBlock_offset-%u hotCodeBlock-%016llX "
"coldCodeBlock-%016llX roDataBlock-%016llX",
"hotCodeBlock_offset-%u coldCodeBlock_offset-%u roDataBlock_offset-%u hotCodeBlock-%016" PRIX64 " "
"coldCodeBlock-%016" PRIX64 " roDataBlock-%016" PRIX64,
value.hotCodeSize, value.coldCodeSize, value.roDataSize, value.xcptnsCount, value.flag,
value.hotCodeBlock_offset, value.coldCodeBlock_offset, value.roDataBlock_offset, value.hotCodeBlock,
value.coldCodeBlock, value.roDataBlock);
Expand Down Expand Up @@ -238,7 +239,7 @@ void CompileResult::recSetBoundaries(CORINFO_METHOD_HANDLE ftn, ULONG32 cMap, IC
void CompileResult::dmpSetBoundaries(DWORD key, const Agnostic_SetBoundaries& value)
{
ICorDebugInfo::OffsetMapping* om = (ICorDebugInfo::OffsetMapping*)SetBoundaries->GetBuffer(value.pMap_offset);
printf("SetBoundaries key 0, value ftn-%016llX cMap-%u %u{", value.ftn, value.cMap, value.pMap_offset);
printf("SetBoundaries key 0, value ftn-%016" PRIX64 " cMap-%u %u{", value.ftn, value.cMap, value.pMap_offset);
for (unsigned int i = 0; i < value.cMap; i++)
{
if (i != 0)
Expand Down Expand Up @@ -286,7 +287,7 @@ void CompileResult::recSetVars(CORINFO_METHOD_HANDLE ftn, ULONG32 cVars, ICorDeb
void CompileResult::dmpSetVars(DWORD key, const Agnostic_SetVars& value)
{
ICorDebugInfo::NativeVarInfo* om = (ICorDebugInfo::NativeVarInfo*)SetVars->GetBuffer(value.vars_offset);
printf("SetVars key %u, value ftn-%016llX cVars-%u %u{", key, value.ftn, value.cVars, value.vars_offset);
printf("SetVars key %u, value ftn-%016" PRIX64 " cVars-%u %u{", key, value.ftn, value.cVars, value.vars_offset);
for (unsigned int i = 0; i < value.cVars; i++)
{
if (i != 0)
Expand Down Expand Up @@ -371,7 +372,7 @@ void CompileResult::dmpAllocGCInfo(DWORD key, const Agnostic_AllocGCInfo& value)
{
const unsigned char* buff = AllocGCInfo->GetBuffer(value.retval_offset);
printf("AllocGCInfo key 0, ");
printf("sz-%llu %p{ ", value.size, buff);
printf("sz-%" PRIu64 " %p{ ", value.size, buff);
for (unsigned int i = 0; i < value.size; i++)
printf("%02X ", *(buff + i));
printf("}");
Expand Down Expand Up @@ -402,7 +403,7 @@ void CompileResult::recCompileMethod(uint8_t** nativeEntry, uint32_t* nativeSize
}
void CompileResult::dmpCompileMethod(DWORD key, const Agnostic_CompileMethodResults& value)
{
printf("CompileMethod key %u, value nativeEntry-%016llX nativeSizeOfCode-%u CorJitResult-%u", key,
printf("CompileMethod key %u, value nativeEntry-%016" PRIX64 " nativeSizeOfCode-%u CorJitResult-%u", key,
value.nativeEntry, value.nativeSizeOfCode, value.CorJitResult);
}
void CompileResult::repCompileMethod(BYTE** nativeEntry, ULONG* nativeSizeOfCode, CorJitResult* result)
Expand Down Expand Up @@ -448,7 +449,7 @@ void CompileResult::recClassMustBeLoadedBeforeCodeIsRun(CORINFO_CLASS_HANDLE cls
}
void CompileResult::dmpClassMustBeLoadedBeforeCodeIsRun(DWORD key, DWORDLONG value)
{
printf("ClassMustBeLoadedBeforeCodeIsRun key %u, value cls-%016llX", key, value);
printf("ClassMustBeLoadedBeforeCodeIsRun key %u, value cls-%016" PRIX64, key, value);
}

void CompileResult::recReportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd,
Expand All @@ -475,7 +476,7 @@ void CompileResult::recReportInliningDecision(CORINFO_METHOD_HANDLE inlinerHnd,
void CompileResult::dmpReportInliningDecision(DWORD key, const Agnostic_ReportInliningDecision& value)
{
const char* reason = (const char*)ReportInliningDecision->GetBuffer(value.reason_offset);
printf("ReportInliningDecision key %u, value inliner-%016llX inlinee-%016llX res-%u reason-'%s'", key,
printf("ReportInliningDecision key %u, value inliner-%016" PRIX64 " inlinee-%016" PRIX64 " res-%u reason-'%s'", key,
value.inlinerHnd, value.inlineeHnd, value.inlineResult, reason);
ReportInliningDecision->Unlock();
}
Expand Down Expand Up @@ -579,7 +580,7 @@ void CompileResult::recSetMethodAttribs(CORINFO_METHOD_HANDLE ftn, CorInfoMethod
}
void CompileResult::dmpSetMethodAttribs(DWORDLONG key, DWORD value)
{
printf("SetMethodAttribs key ftn-%016llX, value attr-%08X", key, value);
printf("SetMethodAttribs key ftn-%016" PRIX64 ", value attr-%08X", key, value);
}
CorInfoMethodRuntimeFlags CompileResult::repSetMethodAttribs(CORINFO_METHOD_HANDLE ftn)
{
Expand All @@ -598,7 +599,7 @@ void CompileResult::recMethodMustBeLoadedBeforeCodeIsRun(CORINFO_METHOD_HANDLE m
}
void CompileResult::dmpMethodMustBeLoadedBeforeCodeIsRun(DWORD key, DWORDLONG value)
{
printf("MethodMustBeLoadedBeforeCodeIsRun key %u, value ftn-%016llX", key, value);
printf("MethodMustBeLoadedBeforeCodeIsRun key %u, value ftn-%016" PRIX64, key, value);
}

void CompileResult::recReportTailCallDecision(CORINFO_METHOD_HANDLE callerHnd,
Expand Down Expand Up @@ -627,7 +628,7 @@ void CompileResult::recReportTailCallDecision(CORINFO_METHOD_HANDLE callerHnd,
void CompileResult::dmpReportTailCallDecision(DWORD key, const Agnostic_ReportTailCallDecision& value)
{
const char* reason = (const char*)ReportTailCallDecision->GetBuffer(value.reason_index);
printf("ReportTailCallDecision key-%u, value cr-%016llX ce-%016llX tail-%u call-%u -%s", key, value.callerHnd,
printf("ReportTailCallDecision key-%u, value cr-%016" PRIX64 " ce-%016" PRIX64 " tail-%u call-%u -%s", key, value.callerHnd,
value.calleeHnd, value.tailCallResult, value.tailCallResult, reason);
ReportTailCallDecision->Unlock();
}
Expand Down Expand Up @@ -678,7 +679,7 @@ const char* relocationTypeToString(uint16_t fRelocType)
}
void CompileResult::dmpRecordRelocation(DWORD key, const Agnostic_RecordRelocation& value)
{
printf("RecordRelocation key %u, value loc-%016llX tgt-%016llX fRelocType-%u(%s) slotNum-%u addlDelta:%d", key,
printf("RecordRelocation key %u, value loc-%016" PRIX64 " tgt-%016" PRIX64 " fRelocType-%u(%s) slotNum-%u addlDelta:%d", key,
value.location, value.target, value.fRelocType, relocationTypeToString((uint16_t)value.fRelocType),
value.slotNum, (int32_t)value.addlDelta);
}
Expand Down Expand Up @@ -759,7 +760,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
size_t address = section_begin + (size_t)fixupLocation - (size_t)originalAddr;
if ((section_begin <= address) && (address < section_end)) // A reloc for our section?
{
LogDebug(" fixupLoc-%016llX (@%p) : %08X => %08X", fixupLocation, address, *(DWORD*)address,
LogDebug(" fixupLoc-%016" PRIX64 " (@%p) : %08X => %08X", fixupLocation, address, *(DWORD*)address,
(DWORD)tmp.target);
*(DWORD*)address = (DWORD)tmp.target;
}
Expand Down Expand Up @@ -877,7 +878,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
size_t address = section_begin + (size_t)fixupLocation - (size_t)originalAddr;
if ((section_begin <= address) && (address < section_end)) // A reloc for our section?
{
LogDebug(" fixupLoc-%016llX (@%p) %016llX => %016llX", fixupLocation, address,
LogDebug(" fixupLoc-%016" PRIX64 " (@%p) %016" PRIX64 " => %016" PRIX64, fixupLocation, address,
*(DWORDLONG*)address, tmp.target);
*(DWORDLONG*)address = tmp.target;
}
Expand Down Expand Up @@ -934,7 +935,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
index = rc->mc->GetRelocTypeHint->GetIndex(key);
if (index != -1)
{
LogDebug(" Using address map: target %016llX, original target %016llX",
LogDebug(" Using address map: target %016" PRIX64 ", original target %016" PRIX64,
tmp.target, key);
}
}
Expand Down Expand Up @@ -1044,7 +1045,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
target = (DWORDLONG)originalAddr + (DWORDLONG)blocksize1;
INT64 newdelta = (INT64)(target - baseAddr);

LogDebug(" REL32 overflow. Mapping target to %016llX. Mapping delta: %016llX => %016llX",
LogDebug(" REL32 overflow. Mapping target to %016" PRIX64 ". Mapping delta: %016" PRIX64 " => %016" PRIX64,
target, delta, newdelta);

delta = newdelta;
Expand All @@ -1061,7 +1062,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
{
if (delta != (INT64)(int)delta)
{
LogError("REL32 relocation overflows field! delta=0x%016llX", delta);
LogError("REL32 relocation overflows field! delta=0x%016" PRIX64, delta);
}
}

Expand All @@ -1078,7 +1079,7 @@ void CompileResult::applyRelocs(RelocContext* rc, unsigned char* block1, ULONG b
}

// Write 32-bits into location
LogDebug(" fixupLoc-%016llX (@%p) : %08X => %08X", fixupLocation, address, *(DWORD*)address, delta);
LogDebug(" fixupLoc-%016" PRIX64 " (@%p) : %08X => %08X", fixupLocation, address, *(DWORD*)address, delta);
*(DWORD*)address = (DWORD)delta;
}

Expand Down Expand Up @@ -1135,7 +1136,7 @@ void CompileResult::recAddressMap(void* originalAddress, void* replayAddress, un
}
void CompileResult::dmpAddressMap(DWORDLONG key, const Agnostic_AddressMap& value)
{
printf("AddressMap key %016llX, value addr-%016llX, size-%u", key, value.Address, value.size);
printf("AddressMap key %016" PRIX64 ", value addr-%016" PRIX64 ", size-%u", key, value.Address, value.size);
}
void* CompileResult::repAddressMap(void* replayAddress)
{
Expand Down Expand Up @@ -1210,7 +1211,7 @@ void CompileResult::recAllocUnwindInfo(BYTE* pHotCode,
}
void CompileResult::dmpAllocUnwindInfo(DWORD key, const Agnostic_AllocUnwindInfo& value)
{
printf("AllocUnwindInfo key %u, value pHot-%016llX pCold-%016llX startOff-%u endOff-%u unwindSz-%u blki-%u "
printf("AllocUnwindInfo key %u, value pHot-%016" PRIX64 " pCold-%016" PRIX64 " startOff-%u endOff-%u unwindSz-%u blki-%u "
"funcKind-%u",
key, value.pHotCode, value.pColdCode, value.startOffset, value.endOffset, value.unwindSize,
value.pUnwindBlock_index, value.funcKind);
Expand All @@ -1223,15 +1224,15 @@ void CompileResult::recRecordCallSite(ULONG instrOffset, CORINFO_SIG_INFO* callS

void CompileResult::dmpRecordCallSiteWithSignature(DWORD key, const Agnostic_RecordCallSite& value) const
{
printf("RecordCallSite key %u, callSig-%s ftn-%016llX",
printf("RecordCallSite key %u, callSig-%s ftn-%016" PRIX64,
key,
SpmiDumpHelper::DumpAgnostic_CORINFO_SIG_INFO(value.callSig, RecordCallSiteWithSignature, CrSigInstHandleMap).c_str(),
value.methodHandle);
}

void CompileResult::dmpRecordCallSiteWithoutSignature(DWORD key, DWORDLONG methodHandle) const
{
printf("RecordCallSite without call signature key %u, ftn-%016llX", key, methodHandle);
printf("RecordCallSite without call signature key %u, ftn-%016" PRIX64, key, methodHandle);
}

void CompileResult::repRecordCallSite(ULONG instrOffset, CORINFO_SIG_INFO* callSig, CORINFO_METHOD_HANDLE methodHandle)
Expand Down Expand Up @@ -1298,5 +1299,5 @@ bool CompileResult::fndRecordCallSiteMethodHandle(ULONG instrOffset, CORINFO_MET

void CompileResult::dmpCrSigInstHandleMap(DWORD key, DWORDLONG value)
{
printf("CrSigInstHandleMap key %u, value %016llX", key, value);
printf("CrSigInstHandleMap key %u, value %016" PRIX64, key, value);
}
Loading