From 2c30889fdc8265a348bc2de7d16b012b767e7093 Mon Sep 17 00:00:00 2001 From: GPUCode Date: Sun, 2 Oct 2022 23:47:41 +0300 Subject: [PATCH] code: Address more compiler warnings --- externals/microprofile/microprofile.h | 6 ++--- externals/microprofile/microprofileui.h | 12 +++++----- src/citra_qt/cheats.cpp | 5 +++-- .../configuration/configure_input.cpp | 22 +++++++++---------- .../configuration/configure_motion_touch.cpp | 2 +- src/core/arm/dynarmic/arm_dynarmic.cpp | 2 ++ src/core/cheats/cheats.cpp | 4 ++-- src/core/hle/kernel/svc.cpp | 2 +- src/core/hle/service/gsp/gsp_gpu.cpp | 4 +++- src/core/hw/gpu.h | 4 +++- src/video_core/regs_framebuffer.h | 4 +++- .../renderer_opengl/gl_rasterizer.cpp | 2 ++ .../renderer_opengl/gl_resource_manager.cpp | 2 +- .../renderer_opengl/renderer_opengl.cpp | 2 +- .../renderer_opengl/texture_downloader_es.cpp | 5 ++--- src/video_core/renderer_vulkan/pica_to_vk.h | 6 +++++ 16 files changed, 50 insertions(+), 34 deletions(-) diff --git a/externals/microprofile/microprofile.h b/externals/microprofile/microprofile.h index 7b54ccf86..2b8017c6a 100644 --- a/externals/microprofile/microprofile.h +++ b/externals/microprofile/microprofile.h @@ -847,7 +847,7 @@ inline MicroProfileLogEntry MicroProfileMakeLogIndex(uint64_t nBegin, MicroProfi MicroProfileLogEntry Entry = (nBegin<<62) | ((0x3fff&nToken)<<48) | (MP_LOG_TICK_MASK&nTick); int t = MicroProfileLogType(Entry); uint64_t nTimerIndex = MicroProfileLogTimerIndex(Entry); - MP_ASSERT(t == nBegin); + MP_ASSERT(static_cast(t) == nBegin); MP_ASSERT(nTimerIndex == (nToken&0x3fff)); return Entry; @@ -1579,10 +1579,10 @@ void MicroProfileFlip() pFramePut->nFrameStartCpu = MP_TICK(); pFramePut->nFrameStartGpu = (uint32_t)MicroProfileGpuInsertTimeStamp(); - if(pFrameNext->nFrameStartGpu != (uint64_t)-1) + if(static_cast(pFrameNext->nFrameStartGpu) != (uint64_t)-1) pFrameNext->nFrameStartGpu = MicroProfileGpuGetTimeStamp((uint32_t)pFrameNext->nFrameStartGpu); - if(pFrameCurrent->nFrameStartGpu == (uint64_t)-1) + if(static_cast(pFrameCurrent->nFrameStartGpu) == (uint64_t)-1) pFrameCurrent->nFrameStartGpu = pFrameNext->nFrameStartGpu + 1; uint64_t nFrameStartCpu = pFrameCurrent->nFrameStartCpu; diff --git a/externals/microprofile/microprofileui.h b/externals/microprofile/microprofileui.h index ce35f81c4..0553734b1 100644 --- a/externals/microprofile/microprofileui.h +++ b/externals/microprofile/microprofileui.h @@ -354,7 +354,7 @@ void MicroProfileInitUI() if(!bInitialized) { bInitialized = true; - memset(&g_MicroProfileUI, 0, sizeof(g_MicroProfileUI)); + g_MicroProfileUI = {}; UI.nActiveMenu = UINT32_MAX; UI.fDetailedOffsetTarget = UI.fDetailedOffset = 0.f; UI.fDetailedRangeTarget = UI.fDetailedRange = 50.f; @@ -845,8 +845,8 @@ void MicroProfileDrawDetailedBars(uint32_t nWidth, uint32_t nHeight, int nBaseY, MicroProfile& S = *MicroProfileGet(); MP_DEBUG_DUMP_RANGE(); int nY = nBaseY - UI.nOffsetY; - int64_t nNumBoxes = 0; - int64_t nNumLines = 0; + [[maybe_unused]] int64_t nNumBoxes = 0; + [[maybe_unused]] int64_t nNumLines = 0; uint32_t nFrameNext = (S.nFrameCurrent+1) % MICROPROFILE_MAX_FRAME_HISTORY; MicroProfileFrameState* pFrameCurrent = &S.Frames[S.nFrameCurrent]; @@ -1988,7 +1988,7 @@ const char* MicroProfileUIMenuGroups(int nIndex, bool* bSelected) else { nIndex = nIndex-1; - if(nIndex < UI.GroupMenuCount) + if(static_cast(nIndex) < UI.GroupMenuCount) { MicroProfileGroupMenuItem& Item = UI.GroupMenu[nIndex]; static char buffer[MICROPROFILE_NAME_MAX_LEN+32]; @@ -2135,7 +2135,7 @@ const char* MicroProfileUIMenuCustom(int nIndex, bool* bSelected) case 1: return "--"; default: nIndex -= 2; - if(nIndex < UI.nCustomCount) + if(static_cast(nIndex) < UI.nCustomCount) { return UI.Custom[nIndex].pName; } @@ -2185,7 +2185,7 @@ void MicroProfileUIClickGroups(int nIndex) else { nIndex -= 1; - if(nIndex < UI.GroupMenuCount) + if(static_cast(nIndex) < UI.GroupMenuCount) { MicroProfileGroupMenuItem& Item = UI.GroupMenu[nIndex]; if(Item.nIsCategory) diff --git a/src/citra_qt/cheats.cpp b/src/citra_qt/cheats.cpp index 4cab098b6..8646aa202 100644 --- a/src/citra_qt/cheats.cpp +++ b/src/citra_qt/cheats.cpp @@ -190,8 +190,9 @@ void CheatDialog::OnDeleteCheat() { if (newly_created) { newly_created = false; } else { - Core::System::GetInstance().CheatEngine().RemoveCheat(ui->tableCheats->currentRow()); - Core::System::GetInstance().CheatEngine().SaveCheatFile(); + auto& cheat_engine = Core::System::GetInstance().CheatEngine(); + cheat_engine.RemoveCheat(ui->tableCheats->currentRow()); + cheat_engine.SaveCheatFile(); } LoadCheats(); diff --git a/src/citra_qt/configuration/configure_input.cpp b/src/citra_qt/configuration/configure_input.cpp index 71561a3c1..94f23129e 100644 --- a/src/citra_qt/configuration/configure_input.cpp +++ b/src/citra_qt/configuration/configure_input.cpp @@ -192,10 +192,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) if (!button_map[button_id]) continue; button_map[button_id]->setContextMenuPolicy(Qt::CustomContextMenu); - connect(button_map[button_id], &QPushButton::clicked, [=]() { + connect(button_map[button_id], &QPushButton::clicked, [this, button_id]() { HandleClick( button_map[button_id], - [=](const Common::ParamPackage& params) { + [this, button_id](const Common::ParamPackage& params) { buttons_param[button_id] = params; // If the user closes the dialog, the changes are reverted in // `GMainWindow::OnConfigure()` @@ -205,7 +205,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) InputCommon::Polling::DeviceType::Button); }); connect(button_map[button_id], &QPushButton::customContextMenuRequested, this, - [=](const QPoint& menu_location) { + [this, button_id](const QPoint& menu_location) { QMenu context_menu; context_menu.addAction(tr("Clear"), this, [&] { buttons_param[button_id].Clear(); @@ -230,10 +230,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) continue; analog_map_buttons[analog_id][sub_button_id]->setContextMenuPolicy( Qt::CustomContextMenu); - connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::clicked, this, [=]() { + connect(analog_map_buttons[analog_id][sub_button_id], &QPushButton::clicked, this, [this, analog_id, sub_button_id]() { HandleClick( analog_map_buttons[analog_id][sub_button_id], - [=](const Common::ParamPackage& params) { + [this, analog_id, sub_button_id](const Common::ParamPackage& params) { SetAnalogButton(params, analogs_param[analog_id], analog_sub_buttons[sub_button_id]); ApplyConfiguration(); @@ -242,7 +242,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) InputCommon::Polling::DeviceType::Button); }); connect(analog_map_buttons[analog_id][sub_button_id], - &QPushButton::customContextMenuRequested, this, [=](const QPoint& menu_location) { + &QPushButton::customContextMenuRequested, this, [this, analog_id, sub_button_id](const QPoint& menu_location) { QMenu context_menu; context_menu.addAction(tr("Clear"), this, [&] { analogs_param[analog_id].Erase(analog_sub_buttons[sub_button_id]); @@ -264,7 +264,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) menu_location)); }); } - connect(analog_map_stick[analog_id], &QPushButton::clicked, this, [=]() { + connect(analog_map_stick[analog_id], &QPushButton::clicked, this, [this, analog_id]() { if (QMessageBox::information( this, tr("Information"), tr("After pressing OK, first move your joystick horizontally, " @@ -272,7 +272,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) QMessageBox::Ok | QMessageBox::Cancel) == QMessageBox::Ok) { HandleClick( analog_map_stick[analog_id], - [=](const Common::ParamPackage& params) { + [this, analog_id](const Common::ParamPackage& params) { analogs_param[analog_id] = params; ApplyConfiguration(); Settings::SaveProfile(ui->profile->currentIndex()); @@ -280,7 +280,7 @@ ConfigureInput::ConfigureInput(QWidget* parent) InputCommon::Polling::DeviceType::Analog); } }); - connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, this, [=] { + connect(analog_map_deadzone_and_modifier_slider[analog_id], &QSlider::valueChanged, this, [this, analog_id] { const int slider_value = analog_map_deadzone_and_modifier_slider[analog_id]->value(); const auto engine = analogs_param[analog_id].Get("engine", ""); if (engine == "sdl" || engine == "gcpad") { @@ -299,10 +299,10 @@ ConfigureInput::ConfigureInput(QWidget* parent) // The Circle Mod button is common for both the sticks, so update the modifier settings // for both the sticks. - connect(ui->buttonCircleMod, &QPushButton::clicked, this, [=]() { + connect(ui->buttonCircleMod, &QPushButton::clicked, this, [this]() { HandleClick( ui->buttonCircleMod, - [=](const Common::ParamPackage& params) { + [this](const Common::ParamPackage& params) { for (int analog_id = 0; analog_id < Settings::NativeAnalog::NumAnalogs; analog_id++) { SetAnalogButton(params, analogs_param[analog_id], "modifier"); diff --git a/src/citra_qt/configuration/configure_motion_touch.cpp b/src/citra_qt/configuration/configure_motion_touch.cpp index d51d2ad4e..e2716d8f1 100644 --- a/src/citra_qt/configuration/configure_motion_touch.cpp +++ b/src/citra_qt/configuration/configure_motion_touch.cpp @@ -205,7 +205,7 @@ void ConfigureMotionTouch::ConnectEvents() { connect(ui->touch_provider, static_cast(&QComboBox::currentIndexChanged), this, [this]([[maybe_unused]] int index) { UpdateUiDisplay(); }); - connect(ui->motion_controller_button, &QPushButton::clicked, this, [=]() { + connect(ui->motion_controller_button, &QPushButton::clicked, this, [this]() { if (QMessageBox::information(this, tr("Information"), tr("After pressing OK, press a button on the controller whose " "motion you want to track."), diff --git a/src/core/arm/dynarmic/arm_dynarmic.cpp b/src/core/arm/dynarmic/arm_dynarmic.cpp index 3bfd27b02..a1026701e 100644 --- a/src/core/arm/dynarmic/arm_dynarmic.cpp +++ b/src/core/arm/dynarmic/arm_dynarmic.cpp @@ -240,6 +240,8 @@ u32 ARM_Dynarmic::GetCP15Register(CP15Register reg) const { default: UNREACHABLE_MSG("Unknown CP15 register: {}", reg); } + + return 0; } void ARM_Dynarmic::SetCP15Register(CP15Register reg, u32 value) { diff --git a/src/core/cheats/cheats.cpp b/src/core/cheats/cheats.cpp index 37700bb2c..440047ffe 100644 --- a/src/core/cheats/cheats.cpp +++ b/src/core/cheats/cheats.cpp @@ -47,7 +47,7 @@ void CheatEngine::AddCheat(const std::shared_ptr& cheat) { void CheatEngine::RemoveCheat(int index) { std::unique_lock lock(cheats_list_mutex); - if (index < 0 || index >= cheats_list.size()) { + if (index < 0 || index >= static_cast(cheats_list.size())) { LOG_ERROR(Core_Cheats, "Invalid index {}", index); return; } @@ -56,7 +56,7 @@ void CheatEngine::RemoveCheat(int index) { void CheatEngine::UpdateCheat(int index, const std::shared_ptr& new_cheat) { std::unique_lock lock(cheats_list_mutex); - if (index < 0 || index >= cheats_list.size()) { + if (index < 0 || index >= static_cast(cheats_list.size())) { LOG_ERROR(Core_Cheats, "Invalid index {}", index); return; } diff --git a/src/core/hle/kernel/svc.cpp b/src/core/hle/kernel/svc.cpp index 8f93be85e..ed86f2e49 100644 --- a/src/core/hle/kernel/svc.cpp +++ b/src/core/hle/kernel/svc.cpp @@ -1391,7 +1391,7 @@ ResultCode SVC::AcceptSession(Handle* out_server_session, Handle server_port_han return RESULT_SUCCESS; } -static void CopyStringPart(char* out, const char* in, int offset, int max_length) { +static void CopyStringPart(char* out, const char* in, size_t offset, size_t max_length) { size_t str_size = strlen(in); if (offset < str_size) { strncpy(out, in + offset, max_length - 1); diff --git a/src/core/hle/service/gsp/gsp_gpu.cpp b/src/core/hle/service/gsp/gsp_gpu.cpp index b705ee48d..56af45078 100644 --- a/src/core/hle/service/gsp/gsp_gpu.cpp +++ b/src/core/hle/service/gsp/gsp_gpu.cpp @@ -83,7 +83,9 @@ u32 GSP_GPU::GetUnusedThreadId() const { if (!used_thread_ids[id]) return id; } - ASSERT_MSG(false, "All GSP threads are in use"); + + UNREACHABLE_MSG("All GSP threads are in use"); + return 0; } /// Gets a pointer to a thread command buffer in GSP shared memory diff --git a/src/core/hw/gpu.h b/src/core/hw/gpu.h index 79976fcdb..b865dcd6e 100644 --- a/src/core/hw/gpu.h +++ b/src/core/hw/gpu.h @@ -68,9 +68,11 @@ struct Regs { case PixelFormat::RGB5A1: case PixelFormat::RGBA4: return 2; + default: + UNREACHABLE(); } - UNREACHABLE(); + return 0; } INSERT_PADDING_WORDS(0x4); diff --git a/src/video_core/regs_framebuffer.h b/src/video_core/regs_framebuffer.h index 483c462fc..21fcd64ec 100644 --- a/src/video_core/regs_framebuffer.h +++ b/src/video_core/regs_framebuffer.h @@ -275,9 +275,11 @@ struct FramebufferRegs { case DepthFormat::D24: case DepthFormat::D24S8: return 24; + default: + UNREACHABLE_MSG("Unknown depth format {}", format); } - ASSERT_MSG(false, "Unknown depth format {}", format); + return 0; } INSERT_PADDING_WORDS(0x10); // Gas related registers diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index d105eb292..e1e8afc25 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -430,6 +430,8 @@ static GLenum GetCurrentPrimitiveMode() { default: UNREACHABLE(); } + + return GL_TRIANGLES; } bool RasterizerOpenGL::AccelerateDrawBatchInternal(bool is_indexed) { diff --git a/src/video_core/renderer_opengl/gl_resource_manager.cpp b/src/video_core/renderer_opengl/gl_resource_manager.cpp index ae8cab7e1..881343596 100644 --- a/src/video_core/renderer_opengl/gl_resource_manager.cpp +++ b/src/video_core/renderer_opengl/gl_resource_manager.cpp @@ -89,7 +89,7 @@ void OGLTexture::CopyFrom(const OGLTexture& other, GLenum target, GLsizei levels glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, handle); - for (u32 level = 0; level < levels; level++) { + for (GLsizei level = 0; level < levels; level++) { glCopyImageSubData(other.handle, target, level, 0, 0, 0, handle, target, level, 0, 0, 0, width >> level, height >> level, 1); } diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 071599096..36533c003 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -766,7 +766,7 @@ void RendererOpenGL::ReloadShader() { void RendererOpenGL::ConfigureFramebufferTexture(TextureInfo& texture, const GPU::Regs::FramebufferConfig& framebuffer) { GPU::Regs::PixelFormat format = framebuffer.color_format; - GLint internal_format; + GLint internal_format{}; texture.format = format; texture.width = framebuffer.width; diff --git a/src/video_core/renderer_opengl/texture_downloader_es.cpp b/src/video_core/renderer_opengl/texture_downloader_es.cpp index 1b36d94cd..e8704e8de 100644 --- a/src/video_core/renderer_opengl/texture_downloader_es.cpp +++ b/src/video_core/renderer_opengl/texture_downloader_es.cpp @@ -6,7 +6,6 @@ #include #include #include "common/logging/log.h" -#include "video_core/rasterizer_cache/utils.h" #include "video_core/renderer_opengl/gl_state.h" #include "video_core/renderer_opengl/gl_texture_runtime.h" #include "video_core/renderer_opengl/texture_downloader_es.h" @@ -73,7 +72,7 @@ void TextureDownloaderES::Test() { auto time = std::chrono::high_resolution_clock::now() - start; LOG_INFO(Render_OpenGL, "test took {}", std::chrono::duration(time)); - int diff = 0; + T diff = 0; for (std::size_t idx = 0; idx < original_data.size(); ++idx) if (new_data[idx] - original_data[idx] != diff) { diff = new_data[idx] - original_data[idx]; @@ -207,7 +206,7 @@ GLuint TextureDownloaderES::ConvertDepthToColor(GLuint level, GLenum& format, GL void TextureDownloaderES::GetTexImage(GLenum target, GLuint level, GLenum format, GLenum type, GLint height, GLint width, void* pixels) const { OpenGLState state = OpenGLState::GetCurState(); - GLuint texture; + GLuint texture{}; const GLuint old_read_buffer = state.draw.read_framebuffer; switch (target) { case GL_TEXTURE_2D: diff --git a/src/video_core/renderer_vulkan/pica_to_vk.h b/src/video_core/renderer_vulkan/pica_to_vk.h index 6cbf3ecfa..33f04225d 100644 --- a/src/video_core/renderer_vulkan/pica_to_vk.h +++ b/src/video_core/renderer_vulkan/pica_to_vk.h @@ -251,6 +251,9 @@ inline vk::CullModeFlags CullMode(Pica::RasterizerRegs::CullMode mode) { case Pica::RasterizerRegs::CullMode::KeepClockWise: case Pica::RasterizerRegs::CullMode::KeepCounterClockWise: return vk::CullModeFlagBits::eBack; + default: + LOG_CRITICAL(Render_Vulkan, "Unknown cull mode {}", mode); + return vk::CullModeFlagBits::eNone; } } @@ -262,6 +265,9 @@ inline vk::FrontFace FrontFace(Pica::RasterizerRegs::CullMode mode) { return vk::FrontFace::eCounterClockwise; case Pica::RasterizerRegs::CullMode::KeepCounterClockWise: return vk::FrontFace::eClockwise; + default: + LOG_CRITICAL(Render_Vulkan, "Unknown cull mode {}", mode); + return vk::FrontFace::eClockwise; } }