From 080cdb35d80e176c1c3c14028dba321ed5bae2e1 Mon Sep 17 00:00:00 2001 From: Thonnat Date: Fri, 2 Jun 2017 17:03:36 +0200 Subject: [PATCH] MSVC: clear some warning Disable warning with pragma in arm_dyncom_trans.h Type refactoring signed/unsigned Type cast 32/64 bit --- src/common/logging/backend.cpp | 4 ++++ src/common/vector_math.h | 2 +- src/core/arm/arm_interface.h | 2 +- src/core/arm/dynarmic/arm_dynarmic.cpp | 4 ++-- src/core/arm/dynarmic/arm_dynarmic.h | 2 +- src/core/arm/dyncom/arm_dyncom_interpreter.cpp | 6 +++--- src/core/arm/dyncom/arm_dyncom_trans.h | 7 +++++++ src/core/file_sys/archive_backend.cpp | 3 +++ src/core/frontend/emu_window.cpp | 4 ++-- src/core/hle/ipc.h | 4 ++-- src/core/hle/kernel/mutex.h | 2 +- src/core/hle/kernel/thread.cpp | 4 ++-- src/core/hle/kernel/thread.h | 2 +- src/core/hle/svc.cpp | 3 ++- src/core/hw/gpu.h | 1 + src/video_core/regs_framebuffer.h | 2 ++ src/video_core/swrasterizer/framebuffer.cpp | 3 +++ src/video_core/swrasterizer/texturing.cpp | 7 +++++++ 18 files changed, 45 insertions(+), 17 deletions(-) diff --git a/src/common/logging/backend.cpp b/src/common/logging/backend.cpp index 42f6a9918..59f58b40a 100644 --- a/src/common/logging/backend.cpp +++ b/src/common/logging/backend.cpp @@ -87,7 +87,9 @@ const char* GetLogClassName(Class log_class) { #undef CLS #undef SUB case Class::Count: + default: UNREACHABLE(); + return {}; } } @@ -103,7 +105,9 @@ const char* GetLevelName(Level log_level) { LVL(Error); LVL(Critical); case Level::Count: + default: UNREACHABLE(); + return {}; } #undef LVL } diff --git a/src/common/vector_math.h b/src/common/vector_math.h index c7a461a1e..95e98b0a3 100644 --- a/src/common/vector_math.h +++ b/src/common/vector_math.h @@ -91,7 +91,7 @@ public: y -= other.y; } template ::value>::type> - Vec2 operator-() const { + Vec2 operator-() const { return MakeVec(-x, -y); } Vec2 operator*(const Vec2& other) const { diff --git a/src/core/arm/arm_interface.h b/src/core/arm/arm_interface.h index ccd43f431..258a11dd0 100644 --- a/src/core/arm/arm_interface.h +++ b/src/core/arm/arm_interface.h @@ -125,7 +125,7 @@ public: * Advance the CPU core by the specified number of ticks (e.g. to simulate CPU execution time) * @param ticks Number of ticks to advance the CPU core */ - virtual void AddTicks(u64 ticks) = 0; + virtual void AddTicks(size_t ticks) = 0; /** * Saves the current CPU context diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 7d2790b08..709070008 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -124,7 +124,7 @@ void ARM_Dynarmic::SetCP15Register(CP15Register reg, u32 value) { interpreter_state->CP15[reg] = value; } -void ARM_Dynarmic::AddTicks(u64 ticks) { +void ARM_Dynarmic::AddTicks(size_t ticks) { down_count -= ticks; if (down_count < 0) { CoreTiming::Advance(); @@ -136,7 +136,7 @@ MICROPROFILE_DEFINE(ARM_Jit, "ARM JIT", "ARM JIT", MP_RGB(255, 64, 64)); void ARM_Dynarmic::ExecuteInstructions(int num_instructions) { MICROPROFILE_SCOPE(ARM_Jit); - unsigned ticks_executed = jit->Run(static_cast(num_instructions)); + size_t ticks_executed = jit->Run(static_cast(num_instructions)); AddTicks(ticks_executed); } diff --git a/src/core/arm/dynarmic/arm_dynarmic.h b/src/core/arm/dynarmic/arm_dynarmic.h index 834dc989e..367069ebf 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.h +++ b/src/core/arm/dynarmic/arm_dynarmic.h @@ -27,7 +27,7 @@ public: u32 GetCP15Register(CP15Register reg) override; void SetCP15Register(CP15Register reg, u32 value) override; - void AddTicks(u64 ticks) override; + void AddTicks(size_t ticks) override; void SaveContext(ThreadContext& ctx) override; void LoadContext(const ThreadContext& ctx) override; diff --git a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp index f4fbb8d04..e9d468fc8 100644 --- a/src/core/arm/dyncom/arm_dyncom_interpreter.cpp +++ b/src/core/arm/dyncom/arm_dyncom_interpreter.cpp @@ -759,7 +759,7 @@ static ThumbDecodeStatus DecodeThumbInstruction(u32 inst, u32 addr, u32* arm_ins ThumbDecodeStatus ret = TranslateThumbInstruction(addr, inst, arm_inst, inst_size); if (ret == ThumbDecodeStatus::BRANCH) { int inst_index; - int table_length = arm_instruction_trans_len; + int table_length = static_cast(arm_instruction_trans_len); u32 tinstr = GetThumbInstruction(inst, addr); switch ((tinstr & 0xF800) >> 11) { @@ -848,7 +848,7 @@ static int InterpreterTranslateBlock(ARMul_State* cpu, int& bb_start, u32 addr) ARM_INST_PTR inst_base = nullptr; TransExtData ret = TransExtData::NON_BRANCH; int size = 0; // instruction size of basic block - bb_start = trans_cache_buf_top; + bb_start = static_cast(trans_cache_buf_top); u32 phys_addr = addr; u32 pc_start = cpu->Reg[15]; @@ -875,7 +875,7 @@ static int InterpreterTranslateSingle(ARMul_State* cpu, int& bb_start, u32 addr) MICROPROFILE_SCOPE(DynCom_Decode); ARM_INST_PTR inst_base = nullptr; - bb_start = trans_cache_buf_top; + bb_start = static_cast(trans_cache_buf_top); u32 phys_addr = addr; u32 pc_start = cpu->Reg[15]; diff --git a/src/core/arm/dyncom/arm_dyncom_trans.h b/src/core/arm/dyncom/arm_dyncom_trans.h index 632ff2cd6..597e293ca 100644 --- a/src/core/arm/dyncom/arm_dyncom_trans.h +++ b/src/core/arm/dyncom/arm_dyncom_trans.h @@ -18,12 +18,19 @@ enum class TransExtData { SINGLE_STEP = (1 << 8) }; +#ifdef _WIN32 +#pragma warning( push ) +#pragma warning( disable : 4200) +#endif // WIN struct arm_inst { unsigned int idx; unsigned int cond; TransExtData br; char component[0]; }; +#ifdef _WIN32 +#pragma warning( pop ) +#endif // WIN struct generic_arm_inst { u32 Ra; diff --git a/src/core/file_sys/archive_backend.cpp b/src/core/file_sys/archive_backend.cpp index 1fae0ede0..5212da984 100644 --- a/src/core/file_sys/archive_backend.cpp +++ b/src/core/file_sys/archive_backend.cpp @@ -89,6 +89,9 @@ std::u16string Path::AsU16Str() const { // TODO(yuriks): Add assert LOG_ERROR(Service_FS, "LowPathType cannot be converted to u16string!"); return {}; + default: + LOG_ERROR(Service_FS, "Bad conversion type for LowPathType!"); + return {}; } } diff --git a/src/core/frontend/emu_window.cpp b/src/core/frontend/emu_window.cpp index 4f7d54a33..993cc0d9d 100644 --- a/src/core/frontend/emu_window.cpp +++ b/src/core/frontend/emu_window.cpp @@ -77,8 +77,8 @@ void EmuWindow::AccelerometerChanged(float x, float y, float z) { void EmuWindow::GyroscopeChanged(float x, float y, float z) { constexpr float FULL_FPS = 60; - float coef = GetGyroscopeRawToDpsCoefficient(); - float stretch = Core::System::GetInstance().perf_stats.GetLastFrameTimeScale(); + f32 coef = GetGyroscopeRawToDpsCoefficient(); + double stretch = Core::System::GetInstance().perf_stats.GetLastFrameTimeScale(); std::lock_guard lock(gyro_mutex); gyro_x = static_cast(x * coef * stretch); gyro_y = static_cast(y * coef * stretch); diff --git a/src/core/hle/ipc.h b/src/core/hle/ipc.h index 303ca090d..191c6a847 100644 --- a/src/core/hle/ipc.h +++ b/src/core/hle/ipc.h @@ -83,8 +83,8 @@ union Header { * @note While @p normal_params_size is equivalent to the number of normal parameters, * @p translate_params_size includes the size occupied by the translate parameters headers. */ -inline u32 MakeHeader(u16 command_id, unsigned int normal_params_size, - unsigned int translate_params_size) { +inline u32 MakeHeader(u16 command_id, u32 normal_params_size, + u32 translate_params_size) { Header header{}; header.command_id.Assign(command_id); header.normal_params_size.Assign(normal_params_size); diff --git a/src/core/hle/kernel/mutex.h b/src/core/hle/kernel/mutex.h index bacacd690..9318d95a4 100644 --- a/src/core/hle/kernel/mutex.h +++ b/src/core/hle/kernel/mutex.h @@ -36,7 +36,7 @@ public: } int lock_count; ///< Number of times the mutex has been acquired - u32 priority; ///< The priority of the mutex, used for priority inheritance. + s32 priority; ///< The priority of the mutex, used for priority inheritance. std::string name; ///< Name of mutex (optional) SharedPtr holding_thread; ///< Thread that has acquired the mutex diff --git a/src/core/hle/kernel/thread.cpp b/src/core/hle/kernel/thread.cpp index 75ce626f8..66f30bd88 100644 --- a/src/core/hle/kernel/thread.cpp +++ b/src/core/hle/kernel/thread.cpp @@ -412,7 +412,7 @@ ResultVal> Thread::Create(std::string name, VAddr entry_point, return ERR_OUT_OF_MEMORY; } - u32 offset = linheap_memory->size(); + size_t offset = linheap_memory->size(); // Allocate some memory from the end of the linear heap for this region. linheap_memory->insert(linheap_memory->end(), Memory::PAGE_SIZE, 0); @@ -522,7 +522,7 @@ void Thread::SetWaitSynchronizationOutput(s32 output) { context.cpu_registers[1] = output; } -s32 Thread::GetWaitObjectIndex(WaitObject* object) const { +s64 Thread::GetWaitObjectIndex(WaitObject* object) const { ASSERT_MSG(!wait_objects.empty(), "Thread is not waiting for anything"); auto match = std::find(wait_objects.rbegin(), wait_objects.rend(), object); return std::distance(match, wait_objects.rend()) - 1; diff --git a/src/core/hle/kernel/thread.h b/src/core/hle/kernel/thread.h index 6a3566f15..5da803fbd 100644 --- a/src/core/hle/kernel/thread.h +++ b/src/core/hle/kernel/thread.h @@ -142,7 +142,7 @@ public: * object in the list. * @param object Object to query the index of. */ - s32 GetWaitObjectIndex(WaitObject* object) const; + s64 GetWaitObjectIndex(WaitObject* object) const; /** * Stops a thread, invalidating it from further use diff --git a/src/core/hle/svc.cpp b/src/core/hle/svc.cpp index e68b9f16a..56a064245 100644 --- a/src/core/hle/svc.cpp +++ b/src/core/hle/svc.cpp @@ -514,7 +514,8 @@ static ResultCode CreateThread(Kernel::Handle* out_handle, u32 priority, u32 ent using Kernel::ResourceLimit; Kernel::SharedPtr& resource_limit = Kernel::g_current_process->resource_limit; - if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > priority) { + if (resource_limit->GetMaxResourceValue(Kernel::ResourceTypes::PRIORITY) > + static_cast(priority)) { return Kernel::ERR_NOT_AUTHORIZED; } diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index bdd997b2a..9ea2e69b5 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -76,6 +76,7 @@ struct Regs { return 2; default: UNIMPLEMENTED(); + return 0; } } diff --git a/src/video_core/regs_framebuffer.h b/src/video_core/regs_framebuffer.h index a50bd4111..a43b2b046 100644 --- a/src/video_core/regs_framebuffer.h +++ b/src/video_core/regs_framebuffer.h @@ -259,6 +259,7 @@ struct FramebufferRegs { default: LOG_CRITICAL(HW_GPU, "Unknown depth format %u", format); UNIMPLEMENTED(); + return -1; } } @@ -273,6 +274,7 @@ struct FramebufferRegs { default: LOG_CRITICAL(HW_GPU, "Unknown depth format %u", format); UNIMPLEMENTED(); + return -1; } } diff --git a/src/video_core/swrasterizer/framebuffer.cpp b/src/video_core/swrasterizer/framebuffer.cpp index 7de3aac75..dd2caf630 100644 --- a/src/video_core/swrasterizer/framebuffer.cpp +++ b/src/video_core/swrasterizer/framebuffer.cpp @@ -351,6 +351,9 @@ u8 LogicOp(u8 src, u8 dest, FramebufferRegs::LogicOp op) { case FramebufferRegs::LogicOp::OrInverted: return ~src | dest; + default: + UNIMPLEMENTED(); + return 0; } }; diff --git a/src/video_core/swrasterizer/texturing.cpp b/src/video_core/swrasterizer/texturing.cpp index aeb6aeb8c..19a4cca81 100644 --- a/src/video_core/swrasterizer/texturing.cpp +++ b/src/video_core/swrasterizer/texturing.cpp @@ -77,6 +77,9 @@ Math::Vec3 GetColorModifier(TevStageConfig::ColorModifier factor, case ColorModifier::OneMinusSourceBlue: return (Math::Vec3(255, 255, 255) - values.bbb()).Cast(); + default: + UNIMPLEMENTED(); + return Math::Vec3(); } }; @@ -107,7 +110,11 @@ u8 GetAlphaModifier(TevStageConfig::AlphaModifier factor, const Math::Vec4& case AlphaModifier::OneMinusSourceBlue: return 255 - values.b(); + default: + UNIMPLEMENTED(); + return -1; } + }; Math::Vec3 ColorCombine(TevStageConfig::Operation op, const Math::Vec3 input[3]) {