Skip to content

Commit 35d957a

Browse files
Merge pull request #58304 from adityamandaleeka/ancm_ca_changes_incr
Enable code analysis and address initial set of issues.
2 parents 7f85154 + c1752f6 commit 35d957a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+861
-1003
lines changed

src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/applicationinfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ APPLICATION_INFO::HandleShadowCopy(const ShimOptions& options, IHttpContext& pHt
301301
auto shadowCopyBaseDirectory = std::filesystem::directory_entry(shadowCopyPath);
302302
if (!shadowCopyBaseDirectory.exists())
303303
{
304-
CreateDirectory(shadowCopyBaseDirectory.path().wstring().c_str(), NULL);
304+
CreateDirectory(shadowCopyBaseDirectory.path().wstring().c_str(), nullptr);
305305
}
306306

307307
for (auto& entry : std::filesystem::directory_iterator(shadowCopyPath))

src/Servers/IIS/AspNetCoreModuleV2/AspNetCore/dllmain.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ BOOL WINAPI DllMain(HMODULE hModule,
5757
// this is a bug in IIS. To try to avoid AVs, we will set a global flag
5858
g_fInShutdown = TRUE;
5959
StaticCleanup();
60+
break;
6061
default:
6162
break;
6263
}

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/ServerErrorHandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class ServerErrorHandler : public REQUEST_HANDLER
1515
m_disableStartupPage(disableStartupPage),
1616
m_statusCode(statusCode),
1717
m_subStatusCode(subStatusCode),
18-
m_statusText(std::move(statusText)),
18+
m_statusText(statusText),
1919
m_ExceptionInfoContent(responseContent)
2020
{
2121
}

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, _countof(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
{

0 commit comments

Comments
 (0)