From b3a514335f4dcde1d6f13535e74d05829bc1200c Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 5 Oct 2024 02:07:42 +0300 Subject: [PATCH] detect bad SysMessage format --- libpcsxcore/misc.c | 2 +- libpcsxcore/psxmem.c | 2 +- libpcsxcore/system.h | 12 ++++++++++-- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/libpcsxcore/misc.c b/libpcsxcore/misc.c index aafe5221..d4c886f4 100644 --- a/libpcsxcore/misc.c +++ b/libpcsxcore/misc.c @@ -585,7 +585,7 @@ int Load(const char *ExePath) { case 0: /* End of file */ break; default: - SysPrintf(_("Unknown CPE opcode %02x at position %08x.\n"), opcode, ftell(tmpFile) - 1); + SysPrintf(_("Unknown CPE opcode %02x at position %08zx.\n"), opcode, ftell(tmpFile) - 1); retval = -1; break; } diff --git a/libpcsxcore/psxmem.c b/libpcsxcore/psxmem.c index ad472592..e08bd895 100644 --- a/libpcsxcore/psxmem.c +++ b/libpcsxcore/psxmem.c @@ -101,7 +101,7 @@ void *psxMap(unsigned long addr, size_t size, int is_fixed, return MAP_FAILED; if (addr != 0 && ret != (void *)(uintptr_t)addr) { - SysMessage("psxMap: tried to map @%08x, got %p\n", + SysMessage("psxMap: tried to map @%08lx, got %p\n", addr, ret); if (is_fixed) { psxUnmap(ret, size, tag); diff --git a/libpcsxcore/system.h b/libpcsxcore/system.h index fe4ab404..4e65911a 100644 --- a/libpcsxcore/system.h +++ b/libpcsxcore/system.h @@ -26,8 +26,16 @@ extern "C" { int SysInit(); // Init mem and plugins void SysReset(); // Resets mem -void SysPrintf(const char *fmt, ...); // Printf used by bios syscalls -void SysMessage(const char *fmt, ...); // Message used to print msg to users +void SysPrintf(const char *fmt, ...) +#if defined(__GNUC__) && defined(__x86_64__) // some platforms have int32_t as long + __attribute__((format(printf, 1, 2))) +#endif + ; +void SysMessage(const char *fmt, ...) // Message used to print msg to users +#if defined(__GNUC__) && defined(__x86_64__) + __attribute__((format(printf, 1, 2))) +#endif + ; void *SysLoadLibrary(const char *lib); // Loads Library void *SysLoadSym(void *lib, const char *sym); // Loads Symbol from Library const char *SysLibError(); // Gets previous error loading sysbols -- 2.39.5