Merge pull request #5563 from akallabeth/scanbuild_fixes
Scanbuild fixes
This commit is contained in:
commit
c90b7a9714
@ -1438,7 +1438,7 @@ static DWORD WINAPI cliprdr_server_thread(LPVOID arg)
|
||||
HANDLE ChannelEvent;
|
||||
CliprdrServerContext* context = (CliprdrServerContext*) arg;
|
||||
CliprdrServerPrivate* cliprdr = (CliprdrServerPrivate*) context->handle;
|
||||
UINT error;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
ChannelEvent = context->GetEventHandle(context);
|
||||
nCount = 0;
|
||||
|
@ -1447,7 +1447,7 @@ static UINT xf_cliprdr_server_format_data_response(CliprdrClientContext*
|
||||
ClipboardGetFormatName(clipboard->system, srcFormatId));
|
||||
}
|
||||
|
||||
if (nullTerminated)
|
||||
if (nullTerminated && pDstData)
|
||||
{
|
||||
BYTE* nullTerminator = memchr(pDstData, '\0', DstSize);
|
||||
if (nullTerminator)
|
||||
|
@ -42,7 +42,7 @@ int main(int argc, char* argv[])
|
||||
cfg = argv[1];
|
||||
|
||||
if (!pf_modules_init())
|
||||
return FALSE;
|
||||
goto fail;
|
||||
|
||||
if (!pf_server_config_load(cfg, config))
|
||||
goto fail;
|
||||
|
@ -47,96 +47,104 @@ typedef struct _wBitStream wBitStream;
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define BitStream_Prefetch(_bs) do { \
|
||||
(_bs->prefetch) = 0; \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 4) < (_bs->capacity)) \
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 4) << 24); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 5) < (_bs->capacity)) \
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 5) << 16); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 6) < (_bs->capacity)) \
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 6) << 8); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 7) < (_bs->capacity)) \
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 7) << 0); \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Prefetch(wBitStream* _bs)
|
||||
{
|
||||
(_bs->prefetch) = 0;
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 4) < (_bs->capacity))
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 4) << 24);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 5) < (_bs->capacity))
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 5) << 16);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 6) < (_bs->capacity))
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 6) << 8);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 7) < (_bs->capacity))
|
||||
(_bs->prefetch) |= (*(_bs->pointer + 7) << 0);
|
||||
}
|
||||
|
||||
#define BitStream_Fetch(_bs) do { \
|
||||
(_bs->accumulator) = 0; \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 0) < (_bs->capacity)) \
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 0) << 24); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 1) < (_bs->capacity)) \
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 1) << 16); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 2) < (_bs->capacity)) \
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 2) << 8); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 3) <(_bs->capacity)) \
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 3) << 0); \
|
||||
BitStream_Prefetch(_bs); \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Fetch(wBitStream* _bs)
|
||||
{
|
||||
(_bs->accumulator) = 0;
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 0) < (_bs->capacity))
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 0) << 24);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 1) < (_bs->capacity))
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 1) << 16);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 2) < (_bs->capacity))
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 2) << 8);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 3) <(_bs->capacity))
|
||||
(_bs->accumulator) |= (*(_bs->pointer + 3) << 0);
|
||||
BitStream_Prefetch(_bs);
|
||||
}
|
||||
|
||||
#define BitStream_Flush(_bs) do { \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 0) < (_bs->capacity)) \
|
||||
*(_bs->pointer + 0) = (_bs->accumulator >> 24); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 1) < (_bs->capacity)) \
|
||||
*(_bs->pointer + 1) = (_bs->accumulator >> 16); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 2) < (_bs->capacity)) \
|
||||
*(_bs->pointer + 2) = (_bs->accumulator >> 8); \
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 3) < (_bs->capacity)) \
|
||||
*(_bs->pointer + 3) = (_bs->accumulator >> 0); \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Flush(wBitStream* _bs)
|
||||
{
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 0) < (_bs->capacity))
|
||||
*(_bs->pointer + 0) = (_bs->accumulator >> 24);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 1) < (_bs->capacity))
|
||||
*(_bs->pointer + 1) = (_bs->accumulator >> 16);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 2) < (_bs->capacity))
|
||||
*(_bs->pointer + 2) = (_bs->accumulator >> 8);
|
||||
if (((UINT32) (_bs->pointer - _bs->buffer) + 3) < (_bs->capacity))
|
||||
*(_bs->pointer + 3) = (_bs->accumulator >> 0);
|
||||
}
|
||||
|
||||
#define BitStream_Shift(_bs, _nbits) do { \
|
||||
if (_nbits == 0) { \
|
||||
} else if ((_nbits > 0) && (_nbits < 32)) { \
|
||||
_bs->accumulator <<= _nbits; \
|
||||
_bs->position += _nbits; \
|
||||
_bs->offset += _nbits; \
|
||||
if (_bs->offset < 32) { \
|
||||
_bs->mask = ((1 << _nbits) - 1); \
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask); \
|
||||
_bs->prefetch <<= _nbits; \
|
||||
} else { \
|
||||
_bs->mask = ((1 << _nbits) - 1); \
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask); \
|
||||
_bs->prefetch <<= _nbits; \
|
||||
_bs->offset -= 32; \
|
||||
_bs->pointer += 4; \
|
||||
BitStream_Prefetch(_bs); \
|
||||
if (_bs->offset) { \
|
||||
_bs->mask = ((1 << _bs->offset) - 1); \
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _bs->offset)) & _bs->mask); \
|
||||
_bs->prefetch <<= _bs->offset; \
|
||||
} \
|
||||
} \
|
||||
} else { \
|
||||
WLog_WARN("com.winpr.bitstream", "warning: BitStream_Shift(%u)", (unsigned)_nbits); \
|
||||
} \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Shift(wBitStream* _bs, UINT32 _nbits)
|
||||
{
|
||||
if (_nbits == 0) {
|
||||
} else if ((_nbits > 0) && (_nbits < 32)) {
|
||||
_bs->accumulator <<= _nbits;
|
||||
_bs->position += _nbits;
|
||||
_bs->offset += _nbits;
|
||||
if (_bs->offset < 32) {
|
||||
_bs->mask = ((1 << _nbits) - 1);
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask);
|
||||
_bs->prefetch <<= _nbits;
|
||||
} else {
|
||||
_bs->mask = ((1 << _nbits) - 1);
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask);
|
||||
_bs->prefetch <<= _nbits;
|
||||
_bs->offset -= 32;
|
||||
_bs->pointer += 4;
|
||||
BitStream_Prefetch(_bs);
|
||||
if (_bs->offset) {
|
||||
_bs->mask = ((1 << _bs->offset) - 1);
|
||||
_bs->accumulator |= ((_bs->prefetch >> (32 - _bs->offset)) & _bs->mask);
|
||||
_bs->prefetch <<= _bs->offset;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
WLog_WARN("com.winpr.bitstream", "warning: BitStream_Shift(%u)", (unsigned)_nbits);
|
||||
}
|
||||
}
|
||||
|
||||
#define BitStream_Shift32(_bs) do { \
|
||||
BitStream_Shift(_bs, 16); \
|
||||
BitStream_Shift(_bs, 16); \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Shift32(wBitStream* _bs)
|
||||
{
|
||||
BitStream_Shift(_bs, 16);
|
||||
BitStream_Shift(_bs, 16);
|
||||
}
|
||||
|
||||
#define BitStream_Write_Bits(_bs, _bits, _nbits) do { \
|
||||
_bs->position += _nbits; \
|
||||
_bs->offset += _nbits; \
|
||||
if (_bs->offset < 32) { \
|
||||
_bs->accumulator |= (_bits << (32 - _bs->offset)); \
|
||||
} else { \
|
||||
_bs->offset -= 32; \
|
||||
_bs->mask = ((1 << (_nbits - _bs->offset)) - 1); \
|
||||
_bs->accumulator |= ((_bits >> _bs->offset) & _bs->mask); \
|
||||
BitStream_Flush(bs); \
|
||||
_bs->accumulator = 0; \
|
||||
_bs->pointer += 4; \
|
||||
if (_bs->offset) { \
|
||||
_bs->mask = ((1 << _bs->offset) - 1); \
|
||||
_bs->accumulator |= ((_bits & _bs->mask) << (32 - _bs->offset)); \
|
||||
} \
|
||||
} \
|
||||
} while(0)
|
||||
static INLINE void BitStream_Write_Bits(wBitStream* _bs, UINT32 _bits, UINT32 _nbits)
|
||||
{
|
||||
_bs->position += _nbits;
|
||||
_bs->offset += _nbits;
|
||||
if (_bs->offset < 32) {
|
||||
_bs->accumulator |= (_bits << (32 - _bs->offset));
|
||||
} else {
|
||||
_bs->offset -= 32;
|
||||
_bs->mask = ((1 << (_nbits - _bs->offset)) - 1);
|
||||
_bs->accumulator |= ((_bits >> _bs->offset) & _bs->mask);
|
||||
BitStream_Flush(_bs);
|
||||
_bs->accumulator = 0;
|
||||
_bs->pointer += 4;
|
||||
if (_bs->offset) {
|
||||
_bs->mask = ((1 << _bs->offset) - 1);
|
||||
_bs->accumulator |= ((_bits & _bs->mask) << (32 - _bs->offset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#define BitStream_GetRemainingLength(_bs) \
|
||||
(_bs->length - _bs->position)
|
||||
static INLINE size_t BitStream_GetRemainingLength(wBitStream* _bs)
|
||||
{
|
||||
return (_bs->length - _bs->position);
|
||||
}
|
||||
|
||||
WINPR_API void BitDump(const char* tag, UINT32 level, const BYTE* buffer, UINT32 length, UINT32 flags);
|
||||
WINPR_API UINT32 ReverseBits32(UINT32 bits, UINT32 nbits);
|
||||
|
Loading…
Reference in New Issue
Block a user