Skip to content

Commit 57c3104

Browse files
Merge pull request #40777 from adityamandaleeka/enable_cpp_warnings
Enable more MSVC warnings for SDL signoff
2 parents 4fb0afc + 510aca8 commit 57c3104

File tree

8 files changed

+141
-271
lines changed

8 files changed

+141
-271
lines changed

src/Servers/IIS/AspNetCoreModuleV2/IISLib/IISLib.vcxproj

Lines changed: 6 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,123 +1,36 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<ItemGroup Label="ProjectConfigurations">
4-
<ProjectConfiguration Include="Debug|Win32">
5-
<Configuration>Debug</Configuration>
6-
<Platform>Win32</Platform>
7-
</ProjectConfiguration>
8-
<ProjectConfiguration Include="Debug|x64">
9-
<Configuration>Debug</Configuration>
10-
<Platform>x64</Platform>
11-
</ProjectConfiguration>
12-
<ProjectConfiguration Include="Debug|ARM64">
13-
<Configuration>Debug</Configuration>
14-
<Platform>ARM64</Platform>
15-
</ProjectConfiguration>
16-
<ProjectConfiguration Include="Debug|Any CPU">
17-
<Configuration>Debug</Configuration>
18-
<Platform>x64</Platform>
19-
</ProjectConfiguration>
20-
<ProjectConfiguration Include="Release|Win32">
21-
<Configuration>Release</Configuration>
22-
<Platform>Win32</Platform>
23-
</ProjectConfiguration>
24-
<ProjectConfiguration Include="Release|x64">
25-
<Configuration>Release</Configuration>
26-
<Platform>x64</Platform>
27-
</ProjectConfiguration>
28-
<ProjectConfiguration Include="Release|ARM64">
29-
<Configuration>Release</Configuration>
30-
<Platform>ARM64</Platform>
31-
</ProjectConfiguration>
32-
<ProjectConfiguration Include="Release|Any CPU">
33-
<Configuration>Release</Configuration>
34-
<Platform>x64</Platform>
35-
</ProjectConfiguration>
36-
</ItemGroup>
3+
<Import Project="..\..\build\Build.Lib.Settings" />
374
<PropertyGroup Label="Globals">
385
<ProjectGuid>{09D9D1D6-2951-4E14-BC35-76A23CF9391A}</ProjectGuid>
39-
<Keyword>Win32Proj</Keyword>
406
<RootNamespace>IISLib</RootNamespace>
417
<ProjectName>IISLib</ProjectName>
42-
<WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0.18362.0</WindowsTargetPlatformVersion>
43-
</PropertyGroup>
44-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
45-
<PropertyGroup Label="Configuration">
46-
<VCToolsVersion>14.29.30133</VCToolsVersion>
47-
</PropertyGroup>
48-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
49-
<ConfigurationType>StaticLibrary</ConfigurationType>
50-
<UseDebugLibraries>false</UseDebugLibraries>
51-
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
52-
<CharacterSet>Unicode</CharacterSet>
53-
</PropertyGroup>
54-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|ARM64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'" Label="Configuration">
55-
<ConfigurationType>StaticLibrary</ConfigurationType>
56-
<UseDebugLibraries>false</UseDebugLibraries>
57-
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
58-
<CharacterSet>Unicode</CharacterSet>
598
</PropertyGroup>
60-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
61-
<ConfigurationType>StaticLibrary</ConfigurationType>
62-
<UseDebugLibraries>false</UseDebugLibraries>
63-
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
9+
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
6410
<WholeProgramOptimization>true</WholeProgramOptimization>
65-
<CharacterSet>Unicode</CharacterSet>
6611
</PropertyGroup>
67-
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|ARM64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'" Label="Configuration">
68-
<ConfigurationType>StaticLibrary</ConfigurationType>
69-
<UseDebugLibraries>false</UseDebugLibraries>
70-
<PlatformToolset>$(PlatformToolsetVersion)</PlatformToolset>
71-
<WholeProgramOptimization>true</WholeProgramOptimization>
72-
<CharacterSet>Unicode</CharacterSet>
73-
</PropertyGroup>
74-
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
75-
<ImportGroup Label="ExtensionSettings">
76-
</ImportGroup>
77-
<ImportGroup Label="PropertySheets">
78-
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
79-
</ImportGroup>
80-
<PropertyGroup Label="UserMacros" />
81-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32' OR'$(Configuration)|$(Platform)'=='Debug|x64' OR '$(Configuration)|$(Platform)'=='Debug|ARM64' OR '$(Configuration)|$(Platform)'=='Debug|Any CPU'">
12+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
8213
<ClCompile>
8314
<PrecompiledHeader>
8415
</PrecompiledHeader>
85-
<WarningLevel>Level3</WarningLevel>
86-
<Optimization>Disabled</Optimization>
87-
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
16+
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
8817
<SDLCheck>true</SDLCheck>
8918
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
90-
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
91-
<ShowIncludes>false</ShowIncludes>
92-
<TreatWarningAsError>true</TreatWarningAsError>
93-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
9419
</ClCompile>
9520
<Link>
96-
<SubSystem>Windows</SubSystem>
9721
<GenerateDebugInformation>true</GenerateDebugInformation>
9822
</Link>
9923
</ItemDefinitionGroup>
100-
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32' OR '$(Configuration)|$(Platform)'=='Release|x64' OR '$(Configuration)|$(Platform)'=='Release|ARM64' OR '$(Configuration)|$(Platform)'=='Release|Any CPU'">
24+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
10125
<ClCompile>
102-
<WarningLevel>Level3</WarningLevel>
10326
<PrecompiledHeader>
10427
</PrecompiledHeader>
105-
<Optimization>MaxSpeed</Optimization>
106-
<FunctionLevelLinking>true</FunctionLevelLinking>
107-
<IntrinsicFunctions>true</IntrinsicFunctions>
108-
<PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
28+
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
10929
<SDLCheck>true</SDLCheck>
110-
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
111-
<ShowIncludes>false</ShowIncludes>
112-
<TreatWarningAsError>true</TreatWarningAsError>
113-
<MultiProcessorCompilation>true</MultiProcessorCompilation>
11430
</ClCompile>
11531
<Link>
116-
<SubSystem>Windows</SubSystem>
11732
<GenerateDebugInformation>true</GenerateDebugInformation>
118-
<EnableCOMDATFolding>true</EnableCOMDATFolding>
11933
<AdditionalOptions>/NODEFAULTLIB:libucrt.lib /DEFAULTLIB:ucrt.lib %(AdditionalOptions)</AdditionalOptions>
120-
<OptimizeReferences>true</OptimizeReferences>
12134
</Link>
12235
</ItemDefinitionGroup>
12336
<ItemGroup>

src/Servers/IIS/AspNetCoreModuleV2/IISLib/acache.cpp

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ HANDLE ALLOC_CACHE_HANDLER::sm_hHeap;
1414
// memory block to a FREE_LIST_HEADER*. The signature is used to guard against
1515
// double deletion. We also fill memory with a pattern.
1616
//
17+
// Disabling C4324 here; alignment comes from SLIST_ENTRY definition.
18+
#pragma warning(push)
19+
#pragma warning(disable:4324)
1720
class FREE_LIST_HEADER
1821
{
1922
public:
@@ -25,6 +28,7 @@ class FREE_LIST_HEADER
2528
FREE_SIGNATURE = (('A') | ('C' << 8) | ('a' << 16) | (('$' << 24) | 0x80)),
2629
};
2730
};
31+
#pragma warning(pop)
2832

2933
ALLOC_CACHE_HANDLER::ALLOC_CACHE_HANDLER(
3034
) : m_nThreshold(0),
@@ -75,7 +79,7 @@ ALLOC_CACHE_HANDLER::Initialize(
7579
//
7680
m_cbSize = cbSize;
7781
m_cbSize = max(m_cbSize, sizeof(FREE_LIST_HEADER));
78-
82+
7983
//
8084
// Round up the block size to a multiple of the size of a LONG (for
8185
// the fill pattern in Free()).
@@ -97,7 +101,7 @@ ALLOC_CACHE_HANDLER::Initialize(
97101
}
98102
} Init;
99103
#endif
100-
104+
101105
hr = PER_CPU<SLIST_HEADER>::Create(Init,
102106
&m_pFreeLists );
103107
if (FAILED(hr))
@@ -223,6 +227,7 @@ ALLOC_CACHE_HANDLER::Alloc(
223227
// on memory that they've freed.
224228
//
225229
DBG_ASSERT(pfl->dwSignature == FREE_LIST_HEADER::FREE_SIGNATURE);
230+
(void)pfl;
226231
}
227232
}
228233

@@ -319,11 +324,11 @@ ALLOC_CACHE_HANDLER::QueryDepthForAllSLists(
319324
/*++
320325
321326
Description:
322-
327+
323328
Aggregates the total count of elements in all lists.
324-
329+
325330
Arguments:
326-
331+
327332
None.
328333
329334
Return Value:
@@ -388,7 +393,7 @@ ALLOC_CACHE_HANDLER::IsPageheapEnabled(
388393
}
389394

390395
//
391-
// Create a heap for calling heapwalk
396+
// Create a heap for calling heapwalk
392397
// otherwise HeapWalk turns off lookasides for a useful heap
393398
//
394399
hHeap = ::HeapCreate( 0, 0, 0 );
@@ -397,7 +402,7 @@ ALLOC_CACHE_HANDLER::IsPageheapEnabled(
397402
fRet = FALSE;
398403
goto Finished;
399404
}
400-
405+
401406
fRet = ::HeapLock( hHeap );
402407
if ( !fRet )
403408
{

src/Servers/IIS/AspNetCoreModuleV2/IISLib/multisz.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ BOOL MULTISZ::AuxAppend( const WCHAR * pStr, UINT cbStr, BOOL fAddSlop )
182182
//
183183

184184
//AcIncrement( CacMultiszAppend);
185-
186-
//
185+
186+
//
187187
// Check for the arithmetic overflow
188188
//
189189
// ( 2 * sizeof( WCHAR ) ) is for the double terminator
@@ -197,7 +197,7 @@ BOOL MULTISZ::AuxAppend( const WCHAR * pStr, UINT cbStr, BOOL fAddSlop )
197197
if ( QuerySize() < (DWORD) cb64Required )
198198
{
199199
ULONGLONG cb64AllocSize = cb64Required + (fAddSlop ? STR_SLOP : 0 );
200-
//
200+
//
201201
// Check for the arithmetic overflow
202202
//
203203
if ( cb64AllocSize > MAXULONG )
@@ -310,7 +310,7 @@ MULTISZ::CopyToBuffer( __out_ecount_opt(*lpcch) WCHAR * lpszBuffer, LPDWORD lpcc
310310
return ( FALSE);
311311
}
312312

313-
register DWORD cch = QueryCCH();
313+
DWORD cch = QueryCCH();
314314

315315
if ( *lpcch >= cch) {
316316

@@ -397,7 +397,7 @@ Return Value:
397397
hr = HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
398398
goto Finished;
399399
}
400-
400+
401401
pmszList->Reset();
402402

403403
/*
@@ -409,7 +409,7 @@ Return Value:
409409
410410
pszEnd: just past the end of the current entry
411411
*/
412-
412+
413413
for ( PCWSTR pszCurrent = pszList,
414414
pszNext = wcschr( pszCurrent, L',' )
415415
;
@@ -449,7 +449,7 @@ Return Value:
449449
goto Finished;
450450
}
451451
}
452-
452+
453453
if ( pszNext == NULL )
454454
{
455455
break;

src/Servers/IIS/AspNetCoreModuleV2/IISLib/percpu.h

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -115,20 +115,23 @@ PER_CPU<T>::Create(
115115
ObjectCacheLineSize = CacheLineSize;
116116
}
117117

118-
//
119-
// Calculate the size of the PER_CPU<T> object, including the array.
120-
// The first cache line is for the member variables and the array
121-
// starts in the next cache line.
122-
//
123-
SIZE_T Size = CacheLineSize + NumberOfProcessors * ObjectCacheLineSize;
124-
125-
pInstance = (PER_CPU<T>*) _aligned_malloc(Size, CacheLineSize);
126-
if (pInstance == NULL)
127118
{
128-
hr = E_OUTOFMEMORY;
129-
goto Finished;
119+
//
120+
// Calculate the size of the PER_CPU<T> object, including the array.
121+
// The first cache line is for the member variables and the array
122+
// starts in the next cache line.
123+
//
124+
SIZE_T Size = CacheLineSize + NumberOfProcessors * ObjectCacheLineSize;
125+
126+
pInstance = (PER_CPU<T>*) _aligned_malloc(Size, CacheLineSize);
127+
if (pInstance == NULL)
128+
{
129+
hr = E_OUTOFMEMORY;
130+
goto Finished;
131+
}
132+
133+
ZeroMemory(pInstance, Size);
130134
}
131-
ZeroMemory(pInstance, Size);
132135

133136
//
134137
// The array start in the 2nd cache line.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Copyright (c) .NET Foundation. All rights reserved.
2+
// Licensed under the MIT License. See License.txt in the project root for license information.

0 commit comments

Comments
 (0)