From a577608835ec4ebba8354818f99ff28e87b761a1 Mon Sep 17 00:00:00 2001 From: Birunthan Mohanathas Date: Mon, 23 Dec 2013 19:42:31 +0000 Subject: [PATCH] Unignore and fix warnings in Library/ --- Build/VS/Rainmeter.Cpp.props | 6 +++++- Library/DialogAbout.cpp | 2 +- Library/DialogManage.cpp | 2 +- Library/Export.cpp | 2 +- Library/IfActions.cpp | 2 +- Library/Library.vcxproj | 1 - Library/Measure.cpp | 10 +++++----- Library/MeasureCalc.cpp | 2 +- Library/MeasureNet.cpp | 2 +- Library/Meter.cpp | 2 +- Library/MeterString.cpp | 4 ++-- Library/MeterWindow.cpp | 11 ++++++----- Library/Rainmeter.cpp | 9 +++++---- Library/TrayWindow.cpp | 2 +- Library/lua/glue/LuaMeasure.cpp | 2 +- Library/lua/glue/LuaMeter.cpp | 4 ++-- 16 files changed, 34 insertions(+), 29 deletions(-) diff --git a/Build/VS/Rainmeter.Cpp.props b/Build/VS/Rainmeter.Cpp.props index 077b2827..df45b8c4 100644 --- a/Build/VS/Rainmeter.Cpp.props +++ b/Build/VS/Rainmeter.Cpp.props @@ -53,8 +53,12 @@ + + + 4351;4530 + - WIN32;_WINDOWS;WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_IE=0x0601;PSAPI_VERSION=1;%(PreprocessorDefinitions) + WIN32;_WINDOWS;WINVER=0x0601;_WIN32_WINNT=0x0601;_WIN32_IE=0x0601;PSAPI_VERSION=1;_CRT_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) Level3 diff --git a/Library/DialogAbout.cpp b/Library/DialogAbout.cpp index 7f810092..ddf8cabb 100644 --- a/Library/DialogAbout.cpp +++ b/Library/DialogAbout.cpp @@ -874,7 +874,7 @@ void DialogAbout::TabSkins::UpdateMeasureList(MeterWindow* meterWindow) } std::wstring tmpStr = (*iter).first; - wcslwr(&tmpStr[0]); + _wcslwr(&tmpStr[0]); lvi.pszText = (WCHAR*)tmpStr.c_str(); if (lvi.iItem < count) diff --git a/Library/DialogManage.cpp b/Library/DialogManage.cpp index 49825a9f..3e37a68d 100644 --- a/Library/DialogManage.cpp +++ b/Library/DialogManage.cpp @@ -1582,7 +1582,7 @@ void DialogManage::TabLayouts::Initialize() { HWND item = GetControl(Id_List); const std::vector& layouts = GetRainmeter().GetAllLayouts(); - for (int i = 0, isize = layouts.size(); i < isize; ++i) + for (size_t i = 0, isize = layouts.size(); i < isize; ++i) { ListBox_AddString(item, layouts[i].c_str()); } diff --git a/Library/Export.cpp b/Library/Export.cpp index 0738cba5..75fa7dea 100644 --- a/Library/Export.cpp +++ b/Library/Export.cpp @@ -34,7 +34,7 @@ LPCWSTR __stdcall RmReadString(void* rm, LPCWSTR option, LPCWSTR defValue, BOOL MeasurePlugin* measure = (MeasurePlugin*)rm; ConfigParser& parser = measure->GetMeterWindow()->GetParser(); - return parser.ReadString(measure->GetName(), option, defValue, (bool)replaceMeasures).c_str(); + return parser.ReadString(measure->GetName(), option, defValue, replaceMeasures != FALSE).c_str(); } double __stdcall RmReadFormula(void* rm, LPCWSTR option, double defValue) diff --git a/Library/IfActions.cpp b/Library/IfActions.cpp index 6de6d324..e3914d3f 100644 --- a/Library/IfActions.cpp +++ b/Library/IfActions.cpp @@ -64,7 +64,7 @@ void IfActions::ReadConditionOptions(ConfigParser& parser, const WCHAR* section) std::wstring fAction = parser.ReadString(section, L"IfFalseAction", L"", false); if (!tAction.empty() || !fAction.empty()) { - int i = 1; + size_t i = 1; do { if (m_Conditions.size() > (i - 1)) diff --git a/Library/Library.vcxproj b/Library/Library.vcxproj index 4b782cd5..d58af95c 100644 --- a/Library/Library.vcxproj +++ b/Library/Library.vcxproj @@ -19,7 +19,6 @@ lua/include;lua/lua;%(AdditionalIncludeDirectories) _USRDLL;HAVE_CONFIG_H;SUPPORT_UTF8;LIBRARY_EXPORTS;%(PreprocessorDefinitions) - 4018;4090;4114;4267;4334;4351;4786;4800;4996 comctl32.lib;Wininet.lib;UxTheme.lib;Winmm.lib;gdiplus.lib;Iphlpapi.lib;shlwapi.lib;d2d1.lib;dwrite.lib;windowscodecs.lib;Version.lib;%(AdditionalDependencies) diff --git a/Library/Measure.cpp b/Library/Measure.cpp index ae7b4086..8315f72d 100644 --- a/Library/Measure.cpp +++ b/Library/Measure.cpp @@ -276,11 +276,11 @@ const WCHAR* Measure::CheckSubstitute(const WCHAR* buffer) re, nullptr, // No extra data - we didn't study the pattern utf8str.c_str(), // The subject string - utf8str.length(), // The length of the subject + (int)utf8str.length(), // The length of the subject offset, 0, ovector, - _countof(ovector)); + (int)_countof(ovector)); if (rc <= 0) { break; @@ -311,10 +311,10 @@ const WCHAR* Measure::CheckSubstitute(const WCHAR* buffer) } } - const size_t start = ovector[0]; - const size_t length = ovector[1] - ovector[0]; + const int start = ovector[0]; + const int length = ovector[1] - ovector[0]; utf8str.replace(start, length, result); - offset = start + result.length(); + offset = start + (int)result.length(); } while (true); diff --git a/Library/MeasureCalc.cpp b/Library/MeasureCalc.cpp index f5c29fbb..b10c729f 100644 --- a/Library/MeasureCalc.cpp +++ b/Library/MeasureCalc.cpp @@ -229,7 +229,7 @@ void MeasureCalc::UpdateUniqueNumberList() const size_t range = (m_HighBound - m_LowBound) + 1; m_UniqueNumbers.resize(range); - for (size_t i = 0; i < range; ++i) + for (int i = 0; i < (int)range; ++i) { m_UniqueNumbers[i] = m_LowBound + i; } diff --git a/Library/MeasureNet.cpp b/Library/MeasureNet.cpp index fe8d7fa4..6f85b6ed 100644 --- a/Library/MeasureNet.cpp +++ b/Library/MeasureNet.cpp @@ -642,7 +642,7 @@ void MeasureNet::WriteStats(const WCHAR* iniFile, const std::wstring& statsDate) WCHAR buffer[48]; int len; - uint32_t count = c_StatValues.size() / 2; + uint32_t count = (uint32_t)c_StatValues.size() / 2; // Reserve sufficient buffer for statistics std::wstring data; diff --git a/Library/Meter.cpp b/Library/Meter.cpp index 777d79e5..b1d99acb 100644 --- a/Library/Meter.cpp +++ b/Library/Meter.cpp @@ -531,7 +531,7 @@ bool Meter::ReplaceMeasures(std::wstring& str, AUTOSCALE autoScale, double scale const WCHAR* measureValue = m_Measures[i - 1]->GetStringOrFormattedValue( autoScale, scale, decimals, percentual); - int measureValueLen = wcslen(measureValue); + const size_t measureValueLen = wcslen(measureValue); do { diff --git a/Library/MeterString.cpp b/Library/MeterString.cpp index 48160a30..f07848f5 100644 --- a/Library/MeterString.cpp +++ b/Library/MeterString.cpp @@ -153,8 +153,8 @@ void MeterString::Initialize() m_TextFormat->SetProperties( m_FontFace.c_str(), m_FontSize, - m_Style & BOLD, - m_Style & ITALIC, + (m_Style & BOLD) != 0, + (m_Style & ITALIC) != 0, m_MeterWindow->GetFontCollection()); } diff --git a/Library/MeterWindow.cpp b/Library/MeterWindow.cpp index ed2075ab..34529735 100644 --- a/Library/MeterWindow.cpp +++ b/Library/MeterWindow.cpp @@ -871,28 +871,28 @@ void MeterWindow::DoBang(Bang bang, const std::vector& args) case Bang::ClickThrough: { int f = m_Parser.ParseInt(args[0].c_str(), 0); - SetClickThrough((f == -1) ? !m_ClickThrough : f); + SetClickThrough((f == -1) ? !m_ClickThrough : f != 0); } break; case Bang::Draggable: { int f = m_Parser.ParseInt(args[0].c_str(), 0); - SetWindowDraggable((f == -1) ? !m_WindowDraggable : f); + SetWindowDraggable((f == -1) ? !m_WindowDraggable : f != 0); } break; case Bang::SnapEdges: { int f = m_Parser.ParseInt(args[0].c_str(), 0); - SetSnapEdges((f == -1) ? !m_SnapEdges : f); + SetSnapEdges((f == -1) ? !m_SnapEdges : f != 0); } break; case Bang::KeepOnScreen: { int f = m_Parser.ParseInt(args[0].c_str(), 0); - SetKeepOnScreen((f == -1) ? !m_KeepOnScreen : f); + SetKeepOnScreen((f == -1) ? !m_KeepOnScreen : f != 0); } break; @@ -1526,7 +1526,8 @@ void MeterWindow::SetOption(const std::wstring& section, const std::wstring& opt } // ContextTitle and ContextAction in [Rainmeter] are dynamic - if ((_wcsicmp(section.c_str(), L"Rainmeter") == 0) && (wcsnicmp(option.c_str(), L"Context", 7) == 0)) + if (_wcsicmp(section.c_str(), L"Rainmeter") == 0 && + _wcsnicmp(option.c_str(), L"Context", 7) == 0) { if (value.empty()) { diff --git a/Library/Rainmeter.cpp b/Library/Rainmeter.cpp index a176f2de..6f1b6809 100644 --- a/Library/Rainmeter.cpp +++ b/Library/Rainmeter.cpp @@ -471,7 +471,7 @@ bool Rainmeter::IsAlreadyRunning() MD5_CTX ctx = {0}; MD5Init(&ctx); - MD5Update(&ctx, (LPBYTE)&data[0], data.length() * sizeof(WCHAR)); + MD5Update(&ctx, (LPBYTE)&data[0], (UINT)data.length() * sizeof(WCHAR)); MD5Final(&ctx); FreeLibrary(cryptDll); @@ -584,7 +584,7 @@ LRESULT CALLBACK Rainmeter::MainWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPA void Rainmeter::SetNetworkStatisticsTimer() { - static bool set = SetTimer(m_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, nullptr); + static bool set = SetTimer(m_Window, TIMER_NETSTATS, INTERVAL_NETSTATS, nullptr) != 0; } void Rainmeter::CreateOptionsFile() @@ -1307,9 +1307,10 @@ void Rainmeter::ReadGeneralSettings(const std::wstring& iniFile) m_DesktopWorkAreaChanged = true; } - for (UINT i = 1, isize = System::GetMonitorCount(); i <= isize; ++i) + const size_t monitorCount = System::GetMonitorCount(); + for (UINT i = 1; i <= monitorCount; ++i) { - _snwprintf_s(buffer, _TRUNCATE, L"DesktopWorkArea@%i", i); + _snwprintf_s(buffer, _TRUNCATE, L"DesktopWorkArea@%i", (int)i); const std::wstring& area = parser.ReadString(L"Rainmeter", buffer, L""); if (!area.empty()) { diff --git a/Library/TrayWindow.cpp b/Library/TrayWindow.cpp index ba21d96a..7a4863ce 100644 --- a/Library/TrayWindow.cpp +++ b/Library/TrayWindow.cpp @@ -129,7 +129,7 @@ bool TrayWindow::IsTrayIconReady() tnid.hWnd = m_Window; tnid.uID = IDI_TRAY; - return Shell_NotifyIcon(NIM_MODIFY, &tnid); + return Shell_NotifyIcon(NIM_MODIFY, &tnid) != FALSE; } void TrayWindow::TryAddTrayIcon() diff --git a/Library/lua/glue/LuaMeasure.cpp b/Library/lua/glue/LuaMeasure.cpp index 50616bcd..c52af7b1 100644 --- a/Library/lua/glue/LuaMeasure.cpp +++ b/Library/lua/glue/LuaMeasure.cpp @@ -125,7 +125,7 @@ static int GetStringValue(lua_State* L) AUTOSCALE autoScale = (top > 1) ? (AUTOSCALE)(int)lua_tonumber(L, 2) : AUTOSCALE_OFF; double scale = (top > 2) ? lua_tonumber(L, 3) : 1.0; int decimals = (int)lua_tonumber(L, 4); - bool percentual = lua_toboolean(L, 5); + bool percentual = lua_toboolean(L, 5) != 0; const WCHAR* val = self->GetStringOrFormattedValue(autoScale, scale, decimals, percentual); LuaManager::PushWide(val); diff --git a/Library/lua/glue/LuaMeter.cpp b/Library/lua/glue/LuaMeter.cpp index 8aebb157..b2ade4f2 100644 --- a/Library/lua/glue/LuaMeter.cpp +++ b/Library/lua/glue/LuaMeter.cpp @@ -68,7 +68,7 @@ static int GetH(lua_State* L) static int GetX(lua_State* L) { DECLARE_SELF(L) - bool abs = (bool)lua_toboolean(L, 2); + const bool abs = lua_toboolean(L, 2) != 0; lua_pushnumber(L, self->GetX(abs)); return 1; @@ -77,7 +77,7 @@ static int GetX(lua_State* L) static int GetY(lua_State* L) { DECLARE_SELF(L) - bool abs = (bool)lua_toboolean(L, 2); + const bool abs = lua_toboolean(L, 2) != 0; lua_pushnumber(L, self->GetY(abs)); return 1;