Fixed Wsign-compare warnings
This commit is contained in:
parent
bd7e2263ad
commit
7ab917dca8
@ -337,8 +337,8 @@ static UINT rdpsnd_server_initialize(RdpsndServerContext* context, BOOL ownThrea
|
||||
*/
|
||||
static UINT rdpsnd_server_select_format(RdpsndServerContext* context, UINT16 client_format_index)
|
||||
{
|
||||
int bs;
|
||||
int out_buffer_size;
|
||||
size_t bs;
|
||||
size_t out_buffer_size;
|
||||
AUDIO_FORMAT* format;
|
||||
UINT error = CHANNEL_RC_OK;
|
||||
|
||||
|
@ -197,7 +197,8 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
|
||||
/* The extradata format that FFmpeg uses is following CodecPrivate in Matroska.
|
||||
See http://haali.su/mkv/codecs.pdf */
|
||||
p = mdecoder->codec_context->extradata;
|
||||
if (mdecoder->codec_context->extradata_size < required)
|
||||
if ((mdecoder->codec_context->extradata_size < 0) ||
|
||||
((size_t)mdecoder->codec_context->extradata_size < required))
|
||||
return FALSE;
|
||||
*p++ = 1; /* Reserved? */
|
||||
*p++ = media_type->ExtraData[8]; /* Profile */
|
||||
@ -208,18 +209,21 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
|
||||
s = media_type->ExtraData + 20;
|
||||
size = ((UINT32)(*s)) * 256 + ((UINT32)(*(s + 1)));
|
||||
required += size + 2;
|
||||
if (mdecoder->codec_context->extradata_size < required)
|
||||
if ((mdecoder->codec_context->extradata_size < 0) ||
|
||||
((size_t)mdecoder->codec_context->extradata_size < required))
|
||||
return FALSE;
|
||||
memcpy(p, s, size + 2);
|
||||
s += size + 2;
|
||||
p += size + 2;
|
||||
required++;
|
||||
if (mdecoder->codec_context->extradata_size < required)
|
||||
if ((mdecoder->codec_context->extradata_size < 0) ||
|
||||
((size_t)mdecoder->codec_context->extradata_size < required))
|
||||
return FALSE;
|
||||
*p++ = 1; /* #pps */
|
||||
size = ((UINT32)(*s)) * 256 + ((UINT32)(*(s + 1)));
|
||||
required += size + 2;
|
||||
if (mdecoder->codec_context->extradata_size < required)
|
||||
if ((mdecoder->codec_context->extradata_size < 0) ||
|
||||
((size_t)mdecoder->codec_context->extradata_size < required))
|
||||
return FALSE;
|
||||
memcpy(p, s, size + 2);
|
||||
}
|
||||
@ -227,7 +231,9 @@ static BOOL tsmf_ffmpeg_init_stream(ITSMFDecoder* decoder, const TS_AM_MEDIA_TYP
|
||||
{
|
||||
memcpy(mdecoder->codec_context->extradata, media_type->ExtraData,
|
||||
media_type->ExtraDataSize);
|
||||
if (mdecoder->codec_context->extradata_size < media_type->ExtraDataSize + 8)
|
||||
if ((mdecoder->codec_context->extradata_size < 0) ||
|
||||
((size_t)mdecoder->codec_context->extradata_size <
|
||||
media_type->ExtraDataSize + 8ull))
|
||||
return FALSE;
|
||||
memset(mdecoder->codec_context->extradata + media_type->ExtraDataSize, 0, 8);
|
||||
}
|
||||
|
@ -84,11 +84,9 @@ static const BYTE CLEAR_8BIT_MASKS[9] = { 0x00, 0x01, 0x03, 0x07, 0x0F, 0x1F, 0x
|
||||
|
||||
static void clear_reset_vbar_storage(CLEAR_CONTEXT* clear, BOOL zero)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (zero)
|
||||
{
|
||||
for (i = 0; i < ARRAYSIZE(clear->VBarStorage); i++)
|
||||
for (size_t i = 0; i < ARRAYSIZE(clear->VBarStorage); i++)
|
||||
free(clear->VBarStorage[i].pixels);
|
||||
|
||||
ZeroMemory(clear->VBarStorage, sizeof(clear->VBarStorage));
|
||||
@ -98,7 +96,7 @@ static void clear_reset_vbar_storage(CLEAR_CONTEXT* clear, BOOL zero)
|
||||
|
||||
if (zero)
|
||||
{
|
||||
for (i = 0; i < ARRAYSIZE(clear->ShortVBarStorage); i++)
|
||||
for (size_t i = 0; i < ARRAYSIZE(clear->ShortVBarStorage); i++)
|
||||
free(clear->ShortVBarStorage[i].pixels);
|
||||
|
||||
ZeroMemory(clear->ShortVBarStorage, sizeof(clear->ShortVBarStorage));
|
||||
@ -109,9 +107,7 @@ static void clear_reset_vbar_storage(CLEAR_CONTEXT* clear, BOOL zero)
|
||||
|
||||
static void clear_reset_glyph_cache(CLEAR_CONTEXT* clear)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(clear->GlyphCache); i++)
|
||||
for (size_t i = 0; i < ARRAYSIZE(clear->GlyphCache); i++)
|
||||
free(clear->GlyphCache[i].pixels);
|
||||
|
||||
ZeroMemory(clear->GlyphCache, sizeof(clear->GlyphCache));
|
||||
|
@ -1039,7 +1039,6 @@ static BOOL colordiff(UINT32 format, UINT32 a, UINT32 b)
|
||||
|
||||
static BOOL test_encode_decode(const char* path)
|
||||
{
|
||||
int x, y;
|
||||
BOOL res = FALSE;
|
||||
int rc;
|
||||
BYTE* resultData = NULL;
|
||||
@ -1087,11 +1086,11 @@ static BOOL test_encode_decode(const char* path)
|
||||
dstImage->data = resultData;
|
||||
winpr_image_write(dstImage, "/tmp/test.bmp");
|
||||
}
|
||||
for (y = 0; y < image->height; y++)
|
||||
for (UINT32 y = 0; y < image->height; y++)
|
||||
{
|
||||
const BYTE* orig = &image->data[y * image->scanline];
|
||||
const BYTE* dec = &resultData[y * image->scanline];
|
||||
for (x = 0; x < image->width; x++)
|
||||
for (UINT32 x = 0; x < image->width; x++)
|
||||
{
|
||||
const BYTE* po = &orig[x * 4];
|
||||
const BYTE* pd = &dec[x * 4];
|
||||
|
@ -235,10 +235,6 @@ BOOL rdp_send_client_control_pdu(rdpRdp* rdp, UINT16 action)
|
||||
|
||||
static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, RDP_BITMAP_PERSISTENT_INFO* info)
|
||||
{
|
||||
int index;
|
||||
UINT32 key1;
|
||||
UINT32 key2;
|
||||
|
||||
WINPR_ASSERT(s);
|
||||
WINPR_ASSERT(info);
|
||||
|
||||
@ -263,10 +259,10 @@ static BOOL rdp_write_client_persistent_key_list_pdu(wStream* s, RDP_BITMAP_PERS
|
||||
if (!Stream_EnsureRemainingCapacity(s, info->keyCount * 8ull))
|
||||
return FALSE;
|
||||
|
||||
for (index = 0; index < info->keyCount; index++)
|
||||
for (UINT32 index = 0; index < info->keyCount; index++)
|
||||
{
|
||||
key1 = (UINT32)info->keyList[index];
|
||||
key2 = (UINT32)(info->keyList[index] >> 32);
|
||||
const UINT32 key1 = (UINT32)info->keyList[index];
|
||||
const UINT32 key2 = (UINT32)(info->keyList[index] >> 32);
|
||||
Stream_Write_UINT32(s, key1);
|
||||
Stream_Write_UINT32(s, key2);
|
||||
}
|
||||
|
@ -447,7 +447,7 @@ static BOOL license_check_stream_length(wStream* s, SSIZE_T expect, const char*
|
||||
WLog_WARN(TAG, "invalid %s, expected value %" PRIdz " invalid", where, expect);
|
||||
return FALSE;
|
||||
}
|
||||
if (remain < expect)
|
||||
if (remain < (size_t)expect)
|
||||
{
|
||||
WLog_WARN(TAG, "short %s, expected %" PRIdz " bytes, got %" PRIuz, where, expect, remain);
|
||||
return FALSE;
|
||||
|
@ -53,15 +53,15 @@ static void delete_file(char* path)
|
||||
if (fp)
|
||||
{
|
||||
const char buffer[8192] = { 0 };
|
||||
INT64 x, size = 0;
|
||||
INT64 size = 0;
|
||||
int rs = _fseeki64(fp, 0, SEEK_END);
|
||||
if (rs == 0)
|
||||
size = _ftelli64(fp);
|
||||
_fseeki64(fp, 0, SEEK_SET);
|
||||
|
||||
for (x = 0; x < size; x += sizeof(buffer))
|
||||
for (INT64 x = 0; x < size; x += sizeof(buffer))
|
||||
{
|
||||
fwrite(buffer, MIN(sizeof(buffer), size - x), 1, fp);
|
||||
fwrite(buffer, MIN(sizeof(buffer), (size_t)size - x), 1, fp);
|
||||
}
|
||||
|
||||
fclose(fp);
|
||||
|
@ -685,9 +685,9 @@ static BOOL freerdp_get_system_language_and_country_codes(char* language, size_t
|
||||
}
|
||||
#else
|
||||
{
|
||||
int dot;
|
||||
size_t dot;
|
||||
DWORD nSize;
|
||||
int underscore;
|
||||
size_t underscore;
|
||||
char* env_lang = NULL;
|
||||
LPCSTR lang = "LANG";
|
||||
/* LANG = <language>_<country>.<encoding> */
|
||||
@ -718,7 +718,7 @@ static BOOL freerdp_get_system_language_and_country_codes(char* language, size_t
|
||||
else
|
||||
{
|
||||
/* Get language code */
|
||||
size_t len = MIN(languageLen - 1, underscore);
|
||||
size_t len = MIN(languageLen - 1u, underscore);
|
||||
strncpy(language, env_lang, len);
|
||||
language[len] = '\0';
|
||||
}
|
||||
|
@ -1145,7 +1145,7 @@ UINT synthetic_file_read_close(struct synthetic_file* file, BOOL force)
|
||||
* so avoid caching to prevent running out of available file descriptors */
|
||||
UINT64 size = 0;
|
||||
file_get_size(file, &size);
|
||||
if ((file->offset >= size) || force)
|
||||
if ((file->offset < 0) || ((UINT64)file->offset >= size) || force)
|
||||
{
|
||||
WLog_VRB(TAG, "close file %d", file->fd);
|
||||
if (CloseHandle(file->fd) < 0)
|
||||
|
@ -84,7 +84,7 @@ static BOOL compare_utf16_int(const WCHAR* what, size_t buffersize, SSIZE_T rc,
|
||||
const size_t welen = _wcsnlen(test->utf16, test->utf16len);
|
||||
if (buffersize > welen)
|
||||
{
|
||||
if (rc != welen)
|
||||
if ((rc < 0) || ((size_t)rc != welen))
|
||||
{
|
||||
fprintf(stderr, "%s length does not match expectation: %" PRIdz " != %" PRIuz "\n",
|
||||
prefix, rc, welen);
|
||||
@ -97,10 +97,10 @@ static BOOL compare_utf16_int(const WCHAR* what, size_t buffersize, SSIZE_T rc,
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((rc > 0) && (buffersize > rc))
|
||||
if ((rc > 0) && (buffersize > (size_t)rc))
|
||||
{
|
||||
const size_t wlen = _wcsnlen(what, buffersize);
|
||||
if (wlen > rc)
|
||||
if ((rc < 0) || (wlen > (size_t)rc))
|
||||
{
|
||||
fprintf(stderr, "%s length does not match wcslen: %" PRIdz " < %" PRIuz "\n", prefix,
|
||||
rc, wlen);
|
||||
@ -134,7 +134,7 @@ static BOOL compare_utf8_int(const char* what, size_t buffersize, SSIZE_T rc, SS
|
||||
const size_t slen = strnlen(test->utf8, test->utf8len);
|
||||
if (buffersize > slen)
|
||||
{
|
||||
if (rc != slen)
|
||||
if ((rc < 0) || ((size_t)rc != slen))
|
||||
{
|
||||
fprintf(stderr, "%s length does not match expectation: %" PRIdz " != %" PRIuz "\n",
|
||||
prefix, rc, slen);
|
||||
@ -147,10 +147,10 @@ static BOOL compare_utf8_int(const char* what, size_t buffersize, SSIZE_T rc, SS
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ((rc > 0) && (buffersize > rc))
|
||||
if ((rc > 0) && (buffersize > (size_t)rc))
|
||||
{
|
||||
const size_t wlen = strnlen(what, buffersize);
|
||||
if (wlen != rc)
|
||||
if (wlen != (size_t)rc)
|
||||
{
|
||||
fprintf(stderr, "%s length does not match strnlen: %" PRIdz " != %" PRIuz "\n", prefix,
|
||||
rc, wlen);
|
||||
@ -177,7 +177,7 @@ static BOOL test_convert_to_utf16(const testcase_t* test)
|
||||
|
||||
const SSIZE_T rc2 = ConvertUtf8ToWChar(test->utf8, NULL, 0);
|
||||
const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
|
||||
if (rc2 != wlen)
|
||||
if ((rc2 < 0) || ((size_t)rc2 != wlen))
|
||||
{
|
||||
char prefix[8192] = { 0 };
|
||||
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __FUNCTION__, __LINE__);
|
||||
@ -204,7 +204,7 @@ static BOOL test_convert_to_utf16_n(const testcase_t* test)
|
||||
|
||||
const SSIZE_T rc2 = ConvertUtf8NToWChar(test->utf8, test->utf8len, NULL, 0);
|
||||
const size_t wlen = _wcsnlen(test->utf16, test->utf16len);
|
||||
if (rc2 != wlen)
|
||||
if ((rc2 < 0) || ((size_t)rc2 != wlen))
|
||||
{
|
||||
char prefix[8192] = { 0 };
|
||||
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf8len, test, __FUNCTION__,
|
||||
@ -241,7 +241,7 @@ static BOOL test_convert_to_utf8(const testcase_t* test)
|
||||
|
||||
const SSIZE_T rc2 = ConvertWCharToUtf8(test->utf16, NULL, 0);
|
||||
const size_t wlen = strnlen(test->utf8, test->utf8len);
|
||||
if (rc2 != wlen)
|
||||
if ((rc2 < 0) || ((size_t)rc2 != wlen))
|
||||
{
|
||||
char prefix[8192] = { 0 };
|
||||
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, -1, test, __FUNCTION__, __LINE__);
|
||||
@ -269,7 +269,7 @@ static BOOL test_convert_to_utf8_n(const testcase_t* test)
|
||||
|
||||
const SSIZE_T rc2 = ConvertWCharNToUtf8(test->utf16, test->utf16len, NULL, 0);
|
||||
const size_t wlen = strnlen(test->utf8, test->utf8len);
|
||||
if (rc2 != wlen)
|
||||
if ((rc2 < 0) || ((size_t)rc2 != wlen))
|
||||
{
|
||||
char prefix[8192] = { 0 };
|
||||
create_prefix(prefix, ARRAYSIZE(prefix), 0, rc2, test->utf16len, test, __FUNCTION__,
|
||||
|
@ -380,7 +380,7 @@ SSIZE_T ConvertWCharToUtf8(const WCHAR* wstr, char* str, size_t len)
|
||||
WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, (int)MIN(INT32_MAX, len), NULL, NULL);
|
||||
if (rc <= 0)
|
||||
return rc;
|
||||
else if (rc == len)
|
||||
else if ((size_t)rc == len)
|
||||
{
|
||||
if (str && (str[rc - 1] != '\0'))
|
||||
return rc;
|
||||
@ -407,15 +407,15 @@ SSIZE_T ConvertWCharNToUtf8(const WCHAR* wstr, size_t wlen, char* str, size_t le
|
||||
}
|
||||
const int rc = WideCharToMultiByte(CP_UTF8, 0, wstr, (int)iwlen, str, (int)MIN(INT32_MAX, len),
|
||||
NULL, NULL);
|
||||
if ((rc <= 0) || ((len > 0) && (rc > len)))
|
||||
if ((rc <= 0) || ((len > 0) && ((size_t)rc > len)))
|
||||
return -1;
|
||||
else if (!isNullTerminated)
|
||||
{
|
||||
if (str && (rc < len))
|
||||
if (str && ((size_t)rc < len))
|
||||
str[rc] = '\0';
|
||||
return rc;
|
||||
}
|
||||
else if (rc == len)
|
||||
else if ((size_t)rc == len)
|
||||
{
|
||||
if (str && (str[rc - 1] != '\0'))
|
||||
return rc;
|
||||
|
@ -623,7 +623,7 @@ static SECURITY_STATUS parseKeyName(LPCWSTR pszKeyName, CK_SLOT_ID* slotId, CK_B
|
||||
if (!pos)
|
||||
return NTE_BAD_KEY;
|
||||
|
||||
if (pos - &asciiKeyName[1] > sizeof(CK_SLOT_ID) * 2)
|
||||
if (pos - &asciiKeyName[1] > sizeof(CK_SLOT_ID) * 2ull)
|
||||
return NTE_BAD_KEY;
|
||||
|
||||
*slotId = (CK_SLOT_ID)0;
|
||||
|
@ -219,7 +219,7 @@ BOOL winpr_SetThreadpoolThreadMinimum(PTP_POOL ptpp, DWORD cthrdMic)
|
||||
#endif
|
||||
ptpp->Minimum = cthrdMic;
|
||||
|
||||
while (ArrayList_Count(ptpp->Threads) < (INT64)ptpp->Minimum)
|
||||
while (ArrayList_Count(ptpp->Threads) < ptpp->Minimum)
|
||||
{
|
||||
if (!(thread = CreateThread(NULL, 0, thread_pool_work_func, (void*)ptpp, 0, NULL)))
|
||||
{
|
||||
|
@ -1203,7 +1203,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_MakeSignature(PCtxtHandle phContext, ULONG
|
||||
|
||||
context = sspi_SecureHandleGetLowerPointer(phContext);
|
||||
|
||||
for (int i = 0; i < pMessage->cBuffers; i++)
|
||||
for (ULONG i = 0; i < pMessage->cBuffers; i++)
|
||||
{
|
||||
if (pMessage->pBuffers[i].BufferType == SECBUFFER_DATA)
|
||||
data_buffer = &pMessage->pBuffers[i];
|
||||
@ -1254,7 +1254,7 @@ static SECURITY_STATUS SEC_ENTRY ntlm_VerifySignature(PCtxtHandle phContext,
|
||||
if (!context)
|
||||
return SEC_E_INVALID_HANDLE;
|
||||
|
||||
for (int i = 0; i < pMessage->cBuffers; i++)
|
||||
for (ULONG i = 0; i < pMessage->cBuffers; i++)
|
||||
{
|
||||
if (pMessage->pBuffers[i].BufferType == SECBUFFER_DATA)
|
||||
data_buffer = &pMessage->pBuffers[i];
|
||||
|
@ -319,7 +319,6 @@ fail:
|
||||
|
||||
static int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash)
|
||||
{
|
||||
int i;
|
||||
char PasswordHash[32] = { 0 };
|
||||
INT64 PasswordHashLength = 0;
|
||||
SSPI_CREDENTIALS* credentials = NULL;
|
||||
@ -333,14 +332,14 @@ static int ntlm_convert_password_hash(NTLM_CONTEXT* context, BYTE* hash)
|
||||
PasswordHashLength = credentials->identity.PasswordLength - SSPI_CREDENTIALS_HASH_LENGTH_OFFSET;
|
||||
|
||||
WINPR_ASSERT(PasswordHashLength >= 0);
|
||||
WINPR_ASSERT(PasswordHashLength < ARRAYSIZE(PasswordHash));
|
||||
WINPR_ASSERT((size_t)PasswordHashLength < ARRAYSIZE(PasswordHash));
|
||||
if (ConvertWCharNToUtf8(credentials->identity.Password, PasswordHashLength, PasswordHash,
|
||||
ARRAYSIZE(PasswordHash)) <= 0)
|
||||
return -1;
|
||||
|
||||
CharUpperBuffA(PasswordHash, (DWORD)PasswordHashLength);
|
||||
|
||||
for (i = 0; i < ARRAYSIZE(PasswordHash); i += 2)
|
||||
for (size_t i = 0; i < ARRAYSIZE(PasswordHash); i += 2)
|
||||
{
|
||||
BYTE hn =
|
||||
(BYTE)(PasswordHash[i] > '9' ? PasswordHash[i] - 'A' + 10 : PasswordHash[i] - '0');
|
||||
|
Loading…
Reference in New Issue
Block a user