Cast to int for enums that are not formattable

This commit is contained in:
Pokechu22 2022-01-12 16:47:26 -08:00
parent 5465775d11
commit 1a92699455
19 changed files with 60 additions and 42 deletions

View File

@ -690,7 +690,8 @@ void ARM64XEmitter::SetJumpTarget(FixupBranch const& branch)
case FixupBranch::Type::CBZ:
{
ASSERT_MSG(DYNA_REC, IsInRangeImm19(distance),
"Branch type {}: Received too large distance: {}", branch.type, distance);
"Branch type {}: Received too large distance: {}", static_cast<int>(branch.type),
distance);
const bool b64Bit = Is64Bit(branch.reg);
inst = (b64Bit << 31) | (0x1A << 25) | (Not << 24) | (MaskImm19(distance) << 5) |
DecodeReg(branch.reg);
@ -698,7 +699,8 @@ void ARM64XEmitter::SetJumpTarget(FixupBranch const& branch)
break;
case FixupBranch::Type::BConditional:
ASSERT_MSG(DYNA_REC, IsInRangeImm19(distance),
"Branch type {}: Received too large distance: {}", branch.type, distance);
"Branch type {}: Received too large distance: {}", static_cast<int>(branch.type),
distance);
inst = (0x2A << 25) | (MaskImm19(distance) << 5) | branch.cond;
break;
case FixupBranch::Type::TBNZ:
@ -707,19 +709,22 @@ void ARM64XEmitter::SetJumpTarget(FixupBranch const& branch)
case FixupBranch::Type::TBZ:
{
ASSERT_MSG(DYNA_REC, IsInRangeImm14(distance),
"Branch type {}: Received too large distance: {}", branch.type, distance);
"Branch type {}: Received too large distance: {}", static_cast<int>(branch.type),
distance);
inst = ((branch.bit & 0x20) << 26) | (0x1B << 25) | (Not << 24) | ((branch.bit & 0x1F) << 19) |
(MaskImm14(distance) << 5) | DecodeReg(branch.reg);
}
break;
case FixupBranch::Type::B:
ASSERT_MSG(DYNA_REC, IsInRangeImm26(distance),
"Branch type {}: Received too large distance: {}", branch.type, distance);
"Branch type {}: Received too large distance: {}", static_cast<int>(branch.type),
distance);
inst = (0x5 << 26) | MaskImm26(distance);
break;
case FixupBranch::Type::BL:
ASSERT_MSG(DYNA_REC, IsInRangeImm26(distance),
"Branch type {}: Received too large distance: {}", branch.type, distance);
"Branch type {}: Received too large distance: {}", static_cast<int>(branch.type),
distance);
inst = (0x25 << 26) | MaskImm26(distance);
break;
}

View File

@ -80,7 +80,7 @@ bool SavePNG(const std::string& path, const u8* input, ImageByteFormat format, u
byte_per_pixel = 4;
break;
default:
ASSERT_MSG(FRAMEDUMP, false, "Invalid format {}", format);
ASSERT_MSG(FRAMEDUMP, false, "Invalid format {}", static_cast<int>(format));
return false;
}

View File

@ -194,7 +194,7 @@ void TraversalClient::HandleServerPacket(TraversalPacket* packet)
break;
}
default:
WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", packet->type);
WARN_LOG_FMT(NETPLAY, "Received unknown packet with type {}", static_cast<int>(packet->type));
break;
}
if (packet->type != TraversalPacketType::Ack)

View File

@ -48,7 +48,7 @@ u16 SDSP::ReadMailboxLow(Mailbox mailbox)
#if defined(_DEBUG) || defined(DEBUGFAST)
const char* const type = mailbox == Mailbox::DSP ? "DSP" : "CPU";
DEBUG_LOG_FMT(DSP_MAIL, "{}(RM) B:{} M:0x{:#010x} (pc={:#06x})", type, mailbox,
DEBUG_LOG_FMT(DSP_MAIL, "{}(RM) B:{} M:0x{:#010x} (pc={:#06x})", type, static_cast<int>(mailbox),
PeekMailbox(mailbox), pc);
#endif
@ -75,7 +75,7 @@ void SDSP::WriteMailboxLow(Mailbox mailbox, u16 value)
#if defined(_DEBUG) || defined(DEBUGFAST)
const char* const type = mailbox == Mailbox::DSP ? "DSP" : "CPU";
DEBUG_LOG_FMT(DSP_MAIL, "{}(WM) B:{} M:{:#010x} (pc={:#06x})", type, mailbox,
DEBUG_LOG_FMT(DSP_MAIL, "{}(WM) B:{} M:{:#010x} (pc={:#06x})", type, static_cast<int>(mailbox),
PeekMailbox(mailbox), pc);
#endif
}

View File

@ -371,10 +371,11 @@ void CEXIMemoryCard::TransferByte(u8& byte)
case Command::ExtraByteProgram:
case Command::ChipErase:
DEBUG_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0. seems normal.",
m_command);
static_cast<u8>(m_command));
break;
default:
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0", m_command);
WARN_LOG_FMT(EXPANSIONINTERFACE, "EXI MEMCARD: command {:02x} at position 0",
static_cast<u8>(m_command));
break;
}
if (m_command == Command::ClearStatus)

View File

@ -335,7 +335,7 @@ int CSIDevice_GBA::RunBuffer(u8* buffer, int request_length)
}
// This should never happen, but appease MSVC which thinks it might.
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", static_cast<int>(m_next_action));
return 0;
}

View File

@ -107,7 +107,7 @@ int CSIDevice_GBAEmu::RunBuffer(u8* buffer, int request_length)
}
// This should never happen, but appease MSVC which thinks it might.
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", m_next_action);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown state {}\n", static_cast<int>(m_next_action));
return -1;
}

View File

@ -108,8 +108,8 @@ int CSIDevice_GCController::RunBuffer(u8* buffer, int request_length)
// DEFAULT
default:
{
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
PanicAlertFmt("SI: Unknown command ({:#x})", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", static_cast<u8>(command));
PanicAlertFmt("SI: Unknown command ({:#x})", static_cast<u8>(command));
}
break;
}

View File

@ -55,7 +55,7 @@ int CSIDevice_Keyboard::RunBuffer(u8* buffer, int request_length)
default:
{
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", command);
ERROR_LOG_FMT(SERIALINTERFACE, "Unknown SI command ({:#x})", static_cast<u8>(command));
}
break;
}

View File

@ -29,7 +29,7 @@ void Wiimote::HandleReportMode(const OutputReportMode& dr)
if (!DataReportBuilder::IsValidMode(dr.mode))
{
// A real wiimote ignores the entire message if the mode is invalid.
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", dr.mode);
WARN_LOG_FMT(WIIMOTE, "Game requested invalid report mode: {:#04x}", static_cast<u8>(dr.mode));
return;
}
@ -50,7 +50,8 @@ void Wiimote::InvokeHandler(H&& handler, const WiimoteCommon::OutputReportGeneri
{
if (size < sizeof(T))
{
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}", rpt.rpt_id, size);
ERROR_LOG_FMT(WIIMOTE, "InvokeHandler: report: {:#04x} invalid size: {}",
static_cast<u8>(rpt.rpt_id), size);
return;
}
@ -124,7 +125,7 @@ void Wiimote::InterruptDataOutput(const u8* data, u32 size)
InvokeHandler<OutputReportEnableFeature>(&Wiimote::HandleIRLogicEnable2, rpt, rpt_size);
break;
default:
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", rpt.rpt_id);
PanicAlertFmt("HidOutputReport: Unknown report ID {:#04x}", static_cast<u8>(rpt.rpt_id));
break;
}
}
@ -411,8 +412,9 @@ void Wiimote::HandleReadData(const OutputReportReadData& rd)
// A zero size request is just ignored, like on the real wiimote.
m_read_request.size = Common::swap16(rd.size);
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})", m_read_request.space,
m_read_request.slave_address, m_read_request.address, m_read_request.size);
DEBUG_LOG_FMT(WIIMOTE, "Wiimote::ReadData: {} @ {:#04x} @ {:#04x} ({})",
static_cast<u8>(m_read_request.space), m_read_request.slave_address,
m_read_request.address, m_read_request.size);
// Send up to one read-data-reply.
// If more data needs to be sent it will happen on the next "Update()"

View File

@ -582,7 +582,8 @@ void MotionPlus::PrepareInput(const Common::Vec3& angular_velocity)
break;
default:
// This really shouldn't happen as the M+ deactivates on an invalid mode write.
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}", GetPassthroughMode());
ERROR_LOG_FMT(WIIMOTE, "M+ unknown passthrough-mode {}",
static_cast<int>(GetPassthroughMode()));
mplus_data.is_mp_data = true;
break;
}

View File

@ -402,7 +402,8 @@ s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& da
{FS::Mode::ReadWrite, FS::Mode::ReadWrite, FS::Mode::None}, ticks);
if (result != FS::ResultCode::Success)
{
ERROR_LOG_FMT(IOS_ES, "Failed to create temporary file {}: {}", tmp_path, result);
ERROR_LOG_FMT(IOS_ES, "Failed to create temporary file {}: {}", tmp_path,
static_cast<int>(result));
return FS::ConvertResult(result);
}
@ -428,7 +429,8 @@ s32 ESDevice::WriteSystemFile(const std::string& path, const std::vector<u8>& da
result = fs.RenameFile(PID_KERNEL, PID_KERNEL, tmp_path, path, ticks);
if (result != FS::ResultCode::Success)
{
ERROR_LOG_FMT(IOS_ES, "Failed to move launch file to final destination ({}): {}", path, result);
ERROR_LOG_FMT(IOS_ES, "Failed to move launch file to final destination ({}): {}", path,
static_cast<int>(result));
return FS::ConvertResult(result);
}

View File

@ -381,7 +381,7 @@ s32 FSDevice::Seek(u64 fd, u32 offset, FS::SeekMode mode, Ticks ticks)
return ConvertResult(ResultCode::Invalid);
const Result<u32> result = m_ios.GetFS()->SeekFile(handle.fs_fd, offset, mode);
LogResult(result, "Seek({}, 0x{:08x}, {})", handle.name.data(), offset, mode);
LogResult(result, "Seek({}, 0x{:08x}, {})", handle.name.data(), offset, static_cast<int>(mode));
if (!result)
return ConvertResult(result.Error());
return *result;

View File

@ -319,7 +319,7 @@ void NetPlayClient::OnData(sf::Packet& packet)
MessageID mid;
packet >> mid;
INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", mid);
INFO_LOG_FMT(NETPLAY, "Got server message: {:x}", static_cast<u8>(mid));
switch (mid)
{
@ -457,7 +457,7 @@ void NetPlayClient::OnData(sf::Packet& packet)
break;
default:
PanicAlertFmtT("Unknown message received with id : {0}", mid);
PanicAlertFmtT("Unknown message received with id : {0}", static_cast<u8>(mid));
break;
}
}
@ -995,7 +995,7 @@ void NetPlayClient::OnSyncSaveData(sf::Packet& packet)
break;
default:
PanicAlertFmtT("Unknown SYNC_SAVE_DATA message received with id: {0}", sub_id);
PanicAlertFmtT("Unknown SYNC_SAVE_DATA message received with id: {0}", static_cast<u8>(sub_id));
break;
}
}
@ -1266,7 +1266,7 @@ void NetPlayClient::OnSyncCodes(sf::Packet& packet)
break;
default:
PanicAlertFmtT("Unknown SYNC_CODES message received with id: {0}", sub_id);
PanicAlertFmtT("Unknown SYNC_CODES message received with id: {0}", static_cast<u8>(sub_id));
break;
}
}
@ -1928,7 +1928,7 @@ void NetPlayClient::OnConnectFailed(TraversalConnectFailedReason reason)
PanicAlertFmtT("Invalid host");
break;
default:
PanicAlertFmtT("Unknown error {0:x}", reason);
PanicAlertFmtT("Unknown error {0:x}", static_cast<int>(reason));
break;
}
}

View File

@ -735,7 +735,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
MessageID mid;
packet >> mid;
INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", mid);
INFO_LOG_FMT(NETPLAY, "Got client message: {:x}", static_cast<u8>(mid));
// don't need lock because this is the only thread that modifies the players
// only need locks for writes to m_players in this thread
@ -1144,7 +1144,7 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
default:
PanicAlertFmtT(
"Unknown SYNC_SAVE_DATA message with id:{0} received from player:{1} Kicking player!",
sub_id, player.pid);
static_cast<u8>(sub_id), player.pid);
return 1;
}
}
@ -1186,15 +1186,15 @@ unsigned int NetPlayServer::OnData(sf::Packet& packet, Client& player)
default:
PanicAlertFmtT(
"Unknown SYNC_GECKO_CODES message with id:{0} received from player:{1} Kicking player!",
sub_id, player.pid);
static_cast<u8>(sub_id), player.pid);
return 1;
}
}
break;
default:
PanicAlertFmtT("Unknown message with id:{0} received from player:{1} Kicking player!", mid,
player.pid);
PanicAlertFmtT("Unknown message with id:{0} received from player:{1} Kicking player!",
static_cast<u8>(mid), player.pid);
// unknown message, kick the client
return 1;
}

View File

@ -100,7 +100,8 @@ void CachedInterpreter::ExecuteOneBlock()
break;
default:
ERROR_LOG_FMT(POWERPC, "Unknown CachedInterpreter Instruction: {}", code->type);
ERROR_LOG_FMT(POWERPC, "Unknown CachedInterpreter Instruction: {}",
static_cast<int>(code->type));
break;
}
}

View File

@ -848,7 +848,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
if (type == BreakpointType::ExecuteHard || type == BreakpointType::ExecuteSoft)
{
PowerPC::breakpoints.Add(addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} breakpoint: {:08x} bytes at {:08x}", type, len, addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} breakpoint: {:08x} bytes at {:08x}",
static_cast<int>(type), len, addr);
}
else
{
@ -864,7 +865,8 @@ static bool AddBreakpoint(BreakpointType type, u32 addr, u32 len)
new_memcheck.log_on_hit = false;
new_memcheck.is_enabled = true;
PowerPC::memchecks.Add(new_memcheck);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} memcheck: {:08x} bytes at {:08x}", type, len, addr);
INFO_LOG_FMT(GDB_STUB, "gdb: added {} memcheck: {:08x} bytes at {:08x}", static_cast<int>(type),
len, addr);
}
return true;
}
@ -1111,7 +1113,8 @@ bool JustConnected()
void SendSignal(Signal signal)
{
char bfr[128] = {};
fmt::format_to(bfr, "T{:02x}{:02x}:{:08x};{:02x}:{:08x};", signal, 64, PC, 1, GPR(1));
fmt::format_to(bfr, "T{:02x}{:02x}:{:08x};{:02x}:{:08x};", static_cast<u8>(signal), 64, PC, 1,
GPR(1));
SendReply(bfr);
}
} // namespace GDBStub

View File

@ -90,7 +90,8 @@ void Arm64RegCache::LockRegister(ARM64Reg host_reg)
{
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
"Don't try locking a register that isn't in the cache. Reg {}", host_reg);
"Don't try locking a register that isn't in the cache. Reg {}",
static_cast<int>(host_reg));
reg->Lock();
}
@ -98,7 +99,8 @@ void Arm64RegCache::UnlockRegister(ARM64Reg host_reg)
{
auto reg = std::find(m_host_registers.begin(), m_host_registers.end(), host_reg);
ASSERT_MSG(DYNA_REC, reg != m_host_registers.end(),
"Don't try unlocking a register that isn't in the cache. Reg {}", host_reg);
"Don't try unlocking a register that isn't in the cache. Reg {}",
static_cast<int>(host_reg));
reg->Unlock();
}

View File

@ -220,7 +220,8 @@ static void InitializeCPUCore(CPUCore cpu_core)
s_cpu_core_base = JitInterface::InitJitCore(cpu_core);
if (!s_cpu_core_base) // Handle Situations where JIT core isn't available
{
WARN_LOG_FMT(POWERPC, "CPU core {} not available. Falling back to default.", cpu_core);
WARN_LOG_FMT(POWERPC, "CPU core {} not available. Falling back to default.",
static_cast<int>(cpu_core));
s_cpu_core_base = JitInterface::InitJitCore(DefaultCPUCore());
}
break;