[CodeQuality]Fix C++ static analyzer findings (#29745)

* [PVS] Fix static analyzer findings

* f: fix error handling

* f: more improvements

* Update src/modules/FileLocksmith/FileLocksmithLibInterop/NtdllExtensions.cpp
This commit is contained in:
Andrey Nekrasov
2023-11-15 17:38:44 +01:00
committed by GitHub
parent 4ebc4cbc0d
commit 5ab83c6ad2
10 changed files with 19 additions and 27 deletions

View File

@@ -238,7 +238,7 @@ void FancyZonesSettings::LoadSettings()
if (auto val = values.get_int_value(NonLocalizable::OverlappingZonesAlgorithmID))
{
// Avoid undefined behavior
if (*val >= 0 || *val < static_cast<int>(OverlappingZonesAlgorithm::EnumElements))
if (*val >= 0 && *val < static_cast<int>(OverlappingZonesAlgorithm::EnumElements))
{
auto algorithm = (OverlappingZonesAlgorithm)*val;
if (m_settings.overlappingZonesAlgorithm != algorithm)

View File

@@ -306,26 +306,23 @@ void FancyZonesWindowUtils::SizeWindowToRect(HWND window, RECT rect) noexcept
::GetWindowPlacement(window, &placement);
}
if (!IsWindowVisible(window))
{
placement.showCmd = SW_HIDE;
}
else
if (IsWindowVisible(window))
{
// Do not restore minimized windows. We change their placement though so they restore to the correct zone.
if ((placement.showCmd != SW_SHOWMINIMIZED) &&
(placement.showCmd != SW_MINIMIZE))
{
placement.showCmd = SW_RESTORE;
}
// Remove maximized show command to make sure window is moved to the correct zone.
if (placement.showCmd == SW_SHOWMAXIMIZED)
placement.flags &= ~WPF_RESTORETOMAXIMIZED;
// Remove maximized show command to make sure window is moved to the correct zone.
if (placement.showCmd == SW_SHOWMAXIMIZED)
{
placement.showCmd = SW_RESTORE;
placement.flags &= ~WPF_RESTORETOMAXIMIZED;
}
}
else
{
placement.showCmd = SW_HIDE;
}
ScreenToWorkAreaCoords(window, rect);