diff --git a/premake5.lua b/premake5.lua index d03ac8857..c0b0c2d07 100644 --- a/premake5.lua +++ b/premake5.lua @@ -70,8 +70,13 @@ filter("platforms:Windows") linkoptions({"/ignore:4006", "/ignore:4221"}) -- Enable multiprocessor compiles (requires Minimal Rebuild to be disabled). buildoptions({ - "/MP", -- Multiprocessor compilation. - "/wd4100", -- Unreferenced parameters are ok. + "/MP", -- Multiprocessor compilation. + "/wd4100", -- Unreferenced parameters are ok. + "/wd4201", -- Nameless struct/unions are ok. + "/wd4512", -- 'assignment operator was implicitly defined as deleted'. + "/wd4127", -- 'conditional expression is constant'. + "/wd4324", -- 'structure was padded due to alignment specifier'. + "/wd4189", -- 'local variable is initialized but not referenced'. }) flags({ "NoMinimalRebuild", -- Required for /MP above. diff --git a/src/xenia/cpu/backend/x64/x64_sequences.cc b/src/xenia/cpu/backend/x64/x64_sequences.cc index d0125e686..90f969ba9 100644 --- a/src/xenia/cpu/backend/x64/x64_sequences.cc +++ b/src/xenia/cpu/backend/x64/x64_sequences.cc @@ -212,8 +212,7 @@ struct ValueOp : Op, KEY_TYPE> { bool operator==(const Xbyak::Reg& b) const { return IsEqual(b); } bool operator!=(const Xbyak::Reg& b) const { return !IsEqual(b); } void Load(const Instr::Op& op) { - const Value* value = op.value; - this->value = value; + value = op.value; is_constant = value->IsConstant(); if (!is_constant) { X64Emitter::SetupReg(value, reg_); diff --git a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc index b67787e40..5548d03ef 100644 --- a/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc +++ b/src/xenia/cpu/compiler/passes/data_flow_analysis_pass.cc @@ -55,7 +55,7 @@ bool DataFlowAnalysisPass::Run(HIRBuilder* builder) { uint32_t DataFlowAnalysisPass::LinearizeBlocks(HIRBuilder* builder) { // TODO(benvanik): actually do this - we cheat now knowing that they are in // sequential order. - uint32_t block_ordinal = 0; + uint16_t block_ordinal = 0; auto block = builder->first_block(); while (block) { block->ordinal = block_ordinal++; diff --git a/src/xenia/cpu/compiler/passes/finalization_pass.cc b/src/xenia/cpu/compiler/passes/finalization_pass.cc index 82b068273..29fd643a7 100644 --- a/src/xenia/cpu/compiler/passes/finalization_pass.cc +++ b/src/xenia/cpu/compiler/passes/finalization_pass.cc @@ -34,7 +34,7 @@ bool FinalizationPass::Run(HIRBuilder* builder) { auto arena = builder->arena(); - uint32_t block_ordinal = 0; + uint16_t block_ordinal = 0; auto block = builder->first_block(); while (block) { block->ordinal = block_ordinal++; diff --git a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc index c554cc63d..5fdfef8c2 100644 --- a/src/xenia/cpu/compiler/passes/register_allocation_pass.cc +++ b/src/xenia/cpu/compiler/passes/register_allocation_pass.cc @@ -77,7 +77,7 @@ bool RegisterAllocationPass::Run(HIRBuilder* builder) { // Really, it'd just be nice to have someone who knew what they // were doing lower SSA and do this right. - uint32_t block_ordinal = 0; + uint16_t block_ordinal = 0; uint32_t instr_ordinal = 0; auto block = builder->first_block(); while (block) { @@ -212,27 +212,27 @@ void RegisterAllocationPass::AdvanceUses(Instr* instr) { break; } auto& upcoming_uses = usage_set->upcoming_uses; - for (int i = 0; i < upcoming_uses.size();) { - auto& upcoming_use = upcoming_uses.at(i); + for (size_t j = 0; j < upcoming_uses.size();) { + auto& upcoming_use = upcoming_uses.at(j); if (!upcoming_use.use) { // No uses at all - we can remove right away. // This comes up from instructions where the dest is never used, // like the ATOMIC ops. MarkRegAvailable(upcoming_use.value->reg); - upcoming_uses.erase(upcoming_uses.begin() + i); + upcoming_uses.erase(upcoming_uses.begin() + j); // i remains the same. continue; } if (upcoming_use.use->instr != instr) { // Not yet at this instruction. - ++i; + ++j; continue; } // The use is from this instruction. if (!upcoming_use.use->next) { // Last use of the value. We can retire it now. MarkRegAvailable(upcoming_use.value->reg); - upcoming_uses.erase(upcoming_uses.begin() + i); + upcoming_uses.erase(upcoming_uses.begin() + j); // i remains the same. continue; } else { @@ -245,7 +245,7 @@ void RegisterAllocationPass::AdvanceUses(Instr* instr) { } // Remove the iterator. auto value = upcoming_use.value; - upcoming_uses.erase(upcoming_uses.begin() + i); + upcoming_uses.erase(upcoming_uses.begin() + j); assert_true(next_use->instr->block == instr->block); assert_true(value->def->block == instr->block); upcoming_uses.emplace_back(value, next_use); diff --git a/src/xenia/cpu/export_resolver.h b/src/xenia/cpu/export_resolver.h index c336b9465..7824be86a 100644 --- a/src/xenia/cpu/export_resolver.h +++ b/src/xenia/cpu/export_resolver.h @@ -23,30 +23,30 @@ struct ExportTag { typedef uint32_t type; // Export is implemented in some form and can be used. - static const type kImplemented = 1 << 0; + static const type kImplemented = 1u << 0; // Export is a stub and is probably bad. - static const type kStub = 1 << 1; + static const type kStub = 1u << 1; // Export is known to cause problems, or may not be complete. - static const type kSketchy = 1 << 2; + static const type kSketchy = 1u << 2; // Export is called *a lot*. - static const type kHighFrequency = 1 << 3; + static const type kHighFrequency = 1u << 3; // Export is important and should always be logged. - static const type kImportant = 1 << 4; + static const type kImportant = 1u << 4; - static const type kThreading = 1 << 10; - static const type kInput = 1 << 11; - static const type kAudio = 1 << 12; - static const type kVideo = 1 << 13; - static const type kFileSystem = 1 << 14; - static const type kModules = 1 << 15; - static const type kUserProfiles = 1 << 16; - static const type kNetworking = 1 << 17; - static const type kMemory = 1 << 18; + static const type kThreading = 1u << 10; + static const type kInput = 1u << 11; + static const type kAudio = 1u << 12; + static const type kVideo = 1u << 13; + static const type kFileSystem = 1u << 14; + static const type kModules = 1u << 15; + static const type kUserProfiles = 1u << 16; + static const type kNetworking = 1u << 17; + static const type kMemory = 1u << 18; // Export will be logged on each call. - static const type kLog = 1 << 30; + static const type kLog = 1u << 30; // Export's result will be logged on each call. - static const type kLogResult = 1 << 31; + static const type kLogResult = 1u << 31; }; // DEPRECATED diff --git a/src/xenia/cpu/frontend/ppc_context.h b/src/xenia/cpu/frontend/ppc_context.h index 58beda6ee..df4c98bb3 100644 --- a/src/xenia/cpu/frontend/ppc_context.h +++ b/src/xenia/cpu/frontend/ppc_context.h @@ -40,7 +40,7 @@ namespace frontend { // 100: invalid // 128-256: VR -#pragma pack(push, 4) +#pragma pack(push, 8) typedef struct alignas(64) PPCContext_s { // Must be stored at 0x0 for now. // TODO(benvanik): find a nice way to describe this to the JIT. @@ -49,9 +49,11 @@ typedef struct alignas(64) PPCContext_s { uint8_t* virtual_membase; // Most frequently used registers first. - uint64_t r[32]; // General purpose registers - uint64_t lr; // Link register - uint64_t ctr; // Count register + uint64_t lr; // Link register + uint64_t ctr; // Count register + uint64_t r[32]; // General purpose registers + double f[32]; // Floating-point registers + vec128_t v[128]; // VMX128 vector registers // XER register // Split to make it easier to do individual updates. @@ -188,9 +190,6 @@ typedef struct alignas(64) PPCContext_s { uint8_t vscr_sat; - double f[32]; // Floating-point registers - vec128_t v[128]; // VMX128 vector registers - // uint32_t get_fprf() { // return fpscr.value & 0x000F8000; // } @@ -216,11 +215,15 @@ typedef struct alignas(64) PPCContext_s { uint8_t* physical_membase; + // Keep the struct padded out to 64b total. + uint8_t _padding[8]; + void SetRegFromString(const char* name, const char* value); bool CompareRegWithString(const char* name, const char* value, char* out_value, size_t out_value_size); } PPCContext; #pragma pack(pop) +static_assert(sizeof(PPCContext) % 64 == 0, "64b padded"); } // namespace frontend } // namespace cpu diff --git a/src/xenia/cpu/frontend/ppc_instr.cc b/src/xenia/cpu/frontend/ppc_instr.cc index 0c5270a04..e4e4b8fc5 100644 --- a/src/xenia/cpu/frontend/ppc_instr.cc +++ b/src/xenia/cpu/frontend/ppc_instr.cc @@ -295,10 +295,11 @@ void InstrAccessBits::Dump(std::string& out_str) { out_str = str.str(); } -void InstrDisasm::Init(const char* name, const char* info, uint32_t flags) { - this->name = name; - this->info = info; - this->flags = flags; +void InstrDisasm::Init(const char* new_name, const char* new_info, + uint32_t new_flags) { + name = new_name; + info = new_info; + flags = new_flags; } void InstrDisasm::AddLR(InstrRegister::Access access) {} diff --git a/src/xenia/cpu/frontend/ppc_instr.h b/src/xenia/cpu/frontend/ppc_instr.h index 8f372d79c..1067f0351 100644 --- a/src/xenia/cpu/frontend/ppc_instr.h +++ b/src/xenia/cpu/frontend/ppc_instr.h @@ -483,7 +483,7 @@ class InstrDisasm { const char* info; uint32_t flags; - void Init(const char* name, const char* info, uint32_t flags); + void Init(const char* new_name, const char* new_info, uint32_t new_flags); void AddLR(InstrRegister::Access access); void AddCTR(InstrRegister::Access access); void AddCR(uint32_t bf, InstrRegister::Access access); diff --git a/src/xenia/cpu/hir/hir_builder.cc b/src/xenia/cpu/hir/hir_builder.cc index 1a3c21168..4fb2a3c2f 100644 --- a/src/xenia/cpu/hir/hir_builder.cc +++ b/src/xenia/cpu/hir/hir_builder.cc @@ -388,7 +388,7 @@ void HIRBuilder::InsertLabel(Label* label, Instr* prev_instr) { Block* next_block = prev_instr->block->next; Block* new_block = arena_->Alloc(); - new_block->ordinal = -1; + new_block->ordinal = UINT16_MAX; new_block->incoming_values = nullptr; new_block->arena = arena_; new_block->prev = prev_block; @@ -466,10 +466,10 @@ void HIRBuilder::AddEdge(Block* src, Block* dest, uint32_t flags) { if (dest_was_dominated) { // If dest was previously dominated it no longer is. - auto edge = dest->incoming_edge_head; - while (edge) { - edge->flags &= ~Edge::DOMINATES; - edge = edge->incoming_next; + auto incoming_edge = dest->incoming_edge_head; + while (incoming_edge) { + incoming_edge->flags &= ~Edge::DOMINATES; + incoming_edge = incoming_edge->incoming_next; } } } @@ -633,7 +633,7 @@ void HIRBuilder::MergeAdjacentBlocks(Block* left, Block* right) { Block* HIRBuilder::AppendBlock() { Block* block = arena_->Alloc(); - block->ordinal = -1; + block->ordinal = UINT16_MAX; block->incoming_values = nullptr; block->arena = arena_; block->next = NULL; @@ -690,7 +690,7 @@ Instr* HIRBuilder::AppendInstr(const OpcodeInfo& opcode_info, uint16_t flags, if (!block->instr_head) { block->instr_head = instr; } - instr->ordinal = -1; + instr->ordinal = UINT32_MAX; instr->block = block; instr->opcode = &opcode_info; instr->flags = flags; @@ -824,7 +824,7 @@ void HIRBuilder::TrapTrue(Value* cond, uint16_t trap_code) { EndBlock(); } -void HIRBuilder::Call(FunctionInfo* symbol_info, uint32_t call_flags) { +void HIRBuilder::Call(FunctionInfo* symbol_info, uint16_t call_flags) { Instr* i = AppendInstr(OPCODE_CALL_info, call_flags); i->src1.symbol_info = symbol_info; i->src2.value = i->src3.value = NULL; @@ -832,7 +832,7 @@ void HIRBuilder::Call(FunctionInfo* symbol_info, uint32_t call_flags) { } void HIRBuilder::CallTrue(Value* cond, FunctionInfo* symbol_info, - uint32_t call_flags) { + uint16_t call_flags) { if (cond->IsConstant()) { if (cond->IsConstantTrue()) { Call(symbol_info, call_flags); @@ -847,7 +847,7 @@ void HIRBuilder::CallTrue(Value* cond, FunctionInfo* symbol_info, EndBlock(); } -void HIRBuilder::CallIndirect(Value* value, uint32_t call_flags) { +void HIRBuilder::CallIndirect(Value* value, uint16_t call_flags) { ASSERT_CALL_ADDRESS_TYPE(value); Instr* i = AppendInstr(OPCODE_CALL_INDIRECT_info, call_flags); i->set_src1(value); @@ -856,7 +856,7 @@ void HIRBuilder::CallIndirect(Value* value, uint32_t call_flags) { } void HIRBuilder::CallIndirectTrue(Value* cond, Value* value, - uint32_t call_flags) { + uint16_t call_flags) { if (cond->IsConstant()) { if (cond->IsConstantTrue()) { CallIndirect(value, call_flags); @@ -907,14 +907,14 @@ void HIRBuilder::SetReturnAddress(Value* value) { i->src2.value = i->src3.value = NULL; } -void HIRBuilder::Branch(Label* label, uint32_t branch_flags) { +void HIRBuilder::Branch(Label* label, uint16_t branch_flags) { Instr* i = AppendInstr(OPCODE_BRANCH_info, branch_flags); i->src1.label = label; i->src2.value = i->src3.value = NULL; EndBlock(); } -void HIRBuilder::Branch(Block* block, uint32_t branch_flags) { +void HIRBuilder::Branch(Block* block, uint16_t branch_flags) { if (!block->label_head) { // Block needs a label. Label* label = NewLabel(); @@ -923,7 +923,7 @@ void HIRBuilder::Branch(Block* block, uint32_t branch_flags) { Branch(block->label_head, branch_flags); } -void HIRBuilder::BranchTrue(Value* cond, Label* label, uint32_t branch_flags) { +void HIRBuilder::BranchTrue(Value* cond, Label* label, uint16_t branch_flags) { if (cond->IsConstant()) { if (cond->IsConstantTrue()) { Branch(label, branch_flags); @@ -938,7 +938,7 @@ void HIRBuilder::BranchTrue(Value* cond, Label* label, uint32_t branch_flags) { EndBlock(); } -void HIRBuilder::BranchFalse(Value* cond, Label* label, uint32_t branch_flags) { +void HIRBuilder::BranchFalse(Value* cond, Label* label, uint16_t branch_flags) { if (cond->IsConstant()) { if (cond->IsConstantFalse()) { Branch(label, branch_flags); diff --git a/src/xenia/cpu/hir/hir_builder.h b/src/xenia/cpu/hir/hir_builder.h index ce1119b74..00a6f6b96 100644 --- a/src/xenia/cpu/hir/hir_builder.h +++ b/src/xenia/cpu/hir/hir_builder.h @@ -83,20 +83,20 @@ class HIRBuilder { void Trap(uint16_t trap_code = 0); void TrapTrue(Value* cond, uint16_t trap_code = 0); - void Call(FunctionInfo* symbol_info, uint32_t call_flags = 0); + void Call(FunctionInfo* symbol_info, uint16_t call_flags = 0); void CallTrue(Value* cond, FunctionInfo* symbol_info, - uint32_t call_flags = 0); - void CallIndirect(Value* value, uint32_t call_flags = 0); - void CallIndirectTrue(Value* cond, Value* value, uint32_t call_flags = 0); + uint16_t call_flags = 0); + void CallIndirect(Value* value, uint16_t call_flags = 0); + void CallIndirectTrue(Value* cond, Value* value, uint16_t call_flags = 0); void CallExtern(FunctionInfo* symbol_info); void Return(); void ReturnTrue(Value* cond); void SetReturnAddress(Value* value); - void Branch(Label* label, uint32_t branch_flags = 0); - void Branch(Block* block, uint32_t branch_flags = 0); - void BranchTrue(Value* cond, Label* label, uint32_t branch_flags = 0); - void BranchFalse(Value* cond, Label* label, uint32_t branch_flags = 0); + void Branch(Label* label, uint16_t branch_flags = 0); + void Branch(Block* block, uint16_t branch_flags = 0); + void BranchTrue(Value* cond, Label* label, uint16_t branch_flags = 0); + void BranchFalse(Value* cond, Label* label, uint16_t branch_flags = 0); // phi type_name, Block* b1, Value* v1, Block* b2, Value* v2, etc diff --git a/src/xenia/cpu/hir/instr.cc b/src/xenia/cpu/hir/instr.cc index 796e54f06..657dc5f53 100644 --- a/src/xenia/cpu/hir/instr.cc +++ b/src/xenia/cpu/hir/instr.cc @@ -78,9 +78,9 @@ void Instr::MoveBefore(Instr* other) { } } -void Instr::Replace(const OpcodeInfo* opcode, uint16_t flags) { - this->opcode = opcode; - this->flags = flags; +void Instr::Replace(const OpcodeInfo* new_opcode, uint16_t new_flags) { + opcode = new_opcode; + flags = new_flags; if (src1_use) { src1.value->RemoveUse(src1_use); diff --git a/src/xenia/cpu/hir/instr.h b/src/xenia/cpu/hir/instr.h index 2406781dc..eee365acd 100644 --- a/src/xenia/cpu/hir/instr.h +++ b/src/xenia/cpu/hir/instr.h @@ -57,7 +57,7 @@ class Instr { void set_src3(Value* value); void MoveBefore(Instr* other); - void Replace(const OpcodeInfo* opcode, uint16_t flags); + void Replace(const OpcodeInfo* new_opcode, uint16_t new_flags); void Remove(); }; diff --git a/src/xenia/cpu/hir/value.cc b/src/xenia/cpu/hir/value.cc index bedef09c2..75ac758ca 100644 --- a/src/xenia/cpu/hir/value.cc +++ b/src/xenia/cpu/hir/value.cc @@ -421,22 +421,22 @@ void Value::Neg() { void Value::Abs() { switch (type) { case INT8_TYPE: - constant.i8 = abs(constant.i8); + constant.i8 = int8_t(std::abs(constant.i8)); break; case INT16_TYPE: - constant.i16 = abs(constant.i16); + constant.i16 = int16_t(std::abs(constant.i16)); break; case INT32_TYPE: - constant.i32 = abs(constant.i32); + constant.i32 = std::abs(constant.i32); break; case INT64_TYPE: - constant.i64 = abs(constant.i64); + constant.i64 = std::abs(constant.i64); break; case FLOAT32_TYPE: - constant.f32 = abs(constant.f32); + constant.f32 = std::abs(constant.f32); break; case FLOAT64_TYPE: - constant.f64 = abs(constant.f64); + constant.f64 = std::abs(constant.f64); break; case VEC128_TYPE: for (int i = 0; i < 4; ++i) { @@ -452,10 +452,10 @@ void Value::Abs() { void Value::Sqrt() { switch (type) { case FLOAT32_TYPE: - constant.f32 = 1.0f / sqrtf(constant.f32); + constant.f32 = 1.0f / std::sqrtf(constant.f32); break; case FLOAT64_TYPE: - constant.f64 = 1.0 / sqrt(constant.f64); + constant.f64 = 1.0 / std::sqrt(constant.f64); break; default: assert_unhandled_case(type); @@ -466,10 +466,10 @@ void Value::Sqrt() { void Value::RSqrt() { switch (type) { case FLOAT32_TYPE: - constant.f32 = sqrt(constant.f32); + constant.f32 = std::sqrt(constant.f32); break; case FLOAT64_TYPE: - constant.f64 = sqrt(constant.f64); + constant.f64 = std::sqrt(constant.f64); break; default: assert_unhandled_case(type); diff --git a/src/xenia/cpu/hir/value.h b/src/xenia/cpu/hir/value.h index 00166a869..cc593c995 100644 --- a/src/xenia/cpu/hir/value.h +++ b/src/xenia/cpu/hir/value.h @@ -113,8 +113,8 @@ class Value { double get_constant(double) const { return constant.f64; } vec128_t get_constant(vec128_t&) const { return constant.v128; } - void set_zero(TypeName type) { - this->type = type; + void set_zero(TypeName new_type) { + type = new_type; flags |= VALUE_IS_CONSTANT; constant.v128.low = constant.v128.high = 0; } diff --git a/src/xenia/cpu/mmio_handler.cc b/src/xenia/cpu/mmio_handler.cc index 6be6992da..002855aa2 100644 --- a/src/xenia/cpu/mmio_handler.cc +++ b/src/xenia/cpu/mmio_handler.cc @@ -281,7 +281,7 @@ bool MMIOHandler::HandleAccessFault(void* thread_state, } } else if (is_store) { // Store of a register value - read register, swap, write to range. - uint64_t value; + uint64_t value = 0; if ((arg2_type & BE::REGISTER_TYPE) == BE::REGISTER_TYPE) { uint32_t be_reg_index; if (!xe::bit_scan_forward(arg2_type & 0xFFFF, &be_reg_index)) { diff --git a/src/xenia/cpu/processor.cc b/src/xenia/cpu/processor.cc index 8db6474f0..8173590ce 100644 --- a/src/xenia/cpu/processor.cc +++ b/src/xenia/cpu/processor.cc @@ -30,10 +30,6 @@ namespace xe { namespace cpu { -// TODO(benvanik): remove when enums converted. -using namespace xe::cpu; -using namespace xe::cpu::backend; - using PPCContext = xe::cpu::frontend::PPCContext; void InitializeIfNeeded(); diff --git a/src/xenia/cpu/thread_state.cc b/src/xenia/cpu/thread_state.cc index 874e194f8..5bc5cc4a0 100644 --- a/src/xenia/cpu/thread_state.cc +++ b/src/xenia/cpu/thread_state.cc @@ -22,8 +22,6 @@ namespace xe { namespace cpu { -using namespace xe::cpu; - using PPCContext = xe::cpu::frontend::PPCContext; thread_local ThreadState* thread_state_ = nullptr; @@ -55,7 +53,7 @@ ThreadState::ThreadState(Processor* processor, uint32_t thread_id, uint32_t stack_padding = uint32_t(xe::memory::page_size()); // Host page size. uint32_t actual_stack_size = stack_padding + stack_size; - bool top_down; + bool top_down = false; switch (stack_type) { case ThreadStackType::kKernelStack: top_down = true; diff --git a/src/xenia/cpu/xex_module.cc b/src/xenia/cpu/xex_module.cc index d73553a3f..712f6fa53 100644 --- a/src/xenia/cpu/xex_module.cc +++ b/src/xenia/cpu/xex_module.cc @@ -26,13 +26,11 @@ namespace xe { namespace cpu { -using namespace xe::cpu; using namespace xe::kernel; using PPCContext = xe::cpu::frontend::PPCContext; -void UndefinedImport(PPCContext* ppc_context, - kernel::KernelState* kernel_state) { +void UndefinedImport(PPCContext* ppc_context, KernelState* kernel_state) { XELOGE("call to undefined import"); } diff --git a/src/xenia/debug/debugger.h b/src/xenia/debug/debugger.h index 72963bfcc..7342860f8 100644 --- a/src/xenia/debug/debugger.h +++ b/src/xenia/debug/debugger.h @@ -110,11 +110,11 @@ class Debugger { Emulator* emulator_ = nullptr; - uintptr_t listen_socket_ = ~0; + uintptr_t listen_socket_ = ~0u; bool accept_thread_running_ = false; std::thread accept_thread_; xe::threading::Fence accept_fence_; - uintptr_t client_socket_ = ~0; + uintptr_t client_socket_ = ~0u; std::thread receive_thread_; std::wstring functions_path_; diff --git a/src/xenia/gpu/ucode_disassembler.cc b/src/xenia/gpu/ucode_disassembler.cc index 777c5e129..81fa3f3ee 100644 --- a/src/xenia/gpu/ucode_disassembler.cc +++ b/src/xenia/gpu/ucode_disassembler.cc @@ -615,7 +615,7 @@ void print_cf_exec(StringBuffer* output, const instr_cf_t* cf) { if (cf->exec.yeild) { output->Append(" YIELD"); } - uint8_t vc = cf->exec.vc_hi | (cf->exec.vc_lo << 2); + uint8_t vc = uint8_t(cf->exec.vc_hi | (cf->exec.vc_lo << 2)); if (vc) { output->AppendFormat(" VC(0x%x)", vc); } diff --git a/src/xenia/hid/winkey/winkey_input_driver.cc b/src/xenia/hid/winkey/winkey_input_driver.cc index fddb77b9e..b6558d345 100644 --- a/src/xenia/hid/winkey/winkey_input_driver.cc +++ b/src/xenia/hid/winkey/winkey_input_driver.cc @@ -36,10 +36,10 @@ X_RESULT WinKeyInputDriver::GetCapabilities(uint32_t user_index, uint32_t flags, out_caps->gamepad.buttons = 0xFFFF; out_caps->gamepad.left_trigger = 0xFF; out_caps->gamepad.right_trigger = 0xFF; - out_caps->gamepad.thumb_lx = (int16_t)0xFFFF; - out_caps->gamepad.thumb_ly = (int16_t)0xFFFF; - out_caps->gamepad.thumb_rx = (int16_t)0xFFFF; - out_caps->gamepad.thumb_ry = (int16_t)0xFFFF; + out_caps->gamepad.thumb_lx = (int16_t)0xFFFFu; + out_caps->gamepad.thumb_ly = (int16_t)0xFFFFu; + out_caps->gamepad.thumb_rx = (int16_t)0xFFFFu; + out_caps->gamepad.thumb_ry = (int16_t)0xFFFFu; out_caps->vibration.left_motor_speed = 0; out_caps->vibration.right_motor_speed = 0; return X_ERROR_SUCCESS; diff --git a/src/xenia/kernel/kernel_state.cc b/src/xenia/kernel/kernel_state.cc index f98b3feed..d1ceee543 100644 --- a/src/xenia/kernel/kernel_state.cc +++ b/src/xenia/kernel/kernel_state.cc @@ -462,7 +462,7 @@ void KernelState::RegisterNotifyListener(XNotifyListener* listener) { void KernelState::UnregisterNotifyListener(XNotifyListener* listener) { std::lock_guard lock(object_mutex_); - for (auto& it = notify_listeners_.begin(); it != notify_listeners_.end(); + for (auto it = notify_listeners_.begin(); it != notify_listeners_.end(); ++it) { if ((*it).get() == listener) { notify_listeners_.erase(it); diff --git a/src/xenia/kernel/objects/xuser_module.cc b/src/xenia/kernel/objects/xuser_module.cc index 037611d37..a1b5c7848 100644 --- a/src/xenia/kernel/objects/xuser_module.cc +++ b/src/xenia/kernel/objects/xuser_module.cc @@ -311,24 +311,24 @@ void XUserModule::Dump() { std::memset(string_table, 0, sizeof(string_table)); // Parse the string table - for (size_t i = 0, j = 0; i < opt_import_libraries->string_table_size; + for (size_t l = 0, j = 0; l < opt_import_libraries->string_table_size; j++) { assert_true(j < xe::countof(string_table)); - const char* str = opt_import_libraries->string_table + i; + const char* str = opt_import_libraries->string_table + l; string_table[j] = str; - i += std::strlen(str) + 1; + l += std::strlen(str) + 1; // Padding - if ((i % 4) != 0) { - i += 4 - (i % 4); + if ((l % 4) != 0) { + l += 4 - (l % 4); } } auto libraries = (uint8_t*)opt_import_libraries + opt_import_libraries->string_table_size + 12; uint32_t library_offset = 0; - for (uint32_t i = 0; i < opt_import_libraries->library_count; i++) { + for (uint32_t l = 0; l < opt_import_libraries->library_count; l++) { auto library = reinterpret_cast( (uint8_t*)libraries + library_offset); auto name = string_table[library->name_index]; @@ -363,8 +363,8 @@ void XUserModule::Dump() { reinterpret_cast(opt_header_ptr); uint32_t count = (opt_static_libraries->size - 4) / 0x10; - for (uint32_t i = 0; i < count; i++) { - auto& library = opt_static_libraries->libraries[i]; + for (uint32_t l = 0; l < count; l++) { + auto& library = opt_static_libraries->libraries[l]; printf( " %-8s : %d.%d.%d.%d\n", library.name, (uint16_t)library.version_major, (uint16_t)library.version_minor, @@ -456,9 +456,9 @@ void XUserModule::Dump() { uint16_t* ordinal_table = (uint16_t*)((uint64_t)e + e->AddressOfNameOrdinals); - for (uint32_t i = 0; i < e->NumberOfNames; i++) { - const char* name = (const char*)((uint8_t*)e + name_table[i]); - uint16_t ordinal = ordinal_table[i]; + for (uint32_t n = 0; n < e->NumberOfNames; n++) { + const char* name = (const char*)((uint8_t*)e + name_table[n]); + uint16_t ordinal = ordinal_table[n]; uint32_t addr = exe_address + function_table[ordinal]; printf(" %-28s - %.3X - %.8X\n", name, ordinal, addr); diff --git a/src/xenia/kernel/util/xex2.cc b/src/xenia/kernel/util/xex2.cc index f44945ed9..1db286091 100644 --- a/src/xenia/kernel/util/xex2.cc +++ b/src/xenia/kernel/util/xex2.cc @@ -917,7 +917,7 @@ int xe_xex2_find_import_infos(xe_xex2_ref xex, auto header = xe_xex2_get_header(xex); // Find library index for verification. - size_t library_index = -1; + size_t library_index = ~0ull; for (size_t n = 0; n < header->import_library_count; n++) { if (&header->import_libraries[n] == library) { library_index = n; @@ -995,7 +995,7 @@ int xe_xex2_get_import_infos(xe_xex2_ref xex, auto header = xe_xex2_get_header(xex); // Find library index for verification. - size_t library_index = -1; + size_t library_index = ~0ull; for (size_t n = 0; n < header->import_library_count; n++) { if (&header->import_libraries[n] == library) { library_index = n; diff --git a/src/xenia/kernel/xam_avatar.cc b/src/xenia/kernel/xam_avatar.cc index 4d3ef9692..e206428fa 100644 --- a/src/xenia/kernel/xam_avatar.cc +++ b/src/xenia/kernel/xam_avatar.cc @@ -25,7 +25,7 @@ dword_result_t XamAvatarInitialize( dword_t unk6 // flags - 0x00300000, 0x30, etc ) { // Negative to fail. Game should immediately call XamAvatarShutdown. - return -1; + return ~0u; } DECLARE_XAM_EXPORT(XamAvatarInitialize, ExportTag::kStub); diff --git a/src/xenia/kernel/xam_net.cc b/src/xenia/kernel/xam_net.cc index 916dc4880..cd2935bc0 100644 --- a/src/xenia/kernel/xam_net.cc +++ b/src/xenia/kernel/xam_net.cc @@ -185,7 +185,7 @@ SHIM_CALL NetDll_XNetRandom_shim(PPCContext* ppc_context, SHIM_CALL NetDll_WSAStartup_shim(PPCContext* ppc_context, KernelState* kernel_state) { uint32_t caller = SHIM_GET_ARG_32(0); - uint32_t version = SHIM_GET_ARG_16(1); + uint16_t version = SHIM_GET_ARG_16(1); uint32_t data_ptr = SHIM_GET_ARG_32(2); XELOGD("NetDll_WSAStartup(%d, %.4X, %.8X)", caller, version, data_ptr); @@ -264,7 +264,7 @@ dword_result_t NetDll_WSAWaitForMultipleEvents( dword_t timeout, dword_t alertable) { if (num_events > 64) { XThread::GetCurrentThread()->set_last_error(87); // ERROR_INVALID_PARAMETER - return -1; + return ~0u; } xe::be timeout_wait = (uint64_t)timeout; @@ -279,7 +279,7 @@ dword_result_t NetDll_WSAWaitForMultipleEvents( if (XFAILED(result)) { uint32_t error = RtlNtStatusToDosError(result); XThread::GetCurrentThread()->set_last_error(error); - return -1; + return ~0u; } return 0; diff --git a/src/xenia/memory.cc b/src/xenia/memory.cc index 994f9e080..5a8fa874b 100644 --- a/src/xenia/memory.cc +++ b/src/xenia/memory.cc @@ -611,7 +611,6 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address, for (int64_t base_page_number = high_page_number - page_count; base_page_number >= low_page_number; base_page_number -= page_scan_stride) { - bool is_free = page_table_[base_page_number].state == 0; if (page_table_[base_page_number].state != 0) { // Base page not free, skip to next usable page. continue; @@ -645,7 +644,6 @@ bool BaseHeap::AllocRange(uint32_t low_address, uint32_t high_address, for (uint32_t base_page_number = low_page_number; base_page_number <= high_page_number - page_count; base_page_number += page_scan_stride) { - bool is_free = page_table_[base_page_number].state == 0; if (page_table_[base_page_number].state != 0) { // Base page not free, skip to next usable page. continue; diff --git a/src/xenia/profiling.cc b/src/xenia/profiling.cc index 1fc186158..f73c8a4ac 100644 --- a/src/xenia/profiling.cc +++ b/src/xenia/profiling.cc @@ -55,8 +55,8 @@ void Profiler::Initialize() { #if XE_OPTION_PROFILING_UI MicroProfileInitUI(); g_MicroProfileUI.bShowSpikes = true; - g_MicroProfileUI.nOpacityBackground = 0x40 << 24; - g_MicroProfileUI.nOpacityForeground = 0xc0 << 24; + g_MicroProfileUI.nOpacityBackground = 0x40u << 24; + g_MicroProfileUI.nOpacityForeground = 0xc0u << 24; MicroProfileSetDisplayMode(1); #else MicroProfileSetForceEnable(true); diff --git a/src/xenia/ui/gl/circular_buffer.cc b/src/xenia/ui/gl/circular_buffer.cc index 575a37b9e..ba50aa1d0 100644 --- a/src/xenia/ui/gl/circular_buffer.cc +++ b/src/xenia/ui/gl/circular_buffer.cc @@ -80,7 +80,7 @@ CircularBuffer::Allocation CircularBuffer::Acquire(size_t length) { bool CircularBuffer::AcquireCached(uint32_t key, size_t length, Allocation* out_allocation) { uint64_t full_key = key | (length << 32); - auto& it = allocation_cache_.find(full_key); + auto it = allocation_cache_.find(full_key); if (it != allocation_cache_.end()) { uintptr_t write_head = it->second; size_t aligned_length = xe::round_up(length, alignment_); diff --git a/src/xenia/ui/menu_item.cc b/src/xenia/ui/menu_item.cc index 06f8c9774..630189e1d 100644 --- a/src/xenia/ui/menu_item.cc +++ b/src/xenia/ui/menu_item.cc @@ -52,7 +52,7 @@ void MenuItem::AddChild(MenuItemPtr child_item) { } void MenuItem::RemoveChild(MenuItem* child_item) { - for (auto& it = children_.begin(); it != children_.end(); ++it) { + for (auto it = children_.begin(); it != children_.end(); ++it) { if (it->get() == child_item) { children_.erase(it); OnChildRemoved(child_item); diff --git a/src/xenia/vfs/devices/stfs_container_device.cc b/src/xenia/vfs/devices/stfs_container_device.cc index aa8e0402b..190fbe501 100644 --- a/src/xenia/vfs/devices/stfs_container_device.cc +++ b/src/xenia/vfs/devices/stfs_container_device.cc @@ -224,7 +224,7 @@ StfsContainerDevice::Error StfsContainerDevice::ReadAllEntries( size_t StfsContainerDevice::BlockToOffset(uint32_t block) { if (block >= 0xFFFFFF) { - return -1; + return ~0ull; } else { return ((header_.header_size + 0x0FFF) & 0xF000) + (block << 12); } diff --git a/src/xenia/vfs/entry.cc b/src/xenia/vfs/entry.cc index 9673b21cb..d1c81ec6f 100644 --- a/src/xenia/vfs/entry.cc +++ b/src/xenia/vfs/entry.cc @@ -100,7 +100,7 @@ bool Entry::Delete(Entry* entry) { if (!DeleteEntryInternal(entry)) { return false; } - for (auto& it = children_.begin(); it != children_.end(); ++it) { + for (auto it = children_.begin(); it != children_.end(); ++it) { if (it->get() == entry) { children_.erase(it); break; diff --git a/src/xenia/vfs/virtual_file_system.cc b/src/xenia/vfs/virtual_file_system.cc index c11488cb0..bbc6dc4a9 100644 --- a/src/xenia/vfs/virtual_file_system.cc +++ b/src/xenia/vfs/virtual_file_system.cc @@ -41,7 +41,7 @@ bool VirtualFileSystem::RegisterSymbolicLink(std::string path, bool VirtualFileSystem::UnregisterSymbolicLink(std::string path) { std::lock_guard lock(mutex_); - auto& it = symlinks_.find(path); + auto it = symlinks_.find(path); if (it == symlinks_.end()) { return false; }