From 06b009f3617d9705cc60ee43c76cf4eb030e8071 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 26 Jun 2021 15:05:21 +1000 Subject: [PATCH] Warning fixes --- dep/libchdr/include/libchdr/coretypes.h | 2 +- src/common/cd_image.cpp | 6 +++--- src/common/cd_image_chd.cpp | 2 +- src/common/cd_image_ecm.cpp | 4 ++-- src/common/cd_image_hasher.cpp | 2 +- src/common/d3d11/texture.cpp | 2 +- src/frontend-common/controller_interface.cpp | 3 ++- src/frontend-common/fullscreen_ui.cpp | 7 +------ src/frontend-common/game_list.cpp | 8 ++++---- .../sdl_controller_interface.cpp | 18 +++++++++--------- 10 files changed, 25 insertions(+), 29 deletions(-) diff --git a/dep/libchdr/include/libchdr/coretypes.h b/dep/libchdr/include/libchdr/coretypes.h index fbe2d7d63..f780ffd31 100644 --- a/dep/libchdr/include/libchdr/coretypes.h +++ b/dep/libchdr/include/libchdr/coretypes.h @@ -26,7 +26,7 @@ typedef int8_t INT8; #define core_fread(fc, buff, len) fread(buff, 1, len, fc) #define core_fclose fclose #define core_ftell ftell -static size_t core_fsize(core_file *f) +static inline size_t core_fsize(core_file *f) { long rv; long p = ftell(f); diff --git a/src/common/cd_image.cpp b/src/common/cd_image.cpp index 3dadf5166..6127156af 100644 --- a/src/common/cd_image.cpp +++ b/src/common/cd_image.cpp @@ -397,9 +397,9 @@ bool CDImage::GenerateSubChannelQ(SubChannelQ* subq, LBA lba) void CDImage::GenerateSubChannelQ(SubChannelQ* subq, const Index& index, u32 index_offset) { subq->control_bits = index.control.bits; - subq->track_number_bcd = - (index.track_number <= m_tracks.size() ? BinaryToBCD(index.track_number) : index.track_number); - subq->index_number_bcd = BinaryToBCD(index.index_number); + subq->track_number_bcd = (index.track_number <= m_tracks.size() ? BinaryToBCD(static_cast(index.track_number)) : + static_cast(index.track_number)); + subq->index_number_bcd = BinaryToBCD(static_cast(index.index_number)); Position relative_position; if (index.is_pregap) diff --git a/src/common/cd_image_chd.cpp b/src/common/cd_image_chd.cpp index eccb2744b..682c25a55 100644 --- a/src/common/cd_image_chd.cpp +++ b/src/common/cd_image_chd.cpp @@ -1,4 +1,4 @@ -#ifdef _MSC_VER +#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) #define _CRT_SECURE_NO_WARNINGS #endif diff --git a/src/common/cd_image_ecm.cpp b/src/common/cd_image_ecm.cpp index b2ef4b9d3..378f0fdf2 100644 --- a/src/common/cd_image_ecm.cpp +++ b/src/common/cd_image_ecm.cpp @@ -19,7 +19,7 @@ static constexpr std::array ComputeECCFLUT() for (u32 i = 0; i < 256; i++) { u32 j = (i << 1) ^ (i & 0x80 ? 0x11D : 0); - ecc_lut[i] = j; + ecc_lut[i] = static_cast(j); } return ecc_lut; } @@ -30,7 +30,7 @@ static constexpr std::array ComputeECCBLUT() for (u32 i = 0; i < 256; i++) { u32 j = (i << 1) ^ (i & 0x80 ? 0x11D : 0); - ecc_lut[i ^ j] = i; + ecc_lut[i ^ j] = static_cast(i); } return ecc_lut; } diff --git a/src/common/cd_image_hasher.cpp b/src/common/cd_image_hasher.cpp index dd93f028c..af652cf7a 100644 --- a/src/common/cd_image_hasher.cpp +++ b/src/common/cd_image_hasher.cpp @@ -90,7 +90,7 @@ bool GetImageHash(CDImage* image, Hash* out_hash, for (u32 i = 1; i <= image->GetTrackCount(); i++) { progress_callback->SetProgressValue(i - 1); - if (!ReadTrack(image, i, &digest, progress_callback)) + if (!ReadTrack(image, static_cast(i), &digest, progress_callback)) { progress_callback->PopState(); return false; diff --git a/src/common/d3d11/texture.cpp b/src/common/d3d11/texture.cpp index d74030842..d7ad70a9d 100644 --- a/src/common/d3d11/texture.cpp +++ b/src/common/d3d11/texture.cpp @@ -13,7 +13,7 @@ Texture::Texture(ComPtr texture, ComPtr(desc.SampleDesc.Count); } Texture::~Texture() diff --git a/src/frontend-common/controller_interface.cpp b/src/frontend-common/controller_interface.cpp index 90134011f..fedc0d4c7 100644 --- a/src/frontend-common/controller_interface.cpp +++ b/src/frontend-common/controller_interface.cpp @@ -142,12 +142,13 @@ ControllerInterface::Backend ControllerInterface::GetDefaultBackend() { #ifdef WITH_SDL2 return Backend::SDL; -#endif +#else #ifdef WIN32 return Backend::XInput; #else return Backend::None; #endif +#endif } #ifdef WITH_SDL2 diff --git a/src/frontend-common/fullscreen_ui.cpp b/src/frontend-common/fullscreen_ui.cpp index f07b9980c..bbd823d04 100644 --- a/src/frontend-common/fullscreen_ui.cpp +++ b/src/frontend-common/fullscreen_ui.cpp @@ -654,7 +654,7 @@ static void DoCheatsMenu() CheatList* cl = System::GetCheatList(); if (!cl) { - if (!s_host_interface->LoadCheatListFromDatabase() || !(cl = System::GetCheatList())) + if (!s_host_interface->LoadCheatListFromDatabase() || ((cl = System::GetCheatList()) == nullptr)) { s_host_interface->AddFormattedOSDMessage(10.0f, "No cheats found for %s.", System::GetRunningTitle().c_str()); ReturnToMainWindow(); @@ -2057,8 +2057,6 @@ void DrawSettingsWindow() #ifdef WIN32 case GPURenderer::HardwareD3D11: { - // TODO: FIXME - bool use_blit_swap_chain = false; settings_changed |= ToggleButtonForNonSetting( "Use Blit Swap Chain", "Uses a blit presentation model instead of flipping. This may be needed on some systems.", "Display", @@ -3064,8 +3062,6 @@ void DrawGameListWindow() if (BeginFullscreenColumnWindow(0.0f, 450.0f, "game_list_info", ImVec4(0.11f, 0.15f, 0.17f, 1.00f))) { - const ImGuiWindow* window = ImGui::GetCurrentWindow(); - ImGui::SetCursorPos(LayoutScale(ImVec2(50.0f, 50.0f))); ImGui::Image(selected_entry ? GetGameListCover(selected_entry)->GetHandle() : GetTextureForGameListEntryType(GameListEntryType::Count)->GetHandle(), @@ -4534,7 +4530,6 @@ void DrawLeaderboardsWindow() float left = bb.Min.x + padding + image_height + spacing; float right = bb.Max.x - padding; float top = bb.Min.y + padding; - ImDrawList* dl = ImGui::GetWindowDrawList(); SmallString text; ImVec2 text_size; diff --git a/src/frontend-common/game_list.cpp b/src/frontend-common/game_list.cpp index 267405f62..8e1e21ea4 100644 --- a/src/frontend-common/game_list.cpp +++ b/src/frontend-common/game_list.cpp @@ -174,10 +174,10 @@ bool GameList::GetGameListEntry(const std::string& path, GameListEntry* entry) entry->publisher = std::move(dbentry.publisher); entry->developer = std::move(dbentry.developer); entry->release_date = dbentry.release_date; - entry->min_players = dbentry.min_players; - entry->max_players = dbentry.max_players; - entry->min_blocks = dbentry.min_blocks; - entry->max_blocks = dbentry.max_blocks; + entry->min_players = static_cast(dbentry.min_players); + entry->max_players = static_cast(dbentry.max_players); + entry->min_blocks = static_cast(dbentry.min_blocks); + entry->max_blocks = static_cast(dbentry.max_blocks); entry->supported_controllers = dbentry.supported_controllers_mask; } diff --git a/src/frontend-common/sdl_controller_interface.cpp b/src/frontend-common/sdl_controller_interface.cpp index d646b746a..cec0983af 100644 --- a/src/frontend-common/sdl_controller_interface.cpp +++ b/src/frontend-common/sdl_controller_interface.cpp @@ -373,21 +373,21 @@ bool SDLControllerInterface::HandleJoystickAxisEvent(const SDL_JoyAxisEvent* eve if (value > 0.0f) { - const AxisCallback& cb = it->axis_mapping[event->axis][AxisSide::Positive]; - if (cb) + const AxisCallback& hcb = it->axis_mapping[event->axis][AxisSide::Positive]; + if (hcb) { // Expand 0..1 - -1..1 - cb(value * 2.0f - 1.0f); + hcb(value * 2.0f - 1.0f); processed = true; } } else if (value < 0.0f) { - const AxisCallback& cb = it->axis_mapping[event->axis][AxisSide::Negative]; - if (cb) + const AxisCallback& hcb = it->axis_mapping[event->axis][AxisSide::Negative]; + if (hcb) { // Expand 0..-1 - -1..1 - cb(value * -2.0f - 1.0f); + hcb(value * -2.0f - 1.0f); processed = true; } } @@ -756,7 +756,7 @@ void SDLControllerInterface::SetControllerRumbleStrength(int controller_index, c if (it->use_game_controller_rumble) { const u16 large = static_cast(strengths[0] * 65535.0f); - const u16 small = static_cast(strengths[1] * 65535.0f); + const u16 small = static_cast(strengths[1] * 65535.0f); SDL_GameControllerRumble(static_cast(it->game_controller), large, small, DURATION); return; } @@ -769,8 +769,8 @@ void SDLControllerInterface::SetControllerRumbleStrength(int controller_index, c { SDL_HapticEffect ef; ef.type = SDL_HAPTIC_LEFTRIGHT; - ef.leftright.large_magnitude = static_cast(strengths[0] * 65535.0f); - ef.leftright.small_magnitude = static_cast(strengths[1] * 65535.0f); + ef.leftright.large_magnitude = static_cast(strengths[0] * 65535.0f); + ef.leftright.small_magnitude = static_cast(strengths[1] * 65535.0f); ef.leftright.length = DURATION; SDL_HapticUpdateEffect(haptic, it->haptic_left_right_effect, &ef); SDL_HapticRunEffect(haptic, it->haptic_left_right_effect, SDL_HAPTIC_INFINITY);