[Analyzers][CPP] turn on Warning 4100 (#21449)

* Analyzers CPP

Changing the warning level from 3 to 4.
change some project files to make them use the warning config in cpp props file.

* Analyzers C++ turn on warning 4706

Change Cpp.Build.props file to enable 4706
fix BugReportTool code to get rid of 4706

* Turn on warning 4100 and fix the code

* Follow c++ core guidelines

* Adapting to PR comments
This commit is contained in:
sosssego
2022-11-09 14:41:14 +00:00
committed by GitHub
parent cca10d2455
commit 78f5b4c3a4
40 changed files with 128 additions and 127 deletions

View File

@@ -42,7 +42,7 @@
<ClCompile> <ClCompile>
<PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<DisableSpecificWarnings>26800;28251;4100;4127;4189;4239;4244;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>26800;28251;4127;4189;4239;4244;4245;4389;4456;4457;4701;6387;4458;4505;4515;4459;4702;6031;6248;26451;28182;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<DisableAnalyzeExternal >true</DisableAnalyzeExternal> <DisableAnalyzeExternal >true</DisableAnalyzeExternal>
<ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel> <ExternalWarningLevel>TurnOffAllWarnings</ExternalWarningLevel>
<ConformanceMode>false</ConformanceMode> <ConformanceMode>false</ConformanceMode>

View File

@@ -19,7 +19,7 @@ MonitorInfo::MonitorInfo(HMONITOR h) :
GetMonitorInfoW(handle, &info); GetMonitorInfoW(handle, &info);
} }
static BOOL CALLBACK GetDisplaysEnumCb(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) static BOOL CALLBACK GetDisplaysEnumCb(HMONITOR monitor, HDC /*hdc*/, LPRECT /*rect*/, LPARAM data)
{ {
auto* monitors = reinterpret_cast<std::vector<MonitorInfo>*>(data); auto* monitors = reinterpret_cast<std::vector<MonitorInfo>*>(data);
monitors->emplace_back(monitor); monitors->emplace_back(monitor);

View File

@@ -24,7 +24,7 @@ HotkeyManager::~HotkeyManager()
} }
// When all Shortcut keys are pressed, fire the HotkeyCallback event. // When all Shortcut keys are pressed, fire the HotkeyCallback event.
void HotkeyManager::KeyboardEventProc(KeyboardEvent ^ ev) void HotkeyManager::KeyboardEventProc(KeyboardEvent ^ /*ev*/)
{ {
// pressedKeys always stores the latest keyboard state // pressedKeys always stores the latest keyboard state
auto pressedKeysHandle = GetHotkeyHandle(pressedKeys); auto pressedKeysHandle = GetHotkeyHandle(pressedKeys);

View File

@@ -90,7 +90,7 @@ public:
} }
virtual HRESULT STDMETHODCALLTYPE Activate( virtual HRESULT STDMETHODCALLTYPE Activate(
LPCWSTR appUserModelId, LPCWSTR /*appUserModelId*/,
LPCWSTR invokedArgs, LPCWSTR invokedArgs,
const NOTIFICATION_USER_INPUT_DATA*, const NOTIFICATION_USER_INPUT_DATA*,
ULONG) override ULONG) override

View File

@@ -14,7 +14,7 @@
extern "C" IMAGE_DOS_HEADER __ImageBase; extern "C" IMAGE_DOS_HEADER __ImageBase;
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -141,7 +141,7 @@ public:
return powertoys_gpo::getConfiguredHostsFileEditorEnabledValue(); return powertoys_gpo::getConfiguredHostsFileEditorEnabledValue();
} }
virtual bool get_config(wchar_t* buffer, int* buffer_size) override virtual bool get_config(wchar_t* /*buffer*/, int* /*buffer_size*/) override
{ {
return false; return false;
} }
@@ -173,7 +173,7 @@ public:
} }
} }
virtual void set_config(const wchar_t* config) override virtual void set_config(const wchar_t* /*config*/) override
{ {
} }

View File

@@ -9,11 +9,8 @@
extern "C" IMAGE_DOS_HEADER __ImageBase; extern "C" IMAGE_DOS_HEADER __ImageBase;
HMODULE m_hModule; BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{ {
m_hModule = hModule;
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
case DLL_PROCESS_ATTACH: case DLL_PROCESS_ATTACH:
@@ -245,7 +242,7 @@ public:
return m_enabled; return m_enabled;
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {

View File

@@ -13,9 +13,9 @@
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
BOOL APIENTRY DllMain(HMODULE hModule, BOOL APIENTRY DllMain(HMODULE /*hModule*/,
DWORD ul_reason_for_call, DWORD ul_reason_for_call,
LPVOID lpReserved) LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -30,6 +30,7 @@ BOOL APIENTRY DllMain(HMODULE hModule,
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@@ -207,7 +208,7 @@ public:
return settings.serialize_to_buffer(buffer, buffer_size); return settings.serialize_to_buffer(buffer, buffer_size);
} }
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }
@@ -254,7 +255,7 @@ public:
Trace::EnablePowerOCR(false); Trace::EnablePowerOCR(false);
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {
@@ -292,7 +293,6 @@ public:
{ {
return m_enabled; return m_enabled;
} }
}; };
extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create() extern "C" __declspec(dllexport) PowertoyModuleIface* __cdecl powertoy_create()

View File

@@ -43,7 +43,7 @@ bool SetCurrentPath()
return true; return true;
} }
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow) int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/, _In_opt_ HINSTANCE /*hPrevInstance*/, _In_ PWSTR lpCmdLine, _In_ int /*nCmdShow*/)
{ {
winrt::init_apartment(); winrt::init_apartment();
LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName); LoggerHelpers::init_logger(ShortcutGuideConstants::ModuleKey, L"ShortcutGuide", LogSettings::shortcutGuideLoggerName);

View File

@@ -11,7 +11,7 @@
#include "Generated Files/resource.h" #include "Generated Files/resource.h"
#include <common/SettingsAPI/settings_objects.h> #include <common/SettingsAPI/settings_objects.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD /*ul_reason_for_call*/, LPVOID /*lpReserved*/)
{ {
return TRUE; return TRUE;
} }

View File

@@ -30,7 +30,7 @@ namespace
const wchar_t JSON_KEY_VALUE[] = L"value"; const wchar_t JSON_KEY_VALUE[] = L"value";
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -106,7 +106,7 @@ public:
} }
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {

View File

@@ -17,7 +17,7 @@
#include <filesystem> #include <filesystem>
#include <set> #include <set>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {

View File

@@ -13,9 +13,7 @@
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
#include <common/utils/winapi_error.h> #include <common/utils/winapi_error.h>
BOOL APIENTRY DllMain(HMODULE hModule, BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
DWORD ul_reason_for_call,
LPVOID lpReserved)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -208,7 +206,7 @@ public:
return settings.serialize_to_buffer(buffer, buffer_size); return settings.serialize_to_buffer(buffer, buffer_size);
} }
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }
@@ -255,7 +253,7 @@ public:
m_enabled = false; m_enabled = false;
} }
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
if (m_enabled) if (m_enabled)
{ {

View File

@@ -247,7 +247,7 @@ namespace std
template<> template<>
struct hash<FancyZonesDataTypes::WorkAreaId> struct hash<FancyZonesDataTypes::WorkAreaId>
{ {
size_t operator()(const FancyZonesDataTypes::WorkAreaId& Value) const size_t operator()(const FancyZonesDataTypes::WorkAreaId& /*Value*/) const
{ {
return 0; return 0;
} }

View File

@@ -110,7 +110,7 @@ namespace std
template<> template<>
struct hash<BackwardsCompatibility::DeviceIdData> struct hash<BackwardsCompatibility::DeviceIdData>
{ {
size_t operator()(const BackwardsCompatibility::DeviceIdData& Value) const size_t operator()(const BackwardsCompatibility::DeviceIdData& /*Value*/) const
{ {
return 0; return 0;
} }

View File

@@ -19,7 +19,7 @@ public:
FancyZonesSettings::instance().RemoveObserver(*this); FancyZonesSettings::instance().RemoveObserver(*this);
} }
virtual void SettingsUpdate(SettingId type) {} virtual void SettingsUpdate(SettingId /*type*/) {}
bool WantsToBeNotified(SettingId type) const noexcept bool WantsToBeNotified(SettingId type) const noexcept
{ {

View File

@@ -59,7 +59,7 @@ WindowMoveHandler::WindowMoveHandler(const std::function<void()>& keyUpdateCallb
{ {
} }
void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& ptScreen, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept void WindowMoveHandler::MoveSizeStart(HWND window, HMONITOR monitor, POINT const& /*ptScreen*/, const std::unordered_map<HMONITOR, std::shared_ptr<WorkArea>>& workAreaMap) noexcept
{ {
if (!FancyZonesWindowProcessing::IsProcessable(window)) if (!FancyZonesWindowProcessing::IsProcessable(window))
{ {

View File

@@ -38,7 +38,7 @@ enum DWM_WINDOW_CORNER_PREFERENCE
namespace namespace
{ {
BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC hdc, LPRECT rect, LPARAM data) BOOL CALLBACK saveDisplayToVector(HMONITOR monitor, HDC /*hdc*/, LPRECT /*rect*/, LPARAM data)
{ {
reinterpret_cast<std::vector<HMONITOR>*>(data)->emplace_back(monitor); reinterpret_cast<std::vector<HMONITOR>*>(data)->emplace_back(monitor);
return true; return true;
@@ -121,7 +121,6 @@ namespace
} }
} }
bool FancyZonesWindowUtils::IsSplashScreen(HWND window) bool FancyZonesWindowUtils::IsSplashScreen(HWND window)
{ {
wchar_t className[MAX_PATH]; wchar_t className[MAX_PATH];
@@ -200,9 +199,7 @@ bool FancyZonesWindowUtils::IsPopupWindow(HWND window) noexcept
bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept bool FancyZonesWindowUtils::HasThickFrameAndMinimizeMaximizeButtons(HWND window) noexcept
{ {
auto style = GetWindowLong(window, GWL_STYLE); auto style = GetWindowLong(window, GWL_STYLE);
return ((style & WS_THICKFRAME) == WS_THICKFRAME return ((style & WS_THICKFRAME) == WS_THICKFRAME && (style & WS_MINIMIZEBOX) == WS_MINIMIZEBOX && (style & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX);
&& (style & WS_MINIMIZEBOX) == WS_MINIMIZEBOX
&& (style & WS_MAXIMIZEBOX) == WS_MAXIMIZEBOX);
} }
bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window) bool FancyZonesWindowUtils::IsCandidateForZoning(HWND window)

View File

@@ -14,7 +14,7 @@ public:
~WorkArea(); ~WorkArea();
public: public:
inline bool Init(HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId) inline bool Init([[maybe_unused]] HINSTANCE hinstance, const FancyZonesDataTypes::WorkAreaId& parentUniqueId)
{ {
#ifndef UNIT_TESTS #ifndef UNIT_TESTS
if (!InitWindow(hinstance)) if (!InitWindow(hinstance))
@@ -22,7 +22,6 @@ public:
return false; return false;
} }
#endif #endif
InitLayout(parentUniqueId); InitLayout(parentUniqueId);
return true; return true;
} }
@@ -123,4 +122,3 @@ inline std::shared_ptr<WorkArea> MakeWorkArea(HINSTANCE hinstance, HMONITOR moni
return self; return self;
} }

View File

@@ -43,7 +43,7 @@ namespace FancyZonesUtils
quad->rgbBlue = GetBValue(color) * alpha / 255; quad->rgbBlue = GetBValue(color) * alpha / 255;
} }
inline void FillRectARGB(wil::unique_hdc& hdc, RECT const* prcFill, BYTE alpha, COLORREF color, bool blendAlpha) inline void FillRectARGB(wil::unique_hdc& hdc, RECT const* prcFill, BYTE alpha, COLORREF color, bool /*blendAlpha*/)
{ {
BITMAPINFO bi; BITMAPINFO bi;
ZeroMemory(&bi, sizeof(bi)); ZeroMemory(&bi, sizeof(bi));
@@ -104,7 +104,7 @@ namespace FancyZonesUtils
using result_t = std::vector<std::pair<HMONITOR, RECT>>; using result_t = std::vector<std::pair<HMONITOR, RECT>>;
result_t result; result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { auto enumMonitors = [](HMONITOR monitor, HDC /*hdc*/, LPRECT /*pRect*/, LPARAM param) -> BOOL {
MONITORINFOEX mi; MONITORINFOEX mi;
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param); result_t& result = *reinterpret_cast<result_t*>(param);
@@ -126,7 +126,7 @@ namespace FancyZonesUtils
using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>; using result_t = std::vector<std::pair<HMONITOR, MONITORINFOEX>>;
result_t result; result_t result;
auto enumMonitors = [](HMONITOR monitor, HDC hdc, LPRECT pRect, LPARAM param) -> BOOL { auto enumMonitors = [](HMONITOR monitor, HDC /*hdc*/, LPRECT /*pRect*/, LPARAM param) -> BOOL {
MONITORINFOEX mi; MONITORINFOEX mi;
mi.cbSize = sizeof(mi); mi.cbSize = sizeof(mi);
result_t& result = *reinterpret_cast<result_t*>(param); result_t& result = *reinterpret_cast<result_t*>(param);

View File

@@ -17,7 +17,7 @@
// Non-localizable // Non-localizable
const std::wstring fancyZonesPath = L"modules\\FancyZones\\PowerToys.FancyZones.exe"; const std::wstring fancyZonesPath = L"modules\\FancyZones\\PowerToys.FancyZones.exe";
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -59,20 +59,20 @@ public:
// Return JSON with the configuration options. // Return JSON with the configuration options.
// These are the settings shown on the settings page along with their current values. // These are the settings shown on the settings page along with their current values.
virtual bool get_config(_Out_ PWSTR buffer, _Out_ int* buffer_size) override virtual bool get_config(_Out_ PWSTR /*buffer*/, _Out_ int* /*buffer_size*/) override
{ {
return false; return false;
} }
// Passes JSON with the configuration settings for the powertoy. // Passes JSON with the configuration settings for the powertoy.
// This is called when the user hits Save on the settings page. // This is called when the user hits Save on the settings page.
virtual void set_config(PCWSTR config) override virtual void set_config(PCWSTR /*config*/) override
{ {
} }
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
SetEvent(m_toggleEditorEvent); SetEvent(m_toggleEditorEvent);
} }

View File

@@ -38,7 +38,7 @@ void CContextMenuHandler::Uninitialize()
} }
} }
HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY hkeyProgID) HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _In_opt_ IDataObject* pdtobj, _In_opt_ HKEY /*hkeyProgID*/)
{ {
Uninitialize(); Uninitialize();
@@ -61,7 +61,7 @@ HRESULT CContextMenuHandler::Initialize(_In_opt_ PCIDLIST_ABSOLUTE pidlFolder, _
return S_OK; return S_OK;
} }
HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags) HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT /*idCmdLast*/, UINT uFlags)
{ {
if (uFlags & CMF_DEFAULTONLY) if (uFlags & CMF_DEFAULTONLY)
return S_OK; return S_OK;
@@ -167,7 +167,7 @@ HRESULT CContextMenuHandler::QueryContextMenu(_In_ HMENU hmenu, UINT indexMenu,
return S_OK; return S_OK;
} }
HRESULT CContextMenuHandler::GetCommandString(UINT_PTR idCmd, UINT uType, _In_ UINT* pReserved, LPSTR pszName, UINT cchMax) HRESULT CContextMenuHandler::GetCommandString(UINT_PTR idCmd, UINT uType, _In_ UINT* /*pReserved*/, LPSTR pszName, UINT cchMax)
{ {
if (idCmd == ID_RESIZE_PICTURES) if (idCmd == ID_RESIZE_PICTURES)
{ {
@@ -360,7 +360,7 @@ HRESULT __stdcall CContextMenuHandler::GetCanonicalName(GUID* pguidCommandName)
return S_OK; return S_OK;
} }
HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState) HRESULT __stdcall CContextMenuHandler::GetState(IShellItemArray* psiItemArray, BOOL /*fOkToBeSlow*/, EXPCMDSTATE* pCmdState)
{ {
if (!CSettingsInstance().GetEnabled()) if (!CSettingsInstance().GetEnabled())
{ {

View File

@@ -92,10 +92,10 @@ public:
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override {} virtual void call_custom_action(const wchar_t* /*action*/) override {}
// Called by the runner to pass the updated settings values as a serialized JSON. // Called by the runner to pass the updated settings values as a serialized JSON.
virtual void set_config(const wchar_t* config) override {} virtual void set_config(const wchar_t* /*config*/) override {}
// Enable the powertoy // Enable the powertoy
virtual void enable() virtual void enable()
@@ -114,7 +114,6 @@ public:
} }
} }
Trace::EnableImageResizer(m_enabled); Trace::EnableImageResizer(m_enabled);
} }

View File

@@ -68,7 +68,7 @@ public:
/* Sets the configuration values. */ /* Sets the configuration values. */
virtual void set_config(const wchar_t* config) = 0; virtual void set_config(const wchar_t* config) = 0;
/* Call custom action from settings screen. */ /* Call custom action from settings screen. */
virtual void call_custom_action(const wchar_t* action){}; virtual void call_custom_action(const wchar_t* /*action*/){};
/* Enables the PowerToy. */ /* Enables the PowerToy. */
virtual void enable() = 0; virtual void enable() = 0;
/* Disables the PowerToy, should free as much memory as possible. */ /* Disables the PowerToy, should free as much memory as possible. */
@@ -83,7 +83,10 @@ public:
* Modules do not need to override this method, it will return zero by default. * Modules do not need to override this method, it will return zero by default.
* This method is called even when the module is disabled. * This method is called even when the module is disabled.
*/ */
virtual size_t get_hotkeys(Hotkey* buffer, size_t buffer_size) { return 0; } virtual size_t get_hotkeys(Hotkey* /*buffer*/, size_t /*buffer_size*/)
{
return 0;
}
virtual std::optional<HotkeyEx> GetHotkeyEx() virtual std::optional<HotkeyEx> GetHotkeyEx()
{ {
@@ -97,7 +100,10 @@ public:
/* Called when one of the registered hotkeys is pressed. Should return true /* Called when one of the registered hotkeys is pressed. Should return true
* if the key press is to be swallowed. * if the key press is to be swallowed.
*/ */
virtual bool on_hotkey(size_t hotkeyId) { return false; } virtual bool on_hotkey(size_t /*hotkeyId*/)
{
return false;
}
/* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key. /* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key.
* keep_track_of_pressed_win_key returns true if the module wants to keep track of the win key being pressed. * keep_track_of_pressed_win_key returns true if the module wants to keep track of the win key being pressed.
@@ -114,7 +120,8 @@ public:
virtual bool is_enabled_by_default() const { return true; } virtual bool is_enabled_by_default() const { return true; }
/* Provides the GPO configuration value for the module. This should be overriden by the module interface to get the proper gpo policy setting. */ /* Provides the GPO configuration value for the module. This should be overriden by the module interface to get the proper gpo policy setting. */
virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration() { virtual powertoys_gpo::gpo_rule_configured_t gpo_policy_enabled_configuration()
{
return powertoys_gpo::gpo_rule_configured_not_configured; return powertoys_gpo::gpo_rule_configured_not_configured;
} }

View File

@@ -22,12 +22,10 @@ std::unique_ptr<KeyboardManagerEditor> editor = nullptr;
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEditor_InstanceMutex"; const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEditor_InstanceMutex";
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ LPWSTR lpCmdLine, _In_ LPWSTR /*lpCmdLine*/,
_In_ int nCmdShow) _In_ int /*nCmdShow*/)
{ {
UNREFERENCED_PARAMETER(hPrevInstance);
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName); LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Editor", LogSettings::keyboardManagerLoggerName);
if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled) if (powertoys_gpo::getConfiguredKeyboardManagerEnabledValue() == powertoys_gpo::gpo_rule_configured_disabled)

View File

@@ -11,7 +11,10 @@
const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex"; const std::wstring instanceMutexName = L"Local\\PowerToys_KBMEngine_InstanceMutex";
int WINAPI wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ PWSTR lpCmdLine, _In_ int nCmdShow) int WINAPI wWinMain(_In_ HINSTANCE /*hInstance*/,
_In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ PWSTR lpCmdLine,
_In_ int /*nCmdShow*/)
{ {
winrt::init_apartment(); winrt::init_apartment();
LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName); LoggerHelpers::init_logger(KeyboardManagerConstants::ModuleName, L"Engine", LogSettings::keyboardManagerLoggerName);

View File

@@ -10,7 +10,7 @@ void MockedInput::SetHookProc(std::function<intptr_t(LowlevelKeyboardEvent*)> ho
} }
// Function to simulate keyboard input - arguments and return value based on SendInput function (https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput) // Function to simulate keyboard input - arguments and return value based on SendInput function (https://learn.microsoft.com/windows/win32/api/winuser/nf-winuser-sendinput)
UINT MockedInput::SendVirtualInput(UINT cInputs, LPINPUT pInputs, int cbSize) UINT MockedInput::SendVirtualInput(UINT cInputs, LPINPUT pInputs, int /*cbSize*/)
{ {
// Iterate over inputs // Iterate over inputs
for (UINT i = 0; i < cInputs; i++) for (UINT i = 0; i < cInputs; i++)

View File

@@ -9,7 +9,7 @@
#include <shellapi.h> #include <shellapi.h>
#include <common/utils/logger_helper.h> #include <common/utils/logger_helper.h>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -23,6 +23,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@@ -40,6 +41,7 @@ private:
std::wstring app_key = KeyboardManagerConstants::ModuleName; std::wstring app_key = KeyboardManagerConstants::ModuleName;
HANDLE m_hProcess = nullptr; HANDLE m_hProcess = nullptr;
public: public:
// Constructor // Constructor
KeyboardManager() KeyboardManager()
@@ -89,7 +91,7 @@ public:
} }
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }

View File

@@ -29,7 +29,7 @@ namespace
const wchar_t JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK[] = L"use_centralized_keyboard_hook"; const wchar_t JSON_KEY_USE_CENTRALIZED_KEYBOARD_HOOK[] = L"use_centralized_keyboard_hook";
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -43,6 +43,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }
@@ -318,7 +319,7 @@ public:
} }
// Process the hotkey event // Process the hotkey event
virtual bool on_hotkey(size_t hotkeyId) override virtual bool on_hotkey(size_t /*hotkeyId*/) override
{ {
// For now, hotkeyId will always be zero // For now, hotkeyId will always be zero
if (m_enabled) if (m_enabled)

View File

@@ -18,7 +18,7 @@
#include <filesystem> #include <filesystem>
#include <set> #include <set>
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {
@@ -32,6 +32,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
Trace::UnregisterProvider(); Trace::UnregisterProvider();
break; break;
} }
return TRUE; return TRUE;
} }

View File

@@ -272,7 +272,7 @@ HRESULT __stdcall CPowerRenameMenu::GetCanonicalName(GUID* pguidCommandName)
return S_OK; return S_OK;
} }
HRESULT __stdcall CPowerRenameMenu::GetState(IShellItemArray* psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE* pCmdState) HRESULT __stdcall CPowerRenameMenu::GetState(IShellItemArray* /*psiItemArray*/, BOOL /*fOkToBeSlow*/, EXPCMDSTATE* pCmdState)
{ {
*pCmdState = CSettingsInstance().GetEnabled() ? ECS_ENABLED : ECS_HIDDEN; *pCmdState = CSettingsInstance().GetEnabled() ? ECS_ENABLED : ECS_HIDDEN;
return S_OK; return S_OK;

View File

@@ -168,8 +168,6 @@ private:
std::wstring app_key; std::wstring app_key;
public: public:
// Return the localized display name of the powertoy // Return the localized display name of the powertoy
virtual PCWSTR get_name() override virtual PCWSTR get_name() override
{ {
@@ -300,7 +298,7 @@ public:
// Signal from the Settings editor to call a custom action. // Signal from the Settings editor to call a custom action.
// This can be used to spawn more complex editors. // This can be used to spawn more complex editors.
virtual void call_custom_action(const wchar_t* action) override virtual void call_custom_action(const wchar_t* /*action*/) override
{ {
} }

View File

@@ -28,9 +28,9 @@ DEFINE_GUID(BHID_DataObject, 0xb8c0bd9f, 0xed24, 0x455c, 0x83, 0xe6, 0xd5, 0x39,
int APIENTRY wWinMain( int APIENTRY wWinMain(
_In_ HINSTANCE hInstance, _In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance, _In_opt_ HINSTANCE /*hPrevInstance*/,
_In_ PWSTR lpCmdLine, _In_ PWSTR /*lpCmdLine*/,
_In_ int nCmdShow) _In_ int /*nCmdShow*/)
{ {
g_hostHInst = hInstance; g_hostHInst = hInstance;
HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
@@ -81,5 +81,6 @@ int APIENTRY wWinMain(
} }
CoUninitialize(); CoUninitialize();
} }
return 0; return 0;
} }

View File

@@ -53,19 +53,19 @@ IFACEMETHODIMP CMockPowerRenameManagerEvents::OnError(_In_ IPowerRenameItem* pIt
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExStarted(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExStarted(_In_ DWORD /*threadId*/)
{ {
m_regExStarted = true; m_regExStarted = true;
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCanceled(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCanceled(_In_ DWORD /*threadId*/)
{ {
m_regExCanceled = true; m_regExCanceled = true;
return S_OK; return S_OK;
} }
IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCompleted(_In_ DWORD threadId) IFACEMETHODIMP CMockPowerRenameManagerEvents::OnRegExCompleted(_In_ DWORD /*threadId*/)
{ {
m_regExCompleted = true; m_regExCompleted = true;
return S_OK; return S_OK;

View File

@@ -31,7 +31,7 @@ HRESULT CALLBACK DllGetClassObject(REFCLSID clsid, REFIID riid, void** ppv)
return hr; return hr;
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*lpReserved*/)
{ {
switch (ul_reason_for_call) switch (ul_reason_for_call)
{ {

View File

@@ -9,7 +9,7 @@ namespace CentralizedHotkeys
std::wstring moduleName; std::wstring moduleName;
std::function<void(WORD, WORD)> action; std::function<void(WORD, WORD)> action;
Action(std::wstring moduleName = L"", std::function<void(WORD, WORD)> action = ([](WORD modifiersMask, WORD vkCode) {})) Action(std::wstring moduleName = L"", std::function<void(WORD, WORD)> action = ([](WORD /*modifiersMask*/, WORD /*vkCode*/) {}))
{ {
this->moduleName = moduleName; this->moduleName = moduleName;
this->action = action; this->action = action;

View File

@@ -58,9 +58,9 @@ namespace CentralizedKeyboardHook
// Handle the pressed key proc // Handle the pressed key proc
void PressedKeyTimerProc( void PressedKeyTimerProc(
HWND hwnd, HWND hwnd,
UINT message, UINT /*message*/,
UINT_PTR idTimer, UINT_PTR idTimer,
DWORD dwTime) DWORD /*dwTime*/)
{ {
std::multiset<PressedKeyDescriptor> copy; std::multiset<PressedKeyDescriptor> copy;
{ {

View File

@@ -348,7 +348,7 @@ void cleanup_updates()
} }
} }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) int WINAPI WinMain(HINSTANCE /*hInstance*/, HINSTANCE /*hPrevInstance*/, LPSTR lpCmdLine, int /*nCmdShow*/)
{ {
Gdiplus::GdiplusStartupInput gpStartupInput; Gdiplus::GdiplusStartupInput gpStartupInput;
ULONG_PTR gpToken; ULONG_PTR gpToken;

View File

@@ -78,7 +78,7 @@ void PowertoyModule::UpdateHotkeyEx()
{ {
auto hotkey = container.value(); auto hotkey = container.value();
auto modulePtr = pt_module.get(); auto modulePtr = pt_module.get();
auto action = [modulePtr](WORD modifiersMask, WORD vkCode) { auto action = [modulePtr](WORD /*modifiersMask*/, WORD /*vkCode*/) {
Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key()); Logger::trace(L"{} hotkey Ex is invoked from Centralized keyboard hook", modulePtr->get_key());
modulePtr->OnHotkeyEx(); modulePtr->OnHotkeyEx();
}; };

View File

@@ -462,7 +462,7 @@ LExit:
#define MAX_TITLE_LENGTH 100 #define MAX_TITLE_LENGTH 100
void bring_settings_to_front() void bring_settings_to_front()
{ {
auto callback = [](HWND hwnd, LPARAM data) -> BOOL { auto callback = [](HWND hwnd, LPARAM /*data*/) -> BOOL {
DWORD processId; DWORD processId;
if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id) if (GetWindowThreadProcessId(hwnd, &processId) && processId == g_settings_process_id)
{ {

View File

@@ -9,6 +9,7 @@
<ProjectName>BugReportTool</ProjectName> <ProjectName>BugReportTool</ProjectName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<PropertyGroup Label="Configuration"> <PropertyGroup Label="Configuration">
<PlatformToolset>v143</PlatformToolset> <PlatformToolset>v143</PlatformToolset>
</PropertyGroup> </PropertyGroup>
@@ -23,7 +24,7 @@
<PropertyGroup Condition="'$(Configuration)'=='Release'"> <PropertyGroup Condition="'$(Configuration)'=='Release'">
<TargetName>PowerToys.$(ProjectName)</TargetName> <TargetName>PowerToys.$(ProjectName)</TargetName>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
</ImportGroup> </ImportGroup>
<ImportGroup Label="Shared"> <ImportGroup Label="Shared">
@@ -45,7 +46,7 @@
<ItemGroup> <ItemGroup>
<ClCompile Include="..\..\..\deps\cziplib\src\zip.c"> <ClCompile Include="..\..\..\deps\cziplib\src\zip.c">
<!-- Disabling warnings for external code --> <!-- Disabling warnings for external code -->
<DisableSpecificWarnings>26451;4706;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>4706;26451;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<ClCompile Include="EventViewer.cpp" /> <ClCompile Include="EventViewer.cpp" />
<ClCompile Include="InstallationFolder.cpp" /> <ClCompile Include="InstallationFolder.cpp" />