mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 03:37:59 +01:00
[Analyzers][CPP] Turn on warning 4702 (#22285)
* Turn on 4702 unreachable code * fix warnings that didnt show locally * add comments about disable warnings * improve comments * changes from comments * fix from PR comments
This commit is contained in:
@@ -46,7 +46,7 @@
|
||||
<ClCompile>
|
||||
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
|
||||
<WarningLevel>Level4</WarningLevel>
|
||||
<DisableSpecificWarnings>4679;4702;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableSpecificWarnings>4679;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||
<DisableAnalyzeExternal >true</DisableAnalyzeExternal>
|
||||
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
|
||||
<ConformanceMode>false</ConformanceMode>
|
||||
|
||||
@@ -2,12 +2,17 @@
|
||||
|
||||
#define HKEY_WINDOWS_THEME L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"
|
||||
|
||||
// disabling warning 4702 - unreachable code
|
||||
// prevent the warning after the call off a infinite loop function
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
DWORD WINAPI _checkTheme(LPVOID lpParam)
|
||||
{
|
||||
auto listener = (ThemeListener*)lpParam;
|
||||
listener->CheckTheme();
|
||||
return 0;
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
void ThemeListener::AddChangedHandler(THEME_HANDLE handle)
|
||||
{
|
||||
|
||||
@@ -67,6 +67,10 @@ namespace updating
|
||||
throw std::runtime_error("Release object doesn't have the required asset");
|
||||
}
|
||||
|
||||
// disabling warning 4702 - unreachable code
|
||||
// prevent the warning that may show up depend on the value of the constants (#defines)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4702)
|
||||
std::future<nonstd::expected<github_version_info, std::wstring>> get_github_version_info_async(const bool prerelease)
|
||||
{
|
||||
// If the current version starts with 0.0.*, it means we're on a local build from a farm and shouldn't check for updates.
|
||||
@@ -126,6 +130,7 @@ namespace updating
|
||||
}
|
||||
co_return nonstd::make_unexpected(NETWORK_ERROR);
|
||||
}
|
||||
#pragma warning(pop)
|
||||
|
||||
std::filesystem::path get_pending_updates_path()
|
||||
{
|
||||
|
||||
@@ -74,7 +74,6 @@ public:
|
||||
// These are the settings shown on the settings page along with their current values.
|
||||
virtual bool get_config(wchar_t* buffer, int* buffer_size) override
|
||||
{
|
||||
return false;
|
||||
HINSTANCE hinstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
|
||||
|
||||
// Create a Settings object.
|
||||
|
||||
@@ -414,7 +414,6 @@ void FancyZones::WindowCreated(HWND window) noexcept
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
HMONITOR primary = MonitorFromWindow(nullptr, MONITOR_DEFAULTTOPRIMARY);
|
||||
HMONITOR active = primary;
|
||||
|
||||
@@ -553,7 +552,6 @@ void FancyZones::ToggleEditor() noexcept
|
||||
waitForEditorThread.detach();
|
||||
}
|
||||
|
||||
|
||||
LRESULT FancyZones::WndProc(HWND window, UINT message, WPARAM wparam, LPARAM lparam) noexcept
|
||||
{
|
||||
switch (message)
|
||||
@@ -1007,11 +1005,8 @@ bool FancyZones::OnSnapHotkey(DWORD vkCode) noexcept
|
||||
{
|
||||
return OnSnapHotkeyBasedOnPosition(window, vkCode);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (vkCode == VK_LEFT || vkCode == VK_RIGHT) && OnSnapHotkeyBasedOnZoneNumber(window, vkCode);
|
||||
}
|
||||
return false;
|
||||
|
||||
return (vkCode == VK_LEFT || vkCode == VK_RIGHT) && OnSnapHotkeyBasedOnZoneNumber(window, vkCode);
|
||||
}
|
||||
|
||||
bool FancyZones::ProcessDirectedSnapHotkey(HWND window, DWORD vkCode, bool cycle, std::shared_ptr<WorkArea> workArea) noexcept
|
||||
|
||||
@@ -36,8 +36,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-app-zone-history.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\app-zone-history.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -44,8 +44,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-applied-layouts.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\applied-layouts.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -58,8 +58,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-custom-layouts.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\custom-layouts.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <FancyZonesLib/FancyZonesData/LayoutData.h>
|
||||
#include <FancyZonesLib/ModuleConstants.h>
|
||||
|
||||
#include <common/SettingsAPI/FileWatcher.h>
|
||||
#include <common/SettingsAPI/settings_helpers.h>
|
||||
|
||||
@@ -40,8 +39,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-default-layouts.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\default-layouts.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -32,8 +32,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-layout-hotkeys.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\layout-hotkeys.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -29,8 +29,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-layout-templates.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\layout-templates.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void LoadData();
|
||||
|
||||
@@ -74,8 +74,9 @@ public:
|
||||
std::wstring saveFolderPath = PTSettingsHelper::get_module_save_folder_location(NonLocalizable::ModuleKey);
|
||||
#if defined(UNIT_TESTS)
|
||||
return saveFolderPath + L"\\test-settings.json";
|
||||
#endif
|
||||
#else
|
||||
return saveFolderPath + L"\\settings.json";
|
||||
#endif
|
||||
}
|
||||
|
||||
void AddObserver(SettingsObserver& observer);
|
||||
|
||||
Reference in New Issue
Block a user