From 195c265a362bc792747ac199b94e6d4c28b957c9 Mon Sep 17 00:00:00 2001 From: sosssego Date: Thu, 17 Nov 2022 16:24:56 +0000 Subject: [PATCH] [CPP][Analyzers]Turn on warning 4244 (#22019) * Turn on warning 4244 fix one occurrence of 4100 * changes from comments * toupper on wchar --- Cpp.Build.props | 2 +- src/common/SettingsAPI/settings_objects.h | 4 +++- src/common/interop/HotkeyManager.cpp | 2 +- src/common/utils/package.h | 2 +- src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp | 2 +- .../ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp | 2 +- src/modules/fancyzones/FancyZonesLib/trace.cpp | 3 +-- src/modules/imageresizer/dll/ContextMenuHandler.cpp | 2 +- src/modules/powerrename/dll/PowerRenameExt.cpp | 2 +- 9 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Cpp.Build.props b/Cpp.Build.props index 66ddb453ff..9041973352 100644 --- a/Cpp.Build.props +++ b/Cpp.Build.props @@ -42,7 +42,7 @@ pch.h Level4 - 26800;28251;4244;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings) + 26800;28251;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings) true TurnOffAllWarnings false diff --git a/src/common/SettingsAPI/settings_objects.h b/src/common/SettingsAPI/settings_objects.h index d48093080c..cee95d7a56 100644 --- a/src/common/SettingsAPI/settings_objects.h +++ b/src/common/SettingsAPI/settings_objects.h @@ -2,6 +2,8 @@ #include "../utils/json.h" +#include + namespace PowerToysSettings { class HotkeyObject; @@ -230,7 +232,7 @@ namespace PowerToysSettings if (output_bytes == 1 && output[0] >= 'a' && output[0] <= 'z') { // Make Latin letters keys capital, as it looks better - output[0] = toupper(output[0]); + output[0] = std::towupper(output[0]); } return output.data(); } diff --git a/src/common/interop/HotkeyManager.cpp b/src/common/interop/HotkeyManager.cpp index 12f0d2ecfe..f38ad4d1ef 100644 --- a/src/common/interop/HotkeyManager.cpp +++ b/src/common/interop/HotkeyManager.cpp @@ -56,7 +56,7 @@ bool HotkeyManager::FilterKeyboardProc(KeyboardEvent ^ ev) pressedKeys->Ctrl = GetAsyncKeyState(VK_CONTROL) & 0x8000; pressedKeys->Alt = GetAsyncKeyState(VK_MENU) & 0x8000; pressedKeys->Shift = GetAsyncKeyState(VK_SHIFT) & 0x8000; - pressedKeys->Key = ev->key; + pressedKeys->Key = static_cast(ev->key); // Convert to hotkey handle auto pressedKeysHandle = GetHotkeyHandle(pressedKeys); diff --git a/src/common/utils/package.h b/src/common/utils/package.h index 9e14255fef..4e39cb4169 100644 --- a/src/common/utils/package.h +++ b/src/common/utils/package.h @@ -16,7 +16,7 @@ namespace package { { OSVERSIONINFOEX osvi{}; DWORDLONG dwlConditionMask = 0; - int op = VER_GREATER_EQUAL; + byte op = VER_GREATER_EQUAL; // Initialize the OSVERSIONINFOEX structure. osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); diff --git a/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp b/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp index c0a3373db6..e3d2a578b5 100644 --- a/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp +++ b/src/modules/ShortcutGuide/ShortcutGuide/overlay_window.cpp @@ -619,7 +619,7 @@ void D2DOverlayWindow::render(ID2D1DeviceContext5* d2d_dc) d2d_dc->Clear(); int x_offset = 0, y_offset = 0; auto current_anim_value = (float)animation.value(Animation::AnimFunctions::LINEAR); - SetLayeredWindowAttributes(hwnd, 0, (int)(255 * current_anim_value), LWA_ALPHA); + SetLayeredWindowAttributes(hwnd, 0, static_cast(255 * current_anim_value), LWA_ALPHA); double pos_anim_value = 1 - animation.value(Animation::AnimFunctions::EASE_OUT_EXPO); if (!tasklist_buttons.empty()) { diff --git a/src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp b/src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp index e38478eaaa..01697d633a 100644 --- a/src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp +++ b/src/modules/ShortcutGuide/ShortcutGuideModuleInterface/dllmain.cpp @@ -311,7 +311,7 @@ private: m_hotkey.modifiersMask |= MOD_ALT; } - m_hotkey.vkCode = hotkey.get_code(); + m_hotkey.vkCode = static_cast(hotkey.get_code()); } catch (...) { diff --git a/src/modules/fancyzones/FancyZonesLib/trace.cpp b/src/modules/fancyzones/FancyZonesLib/trace.cpp index 5362780f49..00cbfbd064 100644 --- a/src/modules/fancyzones/FancyZonesLib/trace.cpp +++ b/src/modules/fancyzones/FancyZonesLib/trace.cpp @@ -212,7 +212,6 @@ void Trace::FancyZones::DataChanged() noexcept activeZoneSetInfo += L", custom zone data was deleted"; } } - TraceLoggingWrite( g_hProvider, EventZoneSettingsChangedKey, @@ -220,7 +219,7 @@ void Trace::FancyZones::DataChanged() noexcept TraceLoggingKeyword(PROJECT_KEYWORD_MEASURE), TraceLoggingInt32(appsHistorySize, AppsInHistoryCountKey), TraceLoggingInt32(static_cast(customZones.size()), CustomZoneSetCountKey), - TraceLoggingInt32Array(customZonesArray.get(), static_cast(customZones.size()), NumberOfZonesForEachCustomZoneSetKey), + TraceLoggingInt32Array(customZonesArray.get(), static_cast(customZones.size()), NumberOfZonesForEachCustomZoneSetKey), TraceLoggingInt32(static_cast(layouts.size()), ActiveZoneSetsCountKey), TraceLoggingWideString(activeZoneSetInfo.c_str(), ActiveZoneSetsListKey), TraceLoggingInt32(static_cast(quickKeysCount), LayoutUsingQuickKeyCountKey)); diff --git a/src/modules/imageresizer/dll/ContextMenuHandler.cpp b/src/modules/imageresizer/dll/ContextMenuHandler.cpp index 122f2a4e8e..771479f691 100644 --- a/src/modules/imageresizer/dll/ContextMenuHandler.cpp +++ b/src/modules/imageresizer/dll/ContextMenuHandler.cpp @@ -262,7 +262,7 @@ HRESULT CContextMenuHandler::ResizePictures(CMINVOKECOMMANDINFO* pici, IShellIte startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; if (pici) { - startupInfo.wShowWindow = pici->nShow; + startupInfo.wShowWindow = static_cast(pici->nShow); } else { diff --git a/src/modules/powerrename/dll/PowerRenameExt.cpp b/src/modules/powerrename/dll/PowerRenameExt.cpp index bec6df5248..cd0346b246 100644 --- a/src/modules/powerrename/dll/PowerRenameExt.cpp +++ b/src/modules/powerrename/dll/PowerRenameExt.cpp @@ -165,7 +165,7 @@ HRESULT CPowerRenameMenu::RunPowerRename(CMINVOKECOMMANDINFO* pici, IShellItemAr startupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; if (pici) { - startupInfo.wShowWindow = pici->nShow; + startupInfo.wShowWindow = static_cast(pici->nShow); } else {