mirror of
https://github.com/microsoft/PowerToys
synced 2025-08-30 22:15:11 +00:00
[Analyzers][CPP]Turn on C26451 and fix code (#21230)
* Turn on rule as error and fixing code * Add packages to external include paths * Disable warrnings on external code.
This commit is contained in:
@@ -34,7 +34,7 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
|
||||||
<VcpkgEnabled>false</VcpkgEnabled>
|
<VcpkgEnabled>false</VcpkgEnabled>
|
||||||
<ExternalIncludePath>$(MSBuildThisFileFullPath)\..\deps\;$(ExternalIncludePath)</ExternalIncludePath>
|
<ExternalIncludePath>$(MSBuildThisFileFullPath)\..\deps\;$(MSBuildThisFileFullPath)\..\packages\;$(ExternalIncludePath)</ExternalIncludePath>
|
||||||
<RunCodeAnalysis>true</RunCodeAnalysis>
|
<RunCodeAnalysis>true</RunCodeAnalysis>
|
||||||
<CodeAnalysisRuleSet>$(MsbuildThisFileDirectory)\CppRuleSet.ruleset</CodeAnalysisRuleSet>
|
<CodeAnalysisRuleSet>$(MsbuildThisFileDirectory)\CppRuleSet.ruleset</CodeAnalysisRuleSet>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
<Rule Id="C26444" Action="Info" />
|
<Rule Id="C26444" Action="Info" />
|
||||||
<Rule Id="C26449" Action="Info" />
|
<Rule Id="C26449" Action="Info" />
|
||||||
<Rule Id="C26450" Action="Info" />
|
<Rule Id="C26450" Action="Info" />
|
||||||
<Rule Id="C26451" Action="Info" />
|
<Rule Id="C26451" Action="Error" />
|
||||||
<Rule Id="C26452" Action="Info" />
|
<Rule Id="C26452" Action="Info" />
|
||||||
<Rule Id="C26453" Action="Info" />
|
<Rule Id="C26453" Action="Info" />
|
||||||
<Rule Id="C26454" Action="Info" />
|
<Rule Id="C26454" Action="Info" />
|
||||||
|
@@ -24,7 +24,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return std::string(2 * min(level, 64) - 1, ' ') + " - ";
|
return std::string(static_cast<int64_t>(2) * min(level, 64) - 1, ' ') + " - ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -139,9 +139,9 @@ ZonesMap CalculateGridZones(FancyZonesUtils::Rect workArea, FancyZonesDataTypes:
|
|||||||
columnInfo[col].Extent = columnInfo[col].End - columnInfo[col].Start;
|
columnInfo[col].Extent = columnInfo[col].End - columnInfo[col].Start;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int row = 0; row < gridLayoutInfo.rows(); row++)
|
for (int64_t row = 0; row < gridLayoutInfo.rows(); row++)
|
||||||
{
|
{
|
||||||
for (int col = 0; col < gridLayoutInfo.columns(); col++)
|
for (int64_t col = 0; col < gridLayoutInfo.columns(); col++)
|
||||||
{
|
{
|
||||||
int i = gridLayoutInfo.cellChildMap()[row][col];
|
int i = gridLayoutInfo.cellChildMap()[row][col];
|
||||||
if (((row == 0) || (gridLayoutInfo.cellChildMap()[row - 1][col] != i)) &&
|
if (((row == 0) || (gridLayoutInfo.cellChildMap()[row - 1][col] != i)) &&
|
||||||
@@ -150,12 +150,12 @@ ZonesMap CalculateGridZones(FancyZonesUtils::Rect workArea, FancyZonesDataTypes:
|
|||||||
long left = columnInfo[col].Start;
|
long left = columnInfo[col].Start;
|
||||||
long top = rowInfo[row].Start;
|
long top = rowInfo[row].Start;
|
||||||
|
|
||||||
int maxRow = row;
|
int64_t maxRow = row;
|
||||||
while (((maxRow + 1) < gridLayoutInfo.rows()) && (gridLayoutInfo.cellChildMap()[maxRow + 1][col] == i))
|
while (((maxRow + 1) < gridLayoutInfo.rows()) && (gridLayoutInfo.cellChildMap()[maxRow + 1][col] == i))
|
||||||
{
|
{
|
||||||
maxRow++;
|
maxRow++;
|
||||||
}
|
}
|
||||||
int maxCol = col;
|
int64_t maxCol = col;
|
||||||
while (((maxCol + 1) < gridLayoutInfo.columns()) && (gridLayoutInfo.cellChildMap()[row][maxCol + 1] == i))
|
while (((maxCol + 1) < gridLayoutInfo.columns()) && (gridLayoutInfo.cellChildMap()[row][maxCol + 1] == i))
|
||||||
{
|
{
|
||||||
maxCol++;
|
maxCol++;
|
||||||
@@ -165,9 +165,9 @@ ZonesMap CalculateGridZones(FancyZonesUtils::Rect workArea, FancyZonesDataTypes:
|
|||||||
long bottom = rowInfo[maxRow].End;
|
long bottom = rowInfo[maxRow].End;
|
||||||
|
|
||||||
top += row == 0 ? spacing : spacing / 2;
|
top += row == 0 ? spacing : spacing / 2;
|
||||||
bottom -= maxRow == gridLayoutInfo.rows() - 1 ? spacing : spacing / 2;
|
bottom -= maxRow == static_cast<int64_t>(gridLayoutInfo.rows()) - 1 ? spacing : spacing / 2;
|
||||||
left += col == 0 ? spacing : spacing / 2;
|
left += col == 0 ? spacing : spacing / 2;
|
||||||
right -= maxCol == gridLayoutInfo.columns() - 1 ? spacing : spacing / 2;
|
right -= maxCol == static_cast<int64_t>(gridLayoutInfo.columns()) - 1 ? spacing : spacing / 2;
|
||||||
|
|
||||||
auto zone = MakeZone(RECT{ left, top, right, bottom }, i);
|
auto zone = MakeZone(RECT{ left, top, right, bottom }, i);
|
||||||
if (zone)
|
if (zone)
|
||||||
|
@@ -709,11 +709,11 @@ ZoneIndexSet ZoneSet::ZoneSelectSubregion(const ZoneIndexSet& capturedZones, POI
|
|||||||
|
|
||||||
if (verticalSplit)
|
if (verticalSplit)
|
||||||
{
|
{
|
||||||
zoneIndex = (pt.y - overlap.top) * capturedZones.size() / height;
|
zoneIndex = (static_cast<int64_t>(pt.y) - overlap.top) * capturedZones.size() / height;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
zoneIndex = (pt.x - overlap.left) * capturedZones.size() / width;
|
zoneIndex = (static_cast<int64_t>(pt.x) - overlap.left) * capturedZones.size() / width;
|
||||||
}
|
}
|
||||||
|
|
||||||
zoneIndex = std::clamp(zoneIndex, ZoneIndex(0), static_cast<ZoneIndex>(capturedZones.size()) - 1);
|
zoneIndex = std::clamp(zoneIndex, ZoneIndex(0), static_cast<ZoneIndex>(capturedZones.size()) - 1);
|
||||||
|
@@ -587,7 +587,7 @@ namespace KeyboardEventHandlers
|
|||||||
{
|
{
|
||||||
DWORD to = std::get<0>(newRemapping.targetShortcut);
|
DWORD to = std::get<0>(newRemapping.targetShortcut);
|
||||||
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
||||||
key_count = from.Size() - 1 + 1 + (isLastKeyStillPressed ? 1 : 0);
|
key_count = static_cast<size_t>(from.Size()) - 1 + 1 + (isLastKeyStillPressed ? 1 : 0);
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
memset(keyEventList, 0, sizeof(keyEventList));
|
memset(keyEventList, 0, sizeof(keyEventList));
|
||||||
int i = 0;
|
int i = 0;
|
||||||
@@ -604,7 +604,10 @@ namespace KeyboardEventHandlers
|
|||||||
Shortcut to = std::get<Shortcut>(newRemapping.targetShortcut);
|
Shortcut to = std::get<Shortcut>(newRemapping.targetShortcut);
|
||||||
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
bool isLastKeyStillPressed = ii.GetVirtualKeyState((WORD)from.actionKey);
|
||||||
|
|
||||||
key_count = from.Size() - 1 + to.Size() - 1 - 2* from.GetCommonModifiersCount(to) + 1 + (isLastKeyStillPressed ? 1 : 0);
|
size_t temp_key_count_calculation = static_cast<size_t>(from.Size()) - 1;
|
||||||
|
temp_key_count_calculation += static_cast<size_t>(to.Size()) - 1;
|
||||||
|
temp_key_count_calculation -= static_cast<size_t>(2) * from.GetCommonModifiersCount(to);
|
||||||
|
key_count = temp_key_count_calculation + 1 + (isLastKeyStillPressed ? 1 : 0);
|
||||||
keyEventList = new INPUT[key_count]();
|
keyEventList = new INPUT[key_count]();
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemDefinitionGroup>
|
<ItemDefinitionGroup>
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<WarningLevel>Level4</WarningLevel>
|
<WarningLevel>Level3</WarningLevel>
|
||||||
<PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>WIN32;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>$(ProjectDir)..\;$(ProjectDir)..\ui;$(ProjectDir)..\dll;$(ProjectDir)..\lib;$(ProjectDir)..\..\..\;$(ProjectDir)..\..\..\common\Telemetry;%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>$(ProjectDir)..\;$(ProjectDir)..\ui;$(ProjectDir)..\dll;$(ProjectDir)..\lib;$(ProjectDir)..\..\..\;$(ProjectDir)..\..\..\common\Telemetry;%(AdditionalIncludeDirectories);$(GeneratedFilesDir)</AdditionalIncludeDirectories>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@@ -83,7 +83,7 @@ std::optional<SerializedSharedMemory> SerializedSharedMemory::create(const std::
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We need an extra byte for locking if it's not readonly
|
// We need an extra byte for locking if it's not readonly
|
||||||
const ULARGE_INTEGER UISize{ .QuadPart = size + !read_only };
|
const ULARGE_INTEGER UISize{ .QuadPart = static_cast<uint64_t>(size) + !read_only };
|
||||||
|
|
||||||
wil::unique_handle hMapFile{ CreateFileMappingW(INVALID_HANDLE_VALUE,
|
wil::unique_handle hMapFile{ CreateFileMappingW(INVALID_HANDLE_VALUE,
|
||||||
maybe_attributes ? maybe_attributes : &sa,
|
maybe_attributes ? maybe_attributes : &sa,
|
||||||
|
@@ -34,7 +34,7 @@ json::JsonObject PowertoyModule::json_config() const
|
|||||||
int size = 0;
|
int size = 0;
|
||||||
pt_module->get_config(nullptr, &size);
|
pt_module->get_config(nullptr, &size);
|
||||||
std::wstring result;
|
std::wstring result;
|
||||||
result.resize(size - 1);
|
result.resize(static_cast<size_t>(size) - 1);
|
||||||
pt_module->get_config(result.data(), &size);
|
pt_module->get_config(result.data(), &size);
|
||||||
return json::JsonObject::Parse(result);
|
return json::JsonObject::Parse(result);
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,8 @@
|
|||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\..\deps\cziplib\src\zip.c">
|
<ClCompile Include="..\..\..\deps\cziplib\src\zip.c">
|
||||||
<WarningLevel>TurnOffAllWarnings</WarningLevel>
|
<!-- Disabling warnings for external code -->
|
||||||
|
<DisableSpecificWarnings>26451;4267;4244;%(DisableSpecificWarnings)</DisableSpecificWarnings>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="EventViewer.cpp" />
|
<ClCompile Include="EventViewer.cpp" />
|
||||||
<ClCompile Include="InstallationFolder.cpp" />
|
<ClCompile Include="InstallationFolder.cpp" />
|
||||||
|
Reference in New Issue
Block a user