Skip to content

Commit 321c2aa

Browse files
Enable CA for CommonLib and address additional errors.
1 parent 0a62055 commit 321c2aa

File tree

9 files changed

+36
-31
lines changed

9 files changed

+36
-31
lines changed

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/CommonLib.vcxproj

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3-
<Import Project="..\..\build\Build.Lib.Settings" />
43
<PropertyGroup Label="Globals">
54
<ProjectGuid>{55494E58-E061-4C4C-A0A8-837008E72F85}</ProjectGuid>
65
<RootNamespace>NewCommon</RootNamespace>
7-
<RunCodeAnalysis>false</RunCodeAnalysis>
86
</PropertyGroup>
7+
<Import Project="..\..\build\Build.Lib.Settings" />
98
<ItemDefinitionGroup>
109
<ClCompile>
1110
<AdditionalIncludeDirectories>..\iislib;$(LibNetHostPath)</AdditionalIncludeDirectories>

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/Environment.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ void Environment::CopyToDirectoryInner(const std::filesystem::path& source, cons
168168
auto destinationDirEntry = std::filesystem::directory_entry(destination);
169169
if (!destinationDirEntry.exists())
170170
{
171-
CreateDirectory(destination.wstring().c_str(), NULL);
171+
CreateDirectory(destination.wstring().c_str(), nullptr);
172172
}
173173

174174
for (auto& path : std::filesystem::directory_iterator(source))

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/EventLog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,11 @@ EventLog::LogEventNoTrace(
3636
dwEventInfoType,
3737
0, // wCategory
3838
dwEventId,
39-
NULL, // lpUserSid
39+
nullptr, // lpUserSid
4040
static_cast<WORD>(eventLogDataStrings.size()), // wNumStrings
4141
0, // dwDataSize,
4242
eventLogDataStrings.data(),
43-
NULL // lpRawData
43+
nullptr // lpRawData
4444
);
4545
}
4646

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/GlobalVersionUtility.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ namespace fs = std::filesystem;
1313
std::wstring
1414
GlobalVersionUtility::GetGlobalRequestHandlerPath(PCWSTR pwzAspNetCoreFolderPath, PCWSTR pwzHandlerVersion, PCWSTR pwzHandlerName)
1515
{
16-
if (pwzAspNetCoreFolderPath == NULL)
16+
if (pwzAspNetCoreFolderPath == nullptr)
1717
{
1818
throw new std::invalid_argument("pwzAspNetCoreFolderPath is NULL");
1919
}
2020

21-
if (pwzHandlerVersion == NULL)
21+
if (pwzHandlerVersion == nullptr)
2222
{
2323
throw new std::invalid_argument("pwzHandlerVersion is NULL");
2424
}
2525

26-
if (pwzHandlerName == NULL)
26+
if (pwzHandlerName == nullptr)
2727
{
2828
throw new std::invalid_argument("pwzHandlerName is NULL");
2929
}
@@ -47,7 +47,7 @@ GlobalVersionUtility::GetGlobalRequestHandlerPath(PCWSTR pwzAspNetCoreFolderPath
4747
std::vector<fx_ver_t>
4848
GlobalVersionUtility::GetRequestHandlerVersions(PCWSTR pwzAspNetCoreFolderPath)
4949
{
50-
if (pwzAspNetCoreFolderPath == NULL)
50+
if (pwzAspNetCoreFolderPath == nullptr)
5151
{
5252
throw new std::invalid_argument("pwzAspNetCoreFolderPath is NULL");
5353
}
@@ -74,7 +74,7 @@ GlobalVersionUtility::GetRequestHandlerVersions(PCWSTR pwzAspNetCoreFolderPath)
7474
std::wstring
7575
GlobalVersionUtility::FindHighestGlobalVersion(PCWSTR pwzAspNetCoreFolderPath)
7676
{
77-
if (pwzAspNetCoreFolderPath == NULL)
77+
if (pwzAspNetCoreFolderPath == nullptr)
7878
{
7979
throw std::invalid_argument("pwzAspNetCoreFolderPath is NULL");
8080
}

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/HostFxrResolver.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -400,16 +400,16 @@ HostFxrResolver::InvokeWhereToFindDotnet()
400400
{
401401
HRESULT hr = S_OK;
402402
// Arguments to call where.exe
403-
STARTUPINFOW startupInfo = { 0 };
404-
PROCESS_INFORMATION processInformation = { 0 };
403+
STARTUPINFOW startupInfo{};
404+
PROCESS_INFORMATION processInformation{};
405405
SECURITY_ATTRIBUTES securityAttributes;
406406

407407
CHAR pzFileContents[READ_BUFFER_SIZE];
408408
HandleWrapper<InvalidHandleTraits> hStdOutReadPipe;
409409
HandleWrapper<InvalidHandleTraits> hStdOutWritePipe;
410410
HandleWrapper<InvalidHandleTraits> hProcess;
411411
HandleWrapper<InvalidHandleTraits> hThread;
412-
CComBSTR pwzDotnetName = NULL;
412+
CComBSTR pwzDotnetName = nullptr;
413413
DWORD dwFilePointer;
414414
BOOL fIsCurrentProcess64Bit;
415415
DWORD dwExitCode;
@@ -423,7 +423,7 @@ HostFxrResolver::InvokeWhereToFindDotnet()
423423

424424
// Set the security attributes for the read/write pipe
425425
securityAttributes.nLength = sizeof(securityAttributes);
426-
securityAttributes.lpSecurityDescriptor = NULL;
426+
securityAttributes.lpSecurityDescriptor = nullptr;
427427
securityAttributes.bInheritHandle = TRUE;
428428

429429
LOG_INFO(L"Invoking where.exe to find dotnet.exe");
@@ -443,14 +443,14 @@ HostFxrResolver::InvokeWhereToFindDotnet()
443443
pwzDotnetName = L"\"where.exe\" dotnet.exe";
444444

445445
// Create a process to invoke where.exe
446-
FINISHED_LAST_ERROR_IF(!CreateProcessW(NULL,
446+
FINISHED_LAST_ERROR_IF(!CreateProcessW(nullptr,
447447
pwzDotnetName,
448-
NULL,
449-
NULL,
448+
nullptr,
449+
nullptr,
450450
TRUE,
451451
CREATE_NO_WINDOW,
452-
NULL,
453-
NULL,
452+
nullptr,
453+
nullptr,
454454
&startupInfo,
455455
&processInformation
456456
));
@@ -480,7 +480,7 @@ HostFxrResolver::InvokeWhereToFindDotnet()
480480

481481
// Where succeeded.
482482
// Reset file pointer to the beginning of the file.
483-
dwFilePointer = SetFilePointer(hStdOutReadPipe, 0, NULL, FILE_BEGIN);
483+
dwFilePointer = SetFilePointer(hStdOutReadPipe, 0, nullptr, FILE_BEGIN);
484484
if (dwFilePointer == INVALID_SET_FILE_POINTER)
485485
{
486486
FINISHED_IF_FAILED(E_FAIL);
@@ -490,7 +490,7 @@ HostFxrResolver::InvokeWhereToFindDotnet()
490490
// As the call to where.exe succeeded (dotnet.exe was found), ReadFile should not hang.
491491
// TODO consider putting ReadFile in a separate thread with a timeout to guarantee it doesn't block.
492492
//
493-
FINISHED_LAST_ERROR_IF (!ReadFile(hStdOutReadPipe, pzFileContents, READ_BUFFER_SIZE, &dwNumBytesRead, NULL));
493+
FINISHED_LAST_ERROR_IF (!ReadFile(hStdOutReadPipe, pzFileContents, READ_BUFFER_SIZE, &dwNumBytesRead, nullptr));
494494

495495
if (dwNumBytesRead >= READ_BUFFER_SIZE)
496496
{

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/RegistryKey.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ std::optional<DWORD> RegistryKey::TryGetDWORD(HKEY section, const std::wstring&
1818

1919
std::optional<std::wstring> RegistryKey::TryGetString(HKEY section, const std::wstring& subSectionName, const std::wstring& valueName)
2020
{
21-
DWORD cbData;
21+
DWORD cbData{};
2222

2323
if (!CheckReturnValue(RegGetValue(section, subSectionName.c_str(), valueName.c_str(), RRF_RT_REG_SZ, nullptr, nullptr, &cbData)))
2424
{

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/StringHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ std::wstring to_wide_string(const std::string& source, const int length, const u
4141

4242
std::wstring destination;
4343

44-
int nChars = MultiByteToWideChar(codePage, 0, source.data(), length, NULL, 0);
44+
int nChars = MultiByteToWideChar(codePage, 0, source.data(), length, nullptr, 0);
4545
THROW_LAST_ERROR_IF(nChars == 0);
4646

4747
destination.resize(nChars);

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/debugutil.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ GetVersionInfoString()
7373
{
7474
DWORD verHandle = 0;
7575
UINT size = 0;
76-
LPVOID lpBuffer = NULL;
76+
LPVOID lpBuffer = nullptr;
7777

7878
auto path = GetModuleName();
7979

@@ -92,7 +92,7 @@ GetVersionInfoString()
9292
RETURN_IF_FAILED(E_FAIL);
9393
}
9494

95-
LPVOID pvProductName = NULL;
95+
LPVOID pvProductName = nullptr;
9696
unsigned int iProductNameLen = 0;
9797
RETURN_LAST_ERROR_IF(!VerQueryValue(verData.data(), _T("\\StringFileInfo\\040904b0\\FileDescription"), &pvProductName, &iProductNameLen));
9898

@@ -114,7 +114,7 @@ std::wstring
114114
GetModuleName()
115115
{
116116
WCHAR path[MAX_PATH];
117-
LOG_LAST_ERROR_IF(!GetModuleFileName(g_hModule, path, sizeof(path)));
117+
LOG_LAST_ERROR_IF(!GetModuleFileName(g_hModule, path, MAX_PATH));
118118
return path;
119119
}
120120

@@ -218,7 +218,7 @@ DebugInitialize(HMODULE hModule)
218218
cbData = sizeof(dwData);
219219
if ((RegQueryValueEx(hKey,
220220
L"DebugFlags",
221-
NULL,
221+
nullptr,
222222
&dwType,
223223
(LPBYTE)&dwData,
224224
&cbData) == NO_ERROR) &&
@@ -409,7 +409,10 @@ DebugPrintfW(
409409

410410
hr = strCooked.SafeVsnwprintf(szFormat, args );
411411

412+
#pragma warning(push)
413+
#pragma warning(disable: 26477) // va_end uses 0
412414
va_end( args );
415+
#pragma warning(pop)
413416

414417
if (FAILED (hr))
415418
{
@@ -453,7 +456,10 @@ DebugPrintf(
453456

454457
hr = strCooked.SafeVsnprintf(szFormat, args );
455458

459+
#pragma warning(push)
460+
#pragma warning(disable: 26477) // va_end uses 0
456461
va_end( args );
462+
#pragma warning(pop)
457463

458464
if (FAILED (hr))
459465
{

src/Servers/IIS/AspNetCoreModuleV2/CommonLib/file_utility.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ FILE_UTILITY::ConvertPathToFullPath(
4141
{
4242
HRESULT hr = S_OK;
4343
STRU strFileFullPath;
44-
LPWSTR pszFullPath = NULL;
44+
LPWSTR pszFullPath = nullptr;
4545

4646
// if relative path, prefix with root path and then convert to absolute path.
4747
if ( PathIsRelative(pszPath) )
@@ -72,7 +72,7 @@ FILE_UTILITY::ConvertPathToFullPath(
7272

7373
if(_wfullpath( pszFullPath,
7474
strFileFullPath.QueryStr(),
75-
strFileFullPath.QueryCCH() + 1 ) == NULL )
75+
strFileFullPath.QueryCCH() + 1 ) == nullptr )
7676
{
7777
hr = HRESULT_FROM_WIN32( ERROR_INVALID_PARAMETER );
7878
goto Finished;
@@ -87,10 +87,10 @@ FILE_UTILITY::ConvertPathToFullPath(
8787

8888
Finished:
8989

90-
if ( pszFullPath != NULL )
90+
if ( pszFullPath != nullptr )
9191
{
9292
delete[] pszFullPath;
93-
pszFullPath = NULL;
93+
pszFullPath = nullptr;
9494
}
9595

9696
return hr;

0 commit comments

Comments
 (0)