Fixing some particularly bad /W4.

This commit is contained in:
Ben Vanik 2015-07-18 23:04:21 -07:00
parent 4128727f6b
commit 91d7acf59e
34 changed files with 123 additions and 125 deletions

View File

@ -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.

View File

@ -212,8 +212,7 @@ struct ValueOp : Op<ValueOp<T, KEY_TYPE, REG_TYPE, CONST_TYPE>, 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_);

View File

@ -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++;

View File

@ -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++;

View File

@ -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);

View File

@ -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

View File

@ -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

View File

@ -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) {}

View File

@ -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);

View File

@ -388,7 +388,7 @@ void HIRBuilder::InsertLabel(Label* label, Instr* prev_instr) {
Block* next_block = prev_instr->block->next;
Block* new_block = arena_->Alloc<Block>();
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>();
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);

View File

@ -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

View File

@ -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);

View File

@ -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();
};

View File

@ -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);

View File

@ -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;
}

View File

@ -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)) {

View File

@ -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();

View File

@ -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;

View File

@ -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");
}

View File

@ -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_;

View File

@ -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);
}

View File

@ -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;

View File

@ -462,7 +462,7 @@ void KernelState::RegisterNotifyListener(XNotifyListener* listener) {
void KernelState::UnregisterNotifyListener(XNotifyListener* listener) {
std::lock_guard<xe::recursive_mutex> 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);

View File

@ -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<xex2_import_library*>(
(uint8_t*)libraries + library_offset);
auto name = string_table[library->name_index];
@ -363,8 +363,8 @@ void XUserModule::Dump() {
reinterpret_cast<const xex2_opt_static_libraries*>(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);

View File

@ -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;

View File

@ -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);

View File

@ -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<uint64_t> 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;

View File

@ -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;

View File

@ -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);

View File

@ -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_);

View File

@ -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);

View File

@ -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);
}

View File

@ -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;

View File

@ -41,7 +41,7 @@ bool VirtualFileSystem::RegisterSymbolicLink(std::string path,
bool VirtualFileSystem::UnregisterSymbolicLink(std::string path) {
std::lock_guard<xe::mutex> lock(mutex_);
auto& it = symlinks_.find(path);
auto it = symlinks_.find(path);
if (it == symlinks_.end()) {
return false;
}