Skip to content

Commit 7368d59

Browse files
[MERGE #5272 @Penguinwizzard] Address issues picked up by Dev15 code analysis
Merge pull request #5272 from Penguinwizzard:dev15_prefast_fixes This is one of the things that was preventing us from moving our jenkins CI to dev15.
2 parents 91bc9c5 + 02a471a commit 7368d59

File tree

73 files changed

+239
-117
lines changed

Some content is hidden

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

73 files changed

+239
-117
lines changed

bin/External/catch.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7374,7 +7374,7 @@ namespace Catch {
73747374
return TestCaseInfo::None;
73757375
}
73767376
inline bool isReservedTag( std::string const& tag ) {
7377-
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( tag[0] );
7377+
return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !isalnum( (unsigned char)tag[0] );
73787378
}
73797379
inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {
73807380
if( isReservedTag( tag ) ) {

bin/GCStress/StubExternalApi.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
bool ConfigParserAPI::FillConsoleTitle(__ecount(cchBufferSize) LPWSTR buffer, size_t cchBufferSize, __in LPWSTR moduleName)
1111
{
12-
swprintf_s(buffer, cchBufferSize, _u("Chakra GC: %d - %s"), GetCurrentProcessId(), moduleName);
12+
swprintf_s(buffer, cchBufferSize, _u("Chakra GC: %lu - %s"), GetCurrentProcessId(), moduleName);
1313

1414
return true;
1515
}

bin/GCStress/WeightedTable.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@ template <class T>
1313
class WeightedTable
1414
{
1515
public:
16-
WeightedTable() :
16+
WeightedTable() noexcept :
1717
entries(nullptr), size(0)
1818
{
1919
}
2020

2121
void AddWeightedEntry(T value, unsigned int weight)
2222
{
23-
T * newEntries = static_cast<T *>(realloc(entries, (size + weight) * sizeof(T)));
23+
T * newEntries = static_cast<T *>(realloc(entries, ((size_t)size + weight) * sizeof(T)));
2424
if (newEntries == nullptr)
2525
{
2626
// Should throw something better

bin/NativeTests/CodexTests.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
6+
#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
7+
#pragma warning(disable:26439) // Implicit noexcept
8+
#pragma warning(disable:26451) // Arithmetic overflow
9+
#pragma warning(disable:26495) // Uninitialized member variable
610
#include "catch.hpp"
711
#include <process.h>
812
#include "Codex\Utf8Codex.h"
@@ -280,4 +284,4 @@ namespace CodexTest
280284

281285
RunUtf8DecodeTestCase(testCases, utf8::DecodeUnitsIntoAndNullTerminateNoAdvance);
282286
}
283-
};
287+
};

bin/NativeTests/FileLoadHelpers.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ HRESULT FileLoadHelpers::LoadScriptFromFile(LPCSTR filename, LPCWSTR& contents,
114114
utf8::DecodeOptions decodeOptions = utf8::doAllowInvalidWCHARs;
115115

116116
UINT cUtf16Chars = utf8::ByteIndexIntoCharacterIndex(pRawBytes, lengthBytes, decodeOptions);
117-
contents = (LPCWSTR)HeapAlloc(GetProcessHeap(), 0, (cUtf16Chars + 1) * sizeof(WCHAR));
117+
contents = (LPCWSTR)HeapAlloc(GetProcessHeap(), 0, (cUtf16Chars + (size_t)1) * sizeof(WCHAR));
118118
if (nullptr == contents)
119119
{
120120
fwprintf(stderr, _u("out of memory"));

bin/NativeTests/FunctionExecutionTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
6+
#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
7+
#pragma warning(disable:26439) // Implicit noexcept
8+
#pragma warning(disable:26451) // Arithmetic overflow
9+
#pragma warning(disable:26495) // Uninitialized member variable
610
#include "catch.hpp"
711
#include "FunctionExecutionTest.h"
812

bin/NativeTests/FunctionExecutionTest.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
// This file contains stubs needed to make FunctionExecutionTest successfully compile and link as well
77
// as a means to emulate behavior of objects that interact with FunctionExecutionStateMachine
88

9+
#include "..\..\lib\Common\Warnings.h"
910
#include "..\..\lib\Common\Core\CommonMinMax.h"
1011

1112
#define ENUM_CLASS_HELPERS(x, y)

bin/NativeTests/JsDiagApiTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
//-------------------------------------------------------------------------------------------------------
55

66
#include "stdafx.h"
7+
#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
8+
#pragma warning(disable:26439) // Implicit noexcept
9+
#pragma warning(disable:26451) // Arithmetic overflow
10+
#pragma warning(disable:26495) // Uninitialized member variable
711
#include "catch.hpp"
812
#include <process.h>
913

bin/NativeTests/JsRTApiTest.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
6+
#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
7+
#pragma warning(disable:26439) // Implicit noexcept
8+
#pragma warning(disable:26451) // Arithmetic overflow
9+
#pragma warning(disable:26495) // Uninitialized member variable
610
#include "catch.hpp"
711
#include <array>
812
#include <process.h>
13+
#include <suppress.h>
914

1015
#pragma warning(disable:4100) // unreferenced formal parameter
1116
#pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs
@@ -1243,7 +1248,8 @@ namespace JsRTApiTest
12431248
size_t length;
12441249
REQUIRE(JsStringToPointer(nameValue, &name, &length) == JsNoError);
12451250

1246-
CHECK(length == 1);
1251+
REQUIRE(length == 1);
1252+
#pragma prefast(suppress:__WARNING_MAYBE_UNINIT_VAR, "The require on the previous line should ensure that name[0] is initialized")
12471253
CHECK(name[0] == ('a' + index));
12481254
}
12491255
}

bin/NativeTests/MemoryPolicyTest.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
// Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
44
//-------------------------------------------------------------------------------------------------------
55
#include "stdafx.h"
6+
#pragma warning(disable:26434) // Function definition hides non-virtual function in base class
7+
#pragma warning(disable:26439) // Implicit noexcept
8+
#pragma warning(disable:26451) // Arithmetic overflow
9+
#pragma warning(disable:26495) // Uninitialized member variable
610
#include "catch.hpp"
711

812
#pragma warning(disable:6387) // suppressing preFAST which raises warning for passing null to the JsRT APIs

0 commit comments

Comments
 (0)