[winpr] refactor complex expressions

* avoid unnecessary casts
This commit is contained in:
Armin Novak
2025-03-19 16:33:39 +01:00
committed by akallabeth
parent 9a1f455e02
commit b14f9e8965
8 changed files with 43 additions and 40 deletions

View File

@@ -53,42 +53,47 @@ extern "C"
WINPR_ASSERT(_bs);
(_bs->prefetch) = 0;
if (((UINT32)(_bs->pointer - _bs->buffer) + 4) < (_bs->capacity))
(_bs->prefetch) |= ((UINT32) * (_bs->pointer + 4) << 24);
if (((UINT32)(_bs->pointer - _bs->buffer) + 5) < (_bs->capacity))
(_bs->prefetch) |= ((UINT32) * (_bs->pointer + 5) << 16);
if (((UINT32)(_bs->pointer - _bs->buffer) + 6) < (_bs->capacity))
(_bs->prefetch) |= ((UINT32) * (_bs->pointer + 6) << 8);
if (((UINT32)(_bs->pointer - _bs->buffer) + 7) < (_bs->capacity))
(_bs->prefetch) |= ((UINT32) * (_bs->pointer + 7) << 0);
const intptr_t diff = _bs->pointer - _bs->buffer;
if ((diff + 4) < _bs->capacity)
(_bs->prefetch) |= ((UINT32)_bs->pointer[4] << 24);
if ((diff + 5) < _bs->capacity)
(_bs->prefetch) |= ((UINT32)_bs->pointer[5] << 16);
if ((diff + 6) < _bs->capacity)
(_bs->prefetch) |= ((UINT32)_bs->pointer[6] << 8);
if ((diff + 7) < _bs->capacity)
(_bs->prefetch) |= ((UINT32)_bs->pointer[7] << 0);
}
static INLINE void BitStream_Fetch(wBitStream* _bs)
{
WINPR_ASSERT(_bs);
(_bs->accumulator) = 0;
if (((UINT32)(_bs->pointer - _bs->buffer) + 0) < (_bs->capacity))
(_bs->accumulator) |= ((UINT32) * (_bs->pointer + 0) << 24);
if (((UINT32)(_bs->pointer - _bs->buffer) + 1) < (_bs->capacity))
(_bs->accumulator) |= ((UINT32) * (_bs->pointer + 1) << 16);
if (((UINT32)(_bs->pointer - _bs->buffer) + 2) < (_bs->capacity))
(_bs->accumulator) |= ((UINT32) * (_bs->pointer + 2) << 8);
if (((UINT32)(_bs->pointer - _bs->buffer) + 3) < (_bs->capacity))
(_bs->accumulator) |= ((UINT32) * (_bs->pointer + 3) << 0);
const intptr_t diff = _bs->pointer - _bs->buffer;
if ((diff + 0) < _bs->capacity)
(_bs->accumulator) |= ((UINT32)_bs->pointer[0] << 24);
if ((diff + 1) < _bs->capacity)
(_bs->accumulator) |= ((UINT32)_bs->pointer[1] << 16);
if ((diff + 2) < _bs->capacity)
(_bs->accumulator) |= ((UINT32)_bs->pointer[2] << 8);
if ((diff + 3) < _bs->capacity)
(_bs->accumulator) |= ((UINT32)_bs->pointer[3] << 0);
BitStream_Prefetch(_bs);
}
static INLINE void BitStream_Flush(wBitStream* _bs)
{
WINPR_ASSERT(_bs);
if (((UINT32)(_bs->pointer - _bs->buffer) + 0) < (_bs->capacity))
*(_bs->pointer + 0) = (BYTE)((UINT32)_bs->accumulator >> 24);
if (((UINT32)(_bs->pointer - _bs->buffer) + 1) < (_bs->capacity))
*(_bs->pointer + 1) = (BYTE)((UINT32)_bs->accumulator >> 16);
if (((UINT32)(_bs->pointer - _bs->buffer) + 2) < (_bs->capacity))
*(_bs->pointer + 2) = (BYTE)((UINT32)_bs->accumulator >> 8);
if (((UINT32)(_bs->pointer - _bs->buffer) + 3) < (_bs->capacity))
*(_bs->pointer + 3) = (BYTE)((UINT32)_bs->accumulator >> 0);
const intptr_t diff = _bs->pointer - _bs->buffer;
if ((diff + 0) < _bs->capacity)
_bs->pointer[0] = (BYTE)((UINT32)_bs->accumulator >> 24);
if ((diff + 1) < _bs->capacity)
_bs->pointer[1] = (BYTE)((UINT32)_bs->accumulator >> 16);
if ((diff + 2) < _bs->capacity)
_bs->pointer[2] = (BYTE)((UINT32)_bs->accumulator >> 8);
if ((diff + 3) < _bs->capacity)
_bs->pointer[3] = (BYTE)((UINT32)_bs->accumulator >> 0);
}
static INLINE void BitStream_Shift(wBitStream* _bs, UINT32 _nbits)

View File

@@ -24,7 +24,6 @@
#include <winpr/platform.h>
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#include <winpr/platform.h>
#ifdef __cplusplus
extern "C"

View File

@@ -41,7 +41,6 @@ typedef PCONTEXT_HANDLE PCHANNEL_CONTEXT_HANDLE_SERIALIZE;
#else
#include <winpr/winpr.h>
#include <winpr/wtypes.h>
#include <winpr/sspi.h>
#include <winpr/spec.h>
#include <winpr/error.h>

View File

@@ -110,10 +110,11 @@ extern "C"
#if !defined(_WIN32) || (defined(_WIN32) && (_WIN32_WINNT < 0x0602)) /* Windows 8 */
WINPR_API DWORD EnumDynamicTimeZoneInformation(
const DWORD dwIndex, PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
WINPR_API
DWORD EnumDynamicTimeZoneInformation(DWORD dwIndex,
PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation);
WINPR_API DWORD GetDynamicTimeZoneInformationEffectiveYears(
const PDYNAMIC_TIME_ZONE_INFORMATION lpTimeZoneInformation, LPDWORD FirstYear,
const DYNAMIC_TIME_ZONE_INFORMATION* lpTimeZoneInformation, LPDWORD FirstYear,
LPDWORD LastYear);
#else

View File

@@ -90,7 +90,6 @@ WINPR_API INT winpr_inet_pton(INT Family, PCSTR pszAddrString, PVOID pAddrBuf);
#include <winpr/io.h>
#include <winpr/error.h>
#include <winpr/platform.h>
#define WSAEVENT HANDLE
#define LPWSAEVENT LPHANDLE