Fixed sign-compare warnings

This commit is contained in:
Armin Novak 2019-02-07 14:18:53 +01:00
parent 696390f027
commit ba40c971d2
5 changed files with 31 additions and 22 deletions

View File

@ -1245,15 +1245,18 @@ BOOL gdi_resize_ex(rdpGdi* gdi, UINT32 width, UINT32 height,
if (!gdi || !gdi->primary)
return FALSE;
if (gdi->width == width && gdi->height == height &&
(!buffer || gdi->primary_buffer == buffer))
if ((width > INT32_MAX) || (height > INT32_MAX))
return FALSE;
if ((gdi->width == (INT32)width) && (gdi->height == (INT32)height) &&
(!buffer || (gdi->primary_buffer == buffer)))
return TRUE;
if (gdi->drawing == gdi->primary)
gdi->drawing = NULL;
gdi->width = width;
gdi->height = height;
gdi->width = (INT32)width;
gdi->height = (INT32)height;
gdi_bitmap_free_ex(gdi->primary);
gdi->primary = NULL;
gdi->primary_buffer = NULL;

View File

@ -439,7 +439,7 @@ INLINE BOOL gdi_InvalidateRegion(HGDI_DC hdc, INT32 x, INT32 y, INT32 w,
cinvalid = hdc->hwnd->cinvalid;
if ((hdc->hwnd->ninvalid + 1) > hdc->hwnd->count)
if ((hdc->hwnd->ninvalid + 1) > (INT64)hdc->hwnd->count)
{
int new_cnt;
HGDI_RGN new_rgn;

View File

@ -96,8 +96,8 @@ static int test_gdi_CreateBitmap(void)
{
int rc = -1;
UINT32 format = PIXEL_FORMAT_ARGB32;
UINT32 width;
UINT32 height;
INT32 width;
INT32 height;
BYTE* data;
HGDI_BITMAP hBitmap = NULL;
width = 32;
@ -145,8 +145,8 @@ static int test_gdi_CreateCompatibleBitmap(void)
{
int rc = -1;
HGDI_DC hdc;
UINT32 width;
UINT32 height;
INT32 width;
INT32 height;
HGDI_BITMAP hBitmap = NULL;
if (!(hdc = gdi_GetDC()))
@ -268,10 +268,10 @@ fail:
static int test_gdi_CreateRectRgn(void)
{
int rc = -1;
UINT32 x1 = 32;
UINT32 y1 = 64;
UINT32 x2 = 128;
UINT32 y2 = 256;
INT32 x1 = 32;
INT32 y1 = 64;
INT32 x2 = 128;
INT32 y2 = 256;
HGDI_RGN hRegion = gdi_CreateRectRgn(x1, y1, x2, y2);
if (!hRegion)
@ -305,10 +305,10 @@ static int test_gdi_CreateRect(void)
{
int rc = -1;
HGDI_RECT hRect;
UINT32 x1 = 32;
UINT32 y1 = 64;
UINT32 x2 = 128;
UINT32 y2 = 256;
INT32 x1 = 32;
INT32 y1 = 64;
INT32 x2 = 128;
INT32 y2 = 256;
if (!(hRect = gdi_CreateRect(x1, y1, x2, y2)))
{

View File

@ -206,7 +206,7 @@ static const char* test_ROP3[] =
int TestGdiRop3(int argc, char* argv[])
{
int index;
size_t index;
for (index = 0; index < sizeof(test_ROP3) / sizeof(test_ROP3[0]); index++)
{

View File

@ -91,13 +91,17 @@ static BOOL gdiVideoShowSurface(VideoClientContext* video, VideoSurface* surface
surfaceRect.right = surface->x + surface->w;
surfaceRect.bottom = surface->y + surface->h;
update->BeginPaint(gdi->context);
if ((gdi->width < 0) || (gdi->height < 0))
return FALSE;
else
{
const UINT32 nXSrc = surface->x;
const UINT32 nYSrc = surface->y;
const UINT32 nXDst = nXSrc;
const UINT32 nYDst = nYSrc;
const UINT32 width = (surface->w + surface->x < gdi->width) ? surface->w : gdi->width - surface->x;
const UINT32 height = (surface->h + surface->y < gdi->height) ? surface->h : gdi->height -
const UINT32 width = (surface->w + surface->x < (UINT32)gdi->width) ? surface->w : (UINT32)gdi->width - surface->x;
const UINT32 height = (surface->h + surface->y < (UINT32)gdi->height) ? surface->h : (UINT32)gdi->height -
surface->y;
if (!freerdp_image_copy(gdi->primary_buffer, gdi->primary->hdc->format,
@ -105,9 +109,11 @@ static BOOL gdiVideoShowSurface(VideoClientContext* video, VideoSurface* surface
nXDst, nYDst, width, height,
surface->data, gdi->primary->hdc->format,
gdiSurface->scanline, 0, 0, NULL, FREERDP_FLIP_NONE))
return CHANNEL_RC_NULL_DATA;
return FALSE;
gdi_InvalidateRegion(gdi->primary->hdc, nXDst, nYDst, width, height);
if ((nXDst > INT32_MAX) || (nYDst > INT32_MAX) || (width > INT32_MAX) || (height > INT32_MAX))
return FALSE;
gdi_InvalidateRegion(gdi->primary->hdc, (INT32)nXDst, (INT32)nYDst, (INT32)width, (INT32)height);
}
update->EndPaint(gdi->context);
return TRUE;