Fixed compilation warnings

This commit is contained in:
Armin Novak 2021-06-16 12:58:21 +02:00 committed by akallabeth
parent 1b3adfae0a
commit f5bb6d12fc
15 changed files with 84 additions and 63 deletions

View File

@ -26,7 +26,7 @@
#include <winpr/wtypes.h>
#include <winpr/wlog.h>
#if WITH_VERBOSE_WINPR_ASSERT
#if defined(WITH_VERBOSE_WINPR_ASSERT) && (WITH_VERBOSE_WINPR_ASSERT != 0)
#define WINPR_ASSERT(cond) \
do \
{ \

View File

@ -78,13 +78,13 @@ extern "C"
static INLINE void BitStream_Flush(wBitStream* _bs)
{
if (((UINT32)(_bs->pointer - _bs->buffer) + 0) < (_bs->capacity))
*(_bs->pointer + 0) = ((UINT32)_bs->accumulator >> 24);
*(_bs->pointer + 0) = (BYTE)((UINT32)_bs->accumulator >> 24);
if (((UINT32)(_bs->pointer - _bs->buffer) + 1) < (_bs->capacity))
*(_bs->pointer + 1) = ((UINT32)_bs->accumulator >> 16);
*(_bs->pointer + 1) = (BYTE)((UINT32)_bs->accumulator >> 16);
if (((UINT32)(_bs->pointer - _bs->buffer) + 2) < (_bs->capacity))
*(_bs->pointer + 2) = ((UINT32)_bs->accumulator >> 8);
*(_bs->pointer + 2) = (BYTE)((UINT32)_bs->accumulator >> 8);
if (((UINT32)(_bs->pointer - _bs->buffer) + 3) < (_bs->capacity))
*(_bs->pointer + 3) = ((UINT32)_bs->accumulator >> 0);
*(_bs->pointer + 3) = (BYTE)((UINT32)_bs->accumulator >> 0);
}
static INLINE void BitStream_Shift(wBitStream* _bs, UINT32 _nbits)
@ -99,13 +99,13 @@ extern "C"
_bs->offset += _nbits;
if (_bs->offset < 32)
{
_bs->mask = ((1UL << _nbits) - 1);
_bs->mask = (UINT32)((1UL << _nbits) - 1UL);
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask);
_bs->prefetch <<= _nbits;
}
else
{
_bs->mask = ((1UL << _nbits) - 1);
_bs->mask = (UINT32)((1UL << _nbits) - 1UL);
_bs->accumulator |= ((_bs->prefetch >> (32 - _nbits)) & _bs->mask);
_bs->prefetch <<= _nbits;
_bs->offset -= 32;
@ -113,7 +113,7 @@ extern "C"
BitStream_Prefetch(_bs);
if (_bs->offset)
{
_bs->mask = ((1UL << _bs->offset) - 1);
_bs->mask = (UINT32)((1UL << _bs->offset) - 1UL);
_bs->accumulator |= ((_bs->prefetch >> (32 - _bs->offset)) & _bs->mask);
_bs->prefetch <<= _bs->offset;
}
@ -149,7 +149,7 @@ extern "C"
_bs->pointer += 4;
if (_bs->offset)
{
_bs->mask = ((1UL << _bs->offset) - 1);
_bs->mask = (UINT32)((1UL << _bs->offset) - 1);
_bs->accumulator |= ((_bits & _bs->mask) << (32 - _bs->offset));
}
}
@ -166,7 +166,7 @@ extern "C"
WINPR_API void BitStream_Attach(wBitStream* bs, const BYTE* buffer, UINT32 capacity);
WINPR_API wBitStream* BitStream_New();
WINPR_API wBitStream* BitStream_New(void);
WINPR_API void BitStream_Free(wBitStream* bs);
#ifdef __cplusplus

View File

@ -99,7 +99,7 @@ static INLINE UINT64 _byteswap_uint64(UINT64 _val)
static INLINE UINT16 _byteswap_ushort(UINT16 _val)
{
return (((_val) >> 8) | ((_val) << 8));
return (UINT16)(((_val) >> 8U) | ((_val) << 8U));
}
#endif

View File

@ -71,12 +71,12 @@ typedef struct _WINPR_BITMAP_CORE_HEADER WINPR_BITMAP_CORE_HEADER;
struct _wImage
{
int type;
int width;
int height;
UINT32 width;
UINT32 height;
BYTE* data;
int scanline;
int bitsPerPixel;
int bytesPerPixel;
UINT32 scanline;
UINT32 bitsPerPixel;
UINT32 bytesPerPixel;
};
typedef struct _wImage wImage;
@ -94,7 +94,7 @@ extern "C"
WINPR_API int winpr_image_read_buffer(wImage* image, const BYTE* buffer, int size);
WINPR_API wImage* winpr_image_new();
WINPR_API wImage* winpr_image_new(void);
WINPR_API void winpr_image_free(wImage* image, BOOL bFreeBuffer);
#ifdef __cplusplus

View File

@ -80,8 +80,8 @@ typedef enum
FD_FILESIZE = 0x00000040,
FD_PROGRESSUI = 0x00004000,
FD_LINKUI = 0x00008000,
FD_UNICODE = 0x80000000
} FD_FLAGS;
#define FD_UNICODE 0x80000000
/* Deprecated, here for compatibility */
#define FD_SHOWPROGRESSUI FD_PROGRESSUI

View File

@ -356,7 +356,7 @@ extern "C"
static INLINE size_t Stream_GetPosition(wStream* _s)
{
WINPR_ASSERT(_s);
return (_s->pointer - _s->buffer);
return (size_t)(_s->pointer - _s->buffer);
}
static INLINE void Stream_SetPosition(wStream* _s, size_t _p)
@ -368,19 +368,19 @@ extern "C"
static INLINE void Stream_SealLength(wStream* _s)
{
WINPR_ASSERT(_s);
_s->length = (_s->pointer - _s->buffer);
_s->length = (size_t)(_s->pointer - _s->buffer);
}
static INLINE size_t Stream_GetRemainingCapacity(wStream* _s)
{
WINPR_ASSERT(_s);
return (_s->capacity - (_s->pointer - _s->buffer));
return (_s->capacity - (size_t)(_s->pointer - _s->buffer));
}
static INLINE size_t Stream_GetRemainingLength(wStream* _s)
{
WINPR_ASSERT(_s);
return (_s->length - (_s->pointer - _s->buffer));
return (_s->length - (size_t)(_s->pointer - _s->buffer));
}
static INLINE void Stream_Clear(wStream* _s)

View File

@ -240,7 +240,7 @@ static BOOL FileRead(PVOID Object, LPVOID lpBuffer, DWORD nNumberOfBytesToRead,
}
if (lpNumberOfBytesRead)
*lpNumberOfBytesRead = io_status;
*lpNumberOfBytesRead = (DWORD)io_status;
return status;
}
@ -271,7 +271,7 @@ static BOOL FileWrite(PVOID Object, LPCVOID lpBuffer, DWORD nNumberOfBytesToWrit
return FALSE;
}
*lpNumberOfBytesWritten = io_status;
*lpNumberOfBytesWritten = (DWORD)io_status;
return TRUE;
}

View File

@ -85,9 +85,9 @@ LPSTR FilePatternFindNextWildcardA(LPCSTR lpPattern, DWORD* pFlags)
static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName, LPCSTR lpX,
size_t cchX, LPCSTR lpY, size_t cchY, LPCSTR lpWildcard,
LPSTR* ppMatchEnd)
LPCSTR* ppMatchEnd)
{
LPSTR lpMatch;
LPCSTR lpMatch;
if (!lpFileName)
return FALSE;
@ -130,13 +130,13 @@ static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName
}
else
{
lpMatch = (LPSTR)&lpFileName[cchFileName];
lpMatch = &lpFileName[cchFileName];
}
/**
* State 3: final state
*/
*ppMatchEnd = (LPSTR)&lpMatch[cchY];
*ppMatchEnd = &lpMatch[cchY];
return TRUE;
}
else if (*lpWildcard == '?')
@ -179,13 +179,13 @@ static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName
if ((cchX + 1) > cchFileName)
return FALSE;
lpMatch = (LPSTR)&lpFileName[cchX + 1];
lpMatch = &lpFileName[cchX + 1];
}
/**
* State 3: final state
*/
*ppMatchEnd = (LPSTR)&lpMatch[cchY];
*ppMatchEnd = &lpMatch[cchY];
return TRUE;
}
else if (*lpWildcard == '~')
@ -200,7 +200,7 @@ static BOOL FilePatternMatchSubExpressionA(LPCSTR lpFileName, size_t cchFileName
BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
{
BOOL match;
LPSTR lpTail;
LPCSTR lpTail;
size_t cchTail;
size_t cchPattern;
size_t cchFileName;
@ -254,7 +254,7 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
if (lpPattern[0] == '*')
{
lpTail = (LPSTR)&lpPattern[1];
lpTail = &lpPattern[1];
cchTail = strlen(lpTail);
if (!FilePatternFindNextWildcardA(lpTail, &dwFlags))
@ -307,29 +307,29 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
if (lpWildcard)
{
LPSTR lpX;
LPSTR lpY;
LPCSTR lpX;
LPCSTR lpY;
size_t cchX;
size_t cchY;
LPSTR lpMatchEnd = NULL;
LPSTR lpSubPattern;
LPCSTR lpMatchEnd = NULL;
LPCSTR lpSubPattern;
size_t cchSubPattern;
LPSTR lpSubFileName;
LPCSTR lpSubFileName;
size_t cchSubFileName;
size_t cchWildcard;
size_t cchNextWildcard;
cchSubPattern = cchPattern;
lpSubPattern = (LPSTR)lpPattern;
lpSubPattern = lpPattern;
cchSubFileName = cchFileName;
lpSubFileName = (LPSTR)lpFileName;
lpSubFileName = lpFileName;
cchWildcard = ((dwFlags & WILDCARD_DOS) ? 2 : 1);
lpNextWildcard = FilePatternFindNextWildcardA(&lpWildcard[cchWildcard], &dwNextFlags);
if (!lpNextWildcard)
{
lpX = (LPSTR)lpSubPattern;
lpX = lpSubPattern;
cchX = (lpWildcard - lpSubPattern);
lpY = (LPSTR)&lpSubPattern[cchX + cchWildcard];
lpY = &lpSubPattern[cchX + cchWildcard];
cchY = (cchSubPattern - (lpY - lpSubPattern));
match = FilePatternMatchSubExpressionA(lpSubFileName, cchSubFileName, lpX, cchX, lpY,
cchY, lpWildcard, &lpMatchEnd);
@ -341,9 +341,9 @@ BOOL FilePatternMatchA(LPCSTR lpFileName, LPCSTR lpPattern)
{
cchSubFileName = cchFileName - (lpSubFileName - lpFileName);
cchNextWildcard = ((dwNextFlags & WILDCARD_DOS) ? 2 : 1);
lpX = (LPSTR)lpSubPattern;
lpX = lpSubPattern;
cchX = (lpWildcard - lpSubPattern);
lpY = (LPSTR)&lpSubPattern[cchX + cchWildcard];
lpY = &lpSubPattern[cchX + cchWildcard];
cchY = (lpNextWildcard - lpWildcard) - cchWildcard;
match = FilePatternMatchSubExpressionA(lpSubFileName, cchSubFileName, lpX, cchX,
lpY, cchY, lpWildcard, &lpMatchEnd);

View File

@ -266,7 +266,7 @@ DWORD GetModuleFileNameW(HMODULE hModule, LPWSTR lpFilename, DWORD nSize)
DWORD GetModuleFileNameA(HMODULE hModule, LPSTR lpFilename, DWORD nSize)
{
#if defined(__linux__)
int status;
SSIZE_T status;
size_t length;
char path[64];

View File

@ -23,6 +23,7 @@
#endif
#include <winpr/synch.h>
#include <winpr/assert.h>
#include "synch.h"
@ -125,12 +126,14 @@ BOOL WINAPI winpr_InitializeSynchronizationBarrier(LPSYNCHRONIZATION_BARRIER lpB
GetNativeSystemInfo(&sysinfo);
lpBarrier->Reserved1 = lTotalThreads;
lpBarrier->Reserved2 = lTotalThreads;
WINPR_ASSERT(lTotalThreads >= 0);
lpBarrier->Reserved1 = (DWORD)lTotalThreads;
lpBarrier->Reserved2 = (DWORD)lTotalThreads;
lpBarrier->Reserved3[0] = (ULONG_PTR)hEvent0;
lpBarrier->Reserved3[1] = (ULONG_PTR)hEvent1;
lpBarrier->Reserved4 = sysinfo.dwNumberOfProcessors;
lpBarrier->Reserved5 = lSpinCount;
WINPR_ASSERT(lSpinCount >= 0);
lpBarrier->Reserved5 = (DWORD)lSpinCount;
return TRUE;
}

View File

@ -9,9 +9,9 @@
#define TAG WINPR_TAG("sync.pollset")
#ifdef HAVE_POLL_H
static DWORD handle_mode_to_pollevent(ULONG mode)
static UINT16 handle_mode_to_pollevent(ULONG mode)
{
DWORD event = 0;
UINT16 event = 0;
if (mode & WINPR_FD_READ)
event |= POLLIN;

View File

@ -63,7 +63,7 @@ static int SemaphoreGetFd(HANDLE handle)
static DWORD SemaphoreCleanupHandle(HANDLE handle)
{
int length;
SSIZE_T length;
WINPR_SEMAPHORE* sem = (WINPR_SEMAPHORE*)handle;
if (!SemaphoreIsHandled(handle))

View File

@ -24,6 +24,7 @@
#include <winpr/crt.h>
#include <winpr/file.h>
#include <winpr/assert.h>
#include <winpr/sysinfo.h>
#include <winpr/synch.h>
@ -73,7 +74,7 @@ static int TimerGetFd(HANDLE handle)
static DWORD TimerCleanupHandle(HANDLE handle)
{
int length;
SSIZE_T length;
UINT64 expirations;
WINPR_TIMER* timer = (WINPR_TIMER*)handle;
@ -132,6 +133,7 @@ typedef struct
static void TimerPostDelete_APC(LPVOID arg)
{
TimerDeleter* deleter = (TimerDeleter*)arg;
WINPR_ASSERT(deleter);
free(deleter->timer);
deleter->apcItem.markedForFree = TRUE;
deleter->apcItem.markedForRemove = TRUE;
@ -290,7 +292,7 @@ static int InitializeWaitableTimer(WINPR_TIMER* timer)
static BOOL timer_drain_fd(int fd)
{
UINT64 expr;
int ret;
SSIZE_T ret;
do
{
@ -419,7 +421,7 @@ HANDLE CreateWaitableTimerExW(LPSECURITY_ATTRIBUTES lpTimerAttributes, LPCWSTR l
static void timerAPC(LPVOID arg)
{
WINPR_TIMER* timer = (WINPR_TIMER*)arg;
WINPR_ASSERT(timer);
if (!timer->lPeriod)
{
/* this is a one time shot timer with a completion, let's remove us from
@ -666,21 +668,26 @@ BOOL CancelWaitableTimer(HANDLE hTimer)
static void timespec_add_ms(struct timespec* tspec, UINT32 ms)
{
UINT64 ns = tspec->tv_nsec + (ms * 1000000);
tspec->tv_sec += (ns / 1000000000);
tspec->tv_nsec = (ns % 1000000000);
INT64 ns;
WINPR_ASSERT(tspec);
ns = tspec->tv_nsec + (ms * 1000000LL);
tspec->tv_sec += (ns / 1000000000LL);
tspec->tv_nsec = (ns % 1000000000LL);
}
static void timespec_gettimeofday(struct timespec* tspec)
{
struct timeval tval;
WINPR_ASSERT(tspec);
gettimeofday(&tval, NULL);
tspec->tv_sec = tval.tv_sec;
tspec->tv_nsec = tval.tv_usec * 1000;
}
static int timespec_compare(const struct timespec* tspec1, const struct timespec* tspec2)
static INT64 timespec_compare(const struct timespec* tspec1, const struct timespec* tspec2)
{
WINPR_ASSERT(tspec1);
WINPR_ASSERT(tspec2);
if (tspec1->tv_sec == tspec2->tv_sec)
return (tspec1->tv_nsec - tspec2->tv_nsec);
else
@ -689,6 +696,8 @@ static int timespec_compare(const struct timespec* tspec1, const struct timespec
static void timespec_copy(struct timespec* dst, struct timespec* src)
{
WINPR_ASSERT(dst);
WINPR_ASSERT(src);
dst->tv_sec = src->tv_sec;
dst->tv_nsec = src->tv_nsec;
}
@ -697,6 +706,9 @@ static void InsertTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_Q
{
WINPR_TIMER_QUEUE_TIMER* node;
WINPR_ASSERT(pHead);
WINPR_ASSERT(timer);
if (!(*pHead))
{
*pHead = timer;
@ -735,6 +747,8 @@ static void RemoveTimerQueueTimer(WINPR_TIMER_QUEUE_TIMER** pHead, WINPR_TIMER_Q
WINPR_TIMER_QUEUE_TIMER* node;
WINPR_TIMER_QUEUE_TIMER* prevNode;
WINPR_ASSERT(pHead);
WINPR_ASSERT(timer);
if (timer == *pHead)
{
*pHead = timer->next;
@ -773,6 +787,8 @@ static int FireExpiredTimerQueueTimers(WINPR_TIMER_QUEUE* timerQueue)
struct timespec CurrentTime;
WINPR_TIMER_QUEUE_TIMER* node;
WINPR_ASSERT(timerQueue);
if (!timerQueue->activeHead)
return 0;
@ -815,6 +831,7 @@ static void* TimerQueueThread(void* arg)
struct timespec timeout;
WINPR_TIMER_QUEUE* timerQueue = (WINPR_TIMER_QUEUE*)arg;
WINPR_ASSERT(timerQueue);
while (1)
{
pthread_mutex_lock(&(timerQueue->cond_mutex));
@ -848,6 +865,7 @@ static void* TimerQueueThread(void* arg)
static int StartTimerQueueThread(WINPR_TIMER_QUEUE* timerQueue)
{
WINPR_ASSERT(timerQueue);
pthread_cond_init(&(timerQueue->cond), NULL);
pthread_mutex_init(&(timerQueue->cond_mutex), NULL);
pthread_mutex_init(&(timerQueue->mutex), NULL);

View File

@ -25,7 +25,7 @@
#include <winpr/bitstream.h>
#include "../trio/trio.h"
const char* BYTE_BIT_STRINGS_LSB[256] = {
static const char* BYTE_BIT_STRINGS_LSB[256] = {
"00000000", "00000001", "00000010", "00000011", "00000100", "00000101", "00000110", "00000111",
"00001000", "00001001", "00001010", "00001011", "00001100", "00001101", "00001110", "00001111",
"00010000", "00010001", "00010010", "00010011", "00010100", "00010101", "00010110", "00010111",
@ -60,7 +60,7 @@ const char* BYTE_BIT_STRINGS_LSB[256] = {
"11111000", "11111001", "11111010", "11111011", "11111100", "11111101", "11111110", "11111111"
};
const char* BYTE_BIT_STRINGS_MSB[256] = {
static const char* BYTE_BIT_STRINGS_MSB[256] = {
"00000000", "10000000", "01000000", "11000000", "00100000", "10100000", "01100000", "11100000",
"00010000", "10010000", "01010000", "11010000", "00110000", "10110000", "01110000", "11110000",
"00001000", "10001000", "01001000", "11001000", "00101000", "10101000", "01101000", "11101000",

View File

@ -69,14 +69,14 @@ static BOOL writeBitmapInfoHeader(wStream* s, const WINPR_BITMAP_INFO_HEADER* bi
return FALSE;
Stream_Write_UINT32(s, bi->biSize);
Stream_Write_UINT32(s, bi->biWidth);
Stream_Write_UINT32(s, bi->biHeight);
Stream_Write_INT32(s, bi->biWidth);
Stream_Write_INT32(s, bi->biHeight);
Stream_Write_UINT16(s, bi->biPlanes);
Stream_Write_UINT16(s, bi->biBitCount);
Stream_Write_UINT32(s, bi->biCompression);
Stream_Write_UINT32(s, bi->biSizeImage);
Stream_Write_UINT32(s, bi->biXPelsPerMeter);
Stream_Write_UINT32(s, bi->biYPelsPerMeter);
Stream_Write_INT32(s, bi->biXPelsPerMeter);
Stream_Write_INT32(s, bi->biYPelsPerMeter);
Stream_Write_UINT32(s, bi->biClrUsed);
Stream_Write_UINT32(s, bi->biClrImportant);
return TRUE;