Skip to content

Commit

Permalink
printf big endian fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
aliaspider committed Sep 21, 2020
1 parent 276354b commit 2334beb
Show file tree
Hide file tree
Showing 27 changed files with 110 additions and 110 deletions.
8 changes: 4 additions & 4 deletions Core/Dialog/PSPOskDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,20 @@ int PSPOskDialog::Init(u32 oskPtr) {
oskParams = oskPtr;
if (oskParams->base.size != sizeof(SceUtilityOskParams))
{
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: invalid size %d", oskParams->base.size);
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: invalid size %d", (u32)oskParams->base.size);
return SCE_ERROR_UTILITY_INVALID_PARAM_SIZE;
}
// Also seems to crash.
if (!oskParams->fields.IsValid())
{
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: invalid field data (%08x)", oskParams->fields.ptr);
ERROR_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: invalid field data (%08x)", (u32)oskParams->fields.ptr);
return -1;
}

if (oskParams->unk_60 != 0)
WARN_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: unknown param is non-zero (%08x)", oskParams->unk_60);
WARN_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: unknown param is non-zero (%08x)", (s32)oskParams->unk_60);
if (oskParams->fieldCount != 1)
WARN_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: unsupported field count %d", oskParams->fieldCount);
WARN_LOG_REPORT(SCEUTILITY, "sceUtilityOskInitStart: unsupported field count %d", (s32)oskParams->fieldCount);

ChangeStatusInit(OSK_INIT_DELAY_US);
selectedChar = 0;
Expand Down
2 changes: 1 addition & 1 deletion Core/Dialog/PSPSaveDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ int PSPSaveDialog::Init(int paramAddr)
currentSelectedSave = param.GetLastEmptySave();
break;
default:
WARN_LOG(SCEUTILITY, "Unknown save list focus option: %d", param.GetPspParam()->focus);
WARN_LOG(SCEUTILITY, "Unknown save list focus option: %d", (int)param.GetPspParam()->focus);
currentSelectedSave = 0;
break;
}
Expand Down
24 changes: 12 additions & 12 deletions Core/Dialog/SavedataParam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,12 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_MS_NOSPACE;
}
if (param->dataSize > param->dataBufSize) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata buffer overflow: %d / %d", param->dataSize, param->dataBufSize);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata buffer overflow: %d / %d", (SceSize)param->dataSize, (SceSize)param->dataBufSize);
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
auto validateSize = [](const PspUtilitySavedataFileData &data) {
if (data.buf.IsValid() && data.bufSize < data.size) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata subdata buffer overflow: %d / %d", data.size, data.bufSize);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata subdata buffer overflow: %d / %d", (SceSize)data.size, (SceSize)data.bufSize);
return false;
}
return true;
Expand All @@ -383,14 +383,14 @@ int SavedataParam::Save(SceUtilitySavedataParam* param, const std::string &saveD
}

if (param->secureVersion > 3) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", param->secureVersion);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", (u32)param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;
} else if (param->secureVersion != 0) {
if (param->secureVersion != 1 && !HasKey(param)) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key on save: %d", param->secureVersion);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key on save: %d", (u32)param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_SAVE_PARAM;
}
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", param->secureVersion);
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested on save: %d", (u32)param->secureVersion);
}

std::string dirPath = GetSaveFilePath(param, GetSaveDir(param, saveDirName));
Expand Down Expand Up @@ -602,14 +602,14 @@ int SavedataParam::Load(SceUtilitySavedataParam *param, const std::string &saveD

int SavedataParam::LoadSaveData(SceUtilitySavedataParam *param, const std::string &saveDirName, const std::string &dirPath, bool secureMode) {
if (param->secureVersion > 3) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", param->secureVersion);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", (u32)param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM;
} else if (param->secureVersion != 0) {
if (param->secureVersion != 1 && !HasKey(param)) {
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key: %d", param->secureVersion);
ERROR_LOG_REPORT(SCEUTILITY, "Savedata version with missing key: %d", (u32)param->secureVersion);
return SCE_UTILITY_SAVEDATA_ERROR_LOAD_PARAM;
}
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", param->secureVersion);
WARN_LOG_REPORT(SCEUTILITY, "Savedata version requested: %d", (u32)param->secureVersion);
}
u8 *data_ = param->dataBuf;
std::string filename = GetFileName(param);
Expand Down Expand Up @@ -1173,23 +1173,23 @@ int SavedataParam::GetFilesList(SceUtilitySavedataParam *param)
}

if (!param->fileList.IsValid()) {
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): bad fileList address %08x", param->fileList.ptr);
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): bad fileList address %08x", (u32)param->fileList.ptr);
// Should crash.
return -1;
}

auto &fileList = param->fileList;
if (fileList->secureEntries.IsValid() && fileList->maxSecureEntries > 99) {
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many secure entries, %d", fileList->maxSecureEntries);
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many secure entries, %d", (u32)fileList->maxSecureEntries);
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
if (fileList->normalEntries.IsValid() && fileList->maxNormalEntries > 8192) {
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many normal entries, %d", fileList->maxNormalEntries);
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many normal entries, %d", (u32)fileList->maxNormalEntries);
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
if (sceKernelGetCompiledSdkVersion() >= 0x02060000) {
if (fileList->systemEntries.IsValid() && fileList->maxSystemEntries > 5) {
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many system entries, %d", fileList->maxSystemEntries);
ERROR_LOG_REPORT(SCEUTILITY, "SavedataParam::GetFilesList(): too many system entries, %d", (u32)fileList->maxSystemEntries);
return SCE_UTILITY_SAVEDATA_ERROR_RW_BAD_PARAMS;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Core/ELF/PBPReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ PBPReader::PBPReader(FileLoader *fileLoader) : file_(nullptr), header_(), isELF_
return;
}

VERBOSE_LOG(LOADER, "Loading PBP, version = %08x", header_.version);
VERBOSE_LOG(LOADER, "Loading PBP, version = %08x", (u32)header_.version);
file_ = fileLoader;
}

Expand Down
6 changes: 3 additions & 3 deletions Core/ELF/ParamSFO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) {
if (header->magic != 0x46535000)
return false;
if (header->version != 0x00000101)
WARN_LOG(LOADER, "Unexpected SFO header version: %08x", header->version);
WARN_LOG(LOADER, "Unexpected SFO header version: %08x", (u32)header->version);

const IndexTable *indexTables = (const IndexTable *)(paramsfo + sizeof(Header));

Expand All @@ -116,7 +116,7 @@ bool ParamSFOData::ReadSFO(const u8 *paramsfo, size_t size) {
// Unsigned int
const u32_le *data = (const u32_le *)(data_start + indexTables[i].data_table_offset);
SetValue(key,*data,indexTables[i].param_max_len);
VERBOSE_LOG(LOADER, "%s %08x", key, *data);
VERBOSE_LOG(LOADER, "%s %08x", key, (u32)*data);
}
break;
case 0x0004:
Expand Down Expand Up @@ -146,7 +146,7 @@ int ParamSFOData::GetDataOffset(const u8 *paramsfo, std::string dataName) {
if (header->magic != 0x46535000)
return -1;
if (header->version != 0x00000101)
WARN_LOG(LOADER, "Unexpected SFO header version: %08x", header->version);
WARN_LOG(LOADER, "Unexpected SFO header version: %08x", (u32)header->version);

const IndexTable *indexTables = (const IndexTable *)(paramsfo + sizeof(Header));

Expand Down
2 changes: 1 addition & 1 deletion Core/FileLoaders/DiskCachingFileLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ u64 DiskCachingFileLoaderCache::FreeDiskSpace() {
u32 DiskCachingFileLoaderCache::DetermineMaxBlocks() {
const s64 freeBytes = FreeDiskSpace();
// We want to leave them some room for other stuff.
const u64 availBytes = std::max(0LL, freeBytes - SAFETY_FREE_DISK_SPACE);
const u64 availBytes = std::max((s64)0LL, freeBytes - SAFETY_FREE_DISK_SPACE);
const u64 freeBlocks = availBytes / (u64)DEFAULT_BLOCK_SIZE;

const u32 alreadyCachedCount = CountCachedFiles();
Expand Down
2 changes: 1 addition & 1 deletion Core/FileSystems/ISOFileSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ size_t ISOFileSystem::ReadFile(u32 handle, u8 *pointer, s64 size, int &usec) {

// Okay, we have size and position, let's rock.
const int firstBlockOffset = positionOnIso & 2047;
const int firstBlockSize = firstBlockOffset == 0 ? 0 : (int)std::min(size, 2048LL - firstBlockOffset);
const int firstBlockSize = firstBlockOffset == 0 ? 0 : (int)std::min(size, (s64)2048LL - firstBlockOffset);
const int lastBlockSize = (size - firstBlockSize) & 2047;
const s64 middleSize = size - firstBlockSize - lastBlockSize;
u32 secNum = (u32)(positionOnIso / 2048);
Expand Down
6 changes: 3 additions & 3 deletions Core/HLE/HLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,14 +468,14 @@ void HLEReturnFromMipsCall() {
stackData.ptr = sp;

if ((stackData->nextOff & 0x0000000F) != 0 || !Memory::IsValidAddress(sp + stackData->nextOff)) {
ERROR_LOG(HLE, "Corrupt stack on HLE mips call return: %08x", stackData->nextOff);
ERROR_LOG(HLE, "Corrupt stack on HLE mips call return: %08x", (u32)stackData->nextOff);
Core_UpdateState(CORE_RUNTIME_ERROR);
return;
}

if (stackData->vals.actionIndex != 0xFFFFFFFF && stackData->vals.actionIndex < (u32)mipsCallActions.size()) {
PSPAction *&action = mipsCallActions[stackData->vals.actionIndex];
VERBOSE_LOG(HLE, "Executing action for HLE mips call at %08x, sp=%08x", stackData->vals.func, sp);
VERBOSE_LOG(HLE, "Executing action for HLE mips call at %08x, sp=%08x", (u32)stackData->vals.func, sp);

// Search for the saved v0/v1 values, to preserve the PSPAction API...
PSPPointer<HLEMipsCallStack> finalMarker = stackData;
Expand All @@ -484,7 +484,7 @@ void HLEReturnFromMipsCall() {
}

if (finalMarker->nextOff != 0xFFFFFFFF) {
ERROR_LOG(HLE, "Corrupt stack on HLE mips call return action: %08x", finalMarker->nextOff);
ERROR_LOG(HLE, "Corrupt stack on HLE mips call return action: %08x", (u32)finalMarker->nextOff);
Core_UpdateState(CORE_RUNTIME_ERROR);
return;
}
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/proAdhoc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1071,7 +1071,7 @@ void AfterMatchingMipsCall::run(MipsCall &call) {
//call.setReturnValue(v0);
}

void AfterMatchingMipsCall::SetData(int ContextID, int eventId, u32_le BufAddr) {
void AfterMatchingMipsCall::SetData(int ContextID, int eventId, u32 BufAddr) {
contextID = ContextID;
EventID = eventId;
bufAddr = BufAddr;
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/proAdhoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ class AfterMatchingMipsCall : public PSPAction {
static PSPAction *Create() { return new AfterMatchingMipsCall(); }
void DoState(PointerWrap &p) override;
void run(MipsCall &call) override;
void SetData(int ContextID, int eventId, u32_le BufAddr);
void SetData(int ContextID, int eventId, u32 BufAddr);

private:
int contextID = -1;
Expand Down
4 changes: 2 additions & 2 deletions Core/HLE/sceAtrac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2314,10 +2314,10 @@ static u32 _sceAtracGetContextAddress(int atracID) {
if (atrac->context_.IsValid())
Memory::Memset(atrac->context_.ptr, 0, 256);

WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", atrac->context_.ptr, atracID);
WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i): allocated new context", (u32)atrac->context_.ptr, atracID);
}
else
WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i)", atrac->context_.ptr, atracID);
WARN_LOG(ME, "%08x=_sceAtracGetContextAddress(%i)", (u32)atrac->context_.ptr, atracID);
if (atrac->context_.IsValid())
_AtracGenerateContext(atrac, atrac->context_);
return atrac->context_.ptr;
Expand Down
6 changes: 3 additions & 3 deletions Core/HLE/sceKernelEventFlag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ class EventFlag : public KernelObject {
static const char *GetStaticTypeName() { return "EventFlag"; }
void GetQuickInfo(char *ptr, int size) override {
sprintf(ptr, "init=%08x cur=%08x numwait=%i",
nef.initPattern,
nef.currentPattern,
nef.numWaitThreads);
(u32)nef.initPattern,
(u32)nef.currentPattern,
(s32)nef.numWaitThreads);
}

static u32 GetMissingErrorCode() {
Expand Down
2 changes: 1 addition & 1 deletion Core/HLE/sceKernelMemory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1499,7 +1499,7 @@ SceUID sceKernelCreateVpl(const char *name, int partition, u32 attr, u32 vplSize
vpl->header->Init(memBlockPtr, vplSize);

DEBUG_LOG(SCEKERNEL, "%x=sceKernelCreateVpl(\"%s\", block=%i, attr=%i, size=%i)",
id, name, partition, vpl->nv.attr, vpl->nv.poolSize);
id, name, partition, (s32)vpl->nv.attr, (s32)vpl->nv.poolSize);

if (optPtr != 0)
{
Expand Down
Loading

0 comments on commit 2334beb

Please sign in to comment.