From a397bf811bfec54bd777befd708bfd773aa34fbc Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Thu, 6 Jan 2022 20:40:29 -0800 Subject: [PATCH] UI: Fix some sign/size comparison warnings. Mostly size_t vs int. --- UI/ControlMappingScreen.cpp | 4 ++-- UI/CwCheatScreen.cpp | 2 +- UI/GameSettingsScreen.cpp | 2 +- UI/MiscScreens.cpp | 4 ++-- Windows/Debugger/Debugger_MemoryDlg.cpp | 2 +- unittest/UnitTest.cpp | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/UI/ControlMappingScreen.cpp b/UI/ControlMappingScreen.cpp index 9058f52960..a4f664237d 100644 --- a/UI/ControlMappingScreen.cpp +++ b/UI/ControlMappingScreen.cpp @@ -175,7 +175,7 @@ void SingleControlMapper::MappedCallback(KeyDef kdf) { bool success = KeyMap::ReplaceSingleKeyMapping(pspKey_, actionIndex_, kdf); if (!success) { replaceAllButton_->SetFocus(); // Last got removed as a duplicate - } else if (actionIndex_ < rows_.size()) { + } else if (actionIndex_ < (int)rows_.size()) { rows_[actionIndex_]->SetFocus(); } else { SetFocus(); @@ -223,7 +223,7 @@ UI::EventReturn SingleControlMapper::OnDelete(UI::EventParams ¶ms) { KeyMap::g_controllerMap[pspKey_].erase(KeyMap::g_controllerMap[pspKey_].begin() + index); KeyMap::g_controllerMapGeneration++; - if (index + 1 < rows_.size()) + if (index + 1 < (int)rows_.size()) rows_[index]->SetFocus(); else SetFocus(); diff --git a/UI/CwCheatScreen.cpp b/UI/CwCheatScreen.cpp index 0e799deb0e..aaf5b8e13a 100644 --- a/UI/CwCheatScreen.cpp +++ b/UI/CwCheatScreen.cpp @@ -358,7 +358,7 @@ bool CwCheatScreen::RebuildCheatFile(int index) { return false; } - for (int i = 0; i < lines.size(); ++i) { + for (size_t i = 0; i < lines.size(); ++i) { fprintf(out, "%s", lines[i].c_str()); if (i != lines.size() - 1) fputc('\n', out); diff --git a/UI/GameSettingsScreen.cpp b/UI/GameSettingsScreen.cpp index 770e01b42b..242b239adb 100644 --- a/UI/GameSettingsScreen.cpp +++ b/UI/GameSettingsScreen.cpp @@ -349,7 +349,7 @@ void GameSettingsScreen::CreateViews() { graphicsSettings->Add(new ItemHeader(gr->T("Postprocessing effect"))); std::set alreadyAddedShader; - for (int i = 0; i < g_Config.vPostShaderNames.size() + 1 && i < ARRAY_SIZE(shaderNames_); ++i) { + for (int i = 0; i < (int)g_Config.vPostShaderNames.size() + 1 && i < ARRAY_SIZE(shaderNames_); ++i) { // Vector element pointer get invalidated on resize, cache name to have always a valid reference in the rendering thread shaderNames_[i] = i == g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[i]; postProcChoice_ = graphicsSettings->Add(new ChoiceWithValueDisplay(&shaderNames_[i], StringFromFormat("%s #%d", gr->T("Postprocessing Shader"), i + 1), &PostShaderTranslateName)); diff --git a/UI/MiscScreens.cpp b/UI/MiscScreens.cpp index 5f82735300..8171a49f9c 100644 --- a/UI/MiscScreens.cpp +++ b/UI/MiscScreens.cpp @@ -525,7 +525,7 @@ void PostProcScreen::CreateViews() { shaders_ = GetAllPostShaderInfo(); std::vector items; int selected = -1; - const std::string selectedName = id_ >= g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[id_]; + const std::string selectedName = id_ >= (int)g_Config.vPostShaderNames.size() ? "Off" : g_Config.vPostShaderNames[id_]; for (int i = 0; i < (int)shaders_.size(); i++) { if (!shaders_[i].visible) continue; @@ -541,7 +541,7 @@ void PostProcScreen::OnCompleted(DialogResult result) { if (result != DR_OK) return; const std::string &value = shaders_[listView_->GetSelected()].section; - if (id_ < g_Config.vPostShaderNames.size()) + if (id_ < (int)g_Config.vPostShaderNames.size()) g_Config.vPostShaderNames[id_] = value; else g_Config.vPostShaderNames.push_back(value); diff --git a/Windows/Debugger/Debugger_MemoryDlg.cpp b/Windows/Debugger/Debugger_MemoryDlg.cpp index 4c110e8cfb..f9ce203232 100644 --- a/Windows/Debugger/Debugger_MemoryDlg.cpp +++ b/Windows/Debugger/Debugger_MemoryDlg.cpp @@ -121,7 +121,7 @@ void CMemoryDlg::searchBoxRedraw(std::vector results) { wchar_t temp[256]{}; SendMessage(srcListHdl, WM_SETREDRAW, FALSE, 0); ListBox_ResetContent(srcListHdl); - for (int i = 0; i < results.size(); i++) { + for (size_t i = 0; i < results.size(); i++) { wsprintf(temp, L"0x%08X", results[i]); int index = (int)ListBox_AddString(srcListHdl, temp); ListBox_SetItemData(srcListHdl, index, results[i]); diff --git a/unittest/UnitTest.cpp b/unittest/UnitTest.cpp index 50611ba241..9ba74e3ba9 100644 --- a/unittest/UnitTest.cpp +++ b/unittest/UnitTest.cpp @@ -671,7 +671,7 @@ protected: float MeasureWidth(const char *str, size_t bytes) override { // Simple case for unit testing. int w = 0; - for (UTF8 utf(str); !utf.end() && utf.byteIndex() < bytes; ) { + for (UTF8 utf(str); !utf.end() && (size_t)utf.byteIndex() < bytes; ) { uint32_t c = utf.next(); switch (c) { case ' ':