Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Wbitwise-instead-of-logical in native tests #72313

Merged
merged 1 commit into from
Jul 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions src/tests/Common/Platform/platformdefines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ error_t TP_getenv_s(size_t* pReturnValue, LPWSTR buffer, size_t sizeInWords, LPC
if (NULL == pReturnValue || NULL == varname) return 1;

#ifdef WINDOWS

size_t returnValue;
WCHAR buf[100];
if( 0 != _wgetenv_s(&returnValue, buf, 100, varname) || returnValue<=0 )
return 2;


TP_scpy_s(buffer, sizeInWords, (LPWSTR)buf);
#else
LPSTR pRet;
Expand Down Expand Up @@ -337,13 +337,13 @@ HRESULT ULongLongToULong(ULONGLONG ullOperand, ULONG* pulResult)
{
HRESULT hr = INTSAFE_E_ARITHMETIC_OVERFLOW;
*pulResult = ULONG_ERROR;

if (ullOperand <= UINT32_MAX)
{
*pulResult = (ULONG)ullOperand;
hr = S_OK;
}

return hr;
}

Expand All @@ -357,16 +357,16 @@ HRESULT ULongAdd(ULONG ulAugend, ULONG ulAddend,ULONG* pulResult)
*pulResult = (ulAugend + ulAddend);
hr = S_OK;
}

return hr;
}

HRESULT ULongMult(ULONG ulMultiplicand, ULONG ulMultiplier, ULONG* pulResult)
{
ULONGLONG ull64Result = UInt32x32To64(ulMultiplicand, ulMultiplier);

return ULongLongToULong(ull64Result, pulResult);
}
}

HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
{
Expand All @@ -388,7 +388,7 @@ HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)
else
{
ULONG temp = 0; // should not use in-place addition in ULongAdd
if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) &
if (SUCCEEDED(ULongMult(cchSize, sizeof(WCHAR), &temp)) &&
SUCCEEDED(ULongAdd(temp, constant, result)))
{
*result = *result & ~WIN32_ALLOC_ALIGN;
Expand All @@ -400,7 +400,7 @@ HRESULT CbSysStringSize(ULONG cchSize, BOOL isByteLen, ULONG *result)

BSTR TP_SysAllocString(LPCWSTR psz)
{
#ifdef WINDOWS
#ifdef WINDOWS
return SysAllocString(psz);
#else
if(psz == NULL)
Expand All @@ -422,7 +422,7 @@ BSTR CoreClrBStrAlloc(LPCWSTR psz, size_t len)

#if defined(HOST_64BIT)
// NOTE: There are some apps which peek back 4 bytes to look at the size of the BSTR. So, in case of 64-bit code,
// we need to ensure that the BSTR length can be found by looking one DWORD before the BSTR pointer.
// we need to ensure that the BSTR length can be found by looking one DWORD before the BSTR pointer.
*(DWORD_PTR *)bstr = (DWORD_PTR) 0;
bstr = (BSTR) ((char *) bstr + sizeof (DWORD));
#endif
Expand All @@ -437,12 +437,12 @@ BSTR CoreClrBStrAlloc(LPCWSTR psz, size_t len)
bstr[len] = '\0'; // always 0 terminate
}

return bstr;
return bstr;
}

BSTR CoreClrBStrAlloc(LPCSTR psz, size_t len)
{
#ifdef WINDOWS
#ifdef WINDOWS
return SysAllocStringByteLen(psz, (UINT)len);
#else
BSTR bstr;
Expand Down Expand Up @@ -472,25 +472,25 @@ BSTR CoreClrBStrAlloc(LPCSTR psz, size_t len)
}

return bstr;
#endif
#endif
}

void CoreClrBStrFree(BSTR bstr)
{
#ifdef WINDOWS
#ifdef WINDOWS
return SysFreeString(bstr);
#else
if (bstr == NULL)
return;
CoreClrFree((BYTE *)bstr - sizeof(DWORD_PTR));
#endif
CoreClrFree((BYTE *)bstr - sizeof(DWORD_PTR));
#endif
}

size_t TP_SysStringByteLen(BSTR bstr)
{
#ifdef WINDOWS
#ifdef WINDOWS
return SysStringByteLen(bstr);
#else
#else
if(bstr == NULL)
return 0;
int32_t * p32 = (int32_t *) bstr;
Expand All @@ -500,7 +500,7 @@ size_t TP_SysStringByteLen(BSTR bstr)
//std::cout << p32 << p32_1 << endl;
//std::cout << d32 << d32_1 << endl;
return (unsigned int)(((DWORD *)bstr)[-1]);
#endif
#endif
}

size_t TP_SysStringLen(BSTR bstr)
Expand All @@ -517,7 +517,7 @@ size_t TP_SysStringLen(BSTR bstr)
size_t TP_strncpy_s(char* strDest, size_t numberOfElements, const char *strSource, size_t count)
{
// NOTE: Need to pass count + 1 since strncpy_s does not count null,
// while snprintf does.
// while snprintf does.
return snprintf(strDest, count + 1, "%s", strSource);
}

Expand Down