[freerdp,warnings] properly handle function return

This commit is contained in:
Armin Novak
2026-02-16 08:18:37 +01:00
parent 81cf9f6cf0
commit e0e6a7f800
14 changed files with 115 additions and 67 deletions

View File

@@ -52,15 +52,11 @@ static BOOL
update_gdi_create_offscreen_bitmap(rdpContext* context,
const CREATE_OFFSCREEN_BITMAP_ORDER* createOffscreenBitmap)
{
UINT16 index = 0;
rdpBitmap* bitmap = NULL;
rdpCache* cache = NULL;
if (!context || !createOffscreenBitmap || !context->cache)
return FALSE;
cache = context->cache;
bitmap = Bitmap_Alloc(context);
rdpCache* cache = context->cache;
rdpBitmap* bitmap = Bitmap_Alloc(context);
if (!bitmap)
return FALSE;
@@ -82,11 +78,14 @@ update_gdi_create_offscreen_bitmap(rdpContext* context,
offscreen_cache_put(cache->offscreen, createOffscreenBitmap->id, bitmap);
if (cache->offscreen->currentSurface == createOffscreenBitmap->id)
bitmap->SetSurface(context, bitmap, FALSE);
{
if (!bitmap->SetSurface(context, bitmap, FALSE))
return FALSE;
}
for (UINT32 i = 0; i < createOffscreenBitmap->deleteList.cIndices; i++)
{
index = createOffscreenBitmap->deleteList.indices[i];
const UINT16 index = createOffscreenBitmap->deleteList.indices[i];
offscreen_cache_delete(cache->offscreen, index);
}
@@ -96,20 +95,18 @@ update_gdi_create_offscreen_bitmap(rdpContext* context,
static BOOL update_gdi_switch_surface(rdpContext* context,
const SWITCH_SURFACE_ORDER* switchSurface)
{
rdpCache* cache = NULL;
rdpBitmap* bitmap = NULL;
if (!context || !context->cache || !switchSurface || !context->graphics)
return FALSE;
cache = context->cache;
bitmap = context->graphics->Bitmap_Prototype;
rdpCache* cache = context->cache;
rdpBitmap* bitmap = context->graphics->Bitmap_Prototype;
if (!bitmap)
return FALSE;
if (switchSurface->bitmapId == SCREEN_BITMAP_SURFACE)
{
bitmap->SetSurface(context, NULL, TRUE);
if (!bitmap->SetSurface(context, NULL, TRUE))
return FALSE;
}
else
{
@@ -118,7 +115,8 @@ static BOOL update_gdi_switch_surface(rdpContext* context,
if (bmp == NULL)
return FALSE;
bitmap->SetSurface(context, bmp, FALSE);
if (!bitmap->SetSurface(context, bmp, FALSE))
return FALSE;
}
cache->offscreen->currentSurface = switchSurface->bitmapId;
@@ -179,7 +177,12 @@ void offscreen_cache_delete(rdpOffscreenCache* offscreenCache, UINT32 index)
WINPR_ASSERT(offscreenCache->context);
/* Ensure that the bitmap is no longer used in GDI */
IFCALL(prevBitmap->SetSurface, offscreenCache->context, NULL, FALSE);
if (prevBitmap->SetSurface)
{
if (!prevBitmap->SetSurface(offscreenCache->context, NULL, FALSE))
WLog_WARN(TAG, "prevBitmap->SetSurface failed");
}
Bitmap_Free(offscreenCache->context, prevBitmap);
}