Fix VS Code Analysis issues (except misc.c)

This commit is contained in:
Calcitem 2021-01-02 16:40:35 +08:00
parent 46e5d573e4
commit 25a71d0a7d
3 changed files with 12 additions and 3 deletions

View File

@ -63,7 +63,9 @@ extern Bitboard StarSquareBB12;
inline Bitboard square_bb(Square s)
{
assert(SQ_BEGIN <= s && s < SQ_END);
if (!(SQ_BEGIN <= s && s < SQ_END))
return 0;
return SquareBB[s];
}

View File

@ -545,6 +545,8 @@ int best_group(size_t idx)
// Early exit if the needed API is not available at runtime
HMODULE k32 = GetModuleHandle(L"Kernel32.dll");
if (k32 == nullptr)
return -1;
auto fun1 = (fun1_t)(void(*)())GetProcAddress(k32, "GetLogicalProcessorInformationEx");
if (!fun1)
return -1;
@ -557,6 +559,9 @@ int best_group(size_t idx)
SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *buffer, *ptr;
ptr = buffer = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)malloc(returnLength);
if (ptr == nullptr)
return -1;
// Second call, now we expect to succeed
if (!fun1(RelationAll, buffer, &returnLength)) {
free(buffer);
@ -611,6 +616,8 @@ void bindThisThread(size_t idx)
// Early exit if the needed API are not available at runtime
HMODULE k32 = GetModuleHandle(L"Kernel32.dll");
if (k32 == nullptr)
return;
auto fun2 = (fun2_t)(void(*)())GetProcAddress(k32, "GetNumaNodeProcessorMaskEx");
auto fun3 = (fun3_t)(void(*)())GetProcAddress(k32, "SetThreadGroupAffinity");

View File

@ -1083,7 +1083,7 @@ int Position::potential_mills_count(Square to, Color c, Square from)
c = color_on(to);
}
if (from != SQ_0) {
if (from != SQ_0 && from >= SQ_BEGIN && from < SQ_END) {
locbak = board[from];
board[from] = NO_PIECE;
@ -1101,7 +1101,7 @@ int Position::potential_mills_count(Square to, Color c, Square from)
}
}
if (from != SQ_0) {
if (from != SQ_0 && from >= SQ_BEGIN && from < SQ_END) {
board[from] = locbak;
SET_BIT(byTypeBB[ALL_PIECES], from);