[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);
}

View File

@@ -760,7 +760,11 @@ static inline int progressive_rfx_dwt_2d_decode(PROGRESSIVE_CONTEXT* WINPR_RESTR
else if (!coeffDiff)
memcpy(current, buffer, bsize);
else
prims->add_16s_inplace(buffer, current, belements);
{
const pstatus_t rc = prims->add_16s_inplace(buffer, current, belements);
if (rc != PRIMITIVES_SUCCESS)
return -1;
}
INT16* temp = (INT16*)BufferPool_Take(progressive->bufferPool, -1); /* DWT buffer */
@@ -787,7 +791,7 @@ static inline void progressive_rfx_decode_block(const primitives_t* prims,
if (!shift)
return;
prims->lShiftC_16s_inplace(buffer, shift, length);
(void)prims->lShiftC_16s_inplace(buffer, shift, length);
}
static inline int

View File

@@ -254,31 +254,28 @@ static void rfx_encode_component(RFX_CONTEXT* WINPR_RESTRICT context,
*size = WINPR_ASSERTING_INT_CAST(uint32_t, rc);
}
void rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, RFX_TILE* WINPR_RESTRICT tile)
BOOL rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, RFX_TILE* WINPR_RESTRICT tile)
{
BOOL rc = TRUE;
union
{
const INT16** cpv;
INT16** pv;
} cnv;
BYTE* pBuffer = NULL;
INT16* pSrcDst[3];
uint32_t YLen = 0;
INT16* pSrcDst[3] = { 0 };
uint32_t CbLen = 0;
uint32_t CrLen = 0;
UINT32* YQuant = NULL;
UINT32* CbQuant = NULL;
UINT32* CrQuant = NULL;
primitives_t* prims = primitives_get();
static const prim_size_t roi_64x64 = { 64, 64 };
if (!(pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1)))
return;
BYTE* pBuffer = (BYTE*)BufferPool_Take(context->priv->BufferPool, -1);
if (!pBuffer)
return FALSE;
YLen = CbLen = CrLen = 0;
YQuant = context->quants + (10ULL * tile->quantIdxY);
CbQuant = context->quants + (10ULL * tile->quantIdxCb);
CrQuant = context->quants + (10ULL * tile->quantIdxCr);
uint32_t YLen = CbLen = CrLen = 0;
UINT32* YQuant = context->quants + (10ULL * tile->quantIdxY);
UINT32* CbQuant = context->quants + (10ULL * tile->quantIdxCb);
UINT32* CrQuant = context->quants + (10ULL * tile->quantIdxCr);
pSrcDst[0] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 0ULL) + 16ULL])); /* y_r_buffer */
pSrcDst[1] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 1ULL) + 16ULL])); /* cb_g_buffer */
pSrcDst[2] = (INT16*)((&pBuffer[((8192ULL + 32ULL) * 2ULL) + 16ULL])); /* cr_b_buffer */
@@ -291,8 +288,9 @@ void rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, RFX_TILE* WINPR_RESTRIC
PROFILER_ENTER(context->priv->prof_rfx_rgb_to_ycbcr)
cnv.pv = pSrcDst;
prims->RGBToYCbCr_16s16s_P3P3(cnv.cpv, 64 * sizeof(INT16), pSrcDst, 64 * sizeof(INT16),
&roi_64x64);
if (prims->RGBToYCbCr_16s16s_P3P3(cnv.cpv, 64 * sizeof(INT16), pSrcDst, 64 * sizeof(INT16),
&roi_64x64) != PRIMITIVES_SUCCESS)
rc = FALSE;
PROFILER_EXIT(context->priv->prof_rfx_rgb_to_ycbcr)
/**
* We need to clear the buffers as the RLGR encoder expects it to be initialized to zero.
@@ -308,5 +306,7 @@ void rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context, RFX_TILE* WINPR_RESTRIC
tile->CbLen = WINPR_ASSERTING_INT_CAST(UINT16, CbLen);
tile->CrLen = WINPR_ASSERTING_INT_CAST(UINT16, CrLen);
PROFILER_EXIT(context->priv->prof_rfx_encode_rgb)
BufferPool_Return(context->priv->BufferPool, pBuffer);
if (!BufferPool_Return(context->priv->BufferPool, pBuffer))
return FALSE;
return rc;
}

View File

@@ -23,7 +23,7 @@
#include <freerdp/codec/rfx.h>
#include <freerdp/api.h>
FREERDP_LOCAL void rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context,
FREERDP_LOCAL BOOL rfx_encode_rgb(RFX_CONTEXT* WINPR_RESTRICT context,
RFX_TILE* WINPR_RESTRICT tile);
#endif /* FREERDP_LIB_CODEC_RFX_ENCODE_H */

View File

@@ -51,7 +51,7 @@ static inline void rfx_quantization_decode_block(const primitives_t* WINPR_RESTR
if (factor == 0)
return;
prims->lShiftC_16s_inplace(buffer, factor, buffer_size);
(void)prims->lShiftC_16s_inplace(buffer, factor, buffer_size);
}
void rfx_quantization_decode(INT16* WINPR_RESTRICT buffer, const UINT32* WINPR_RESTRICT quantVals)

View File

@@ -860,8 +860,10 @@ state_run_t autodetect_recv_request_packet(rdpAutoDetect* autodetect, RDP_TRANSP
goto fail;
}
IFCALL(autodetect->RequestReceived, autodetect, transport, autodetectReqPdu.requestType,
autodetectReqPdu.sequenceNumber);
if (!IFCALLRESULT(TRUE, autodetect->RequestReceived, autodetect, transport,
autodetectReqPdu.requestType, autodetectReqPdu.sequenceNumber))
goto fail;
switch (autodetectReqPdu.requestType)
{
case RDP_RTT_REQUEST_TYPE_CONTINUOUS:
@@ -981,8 +983,10 @@ state_run_t autodetect_recv_response_packet(rdpAutoDetect* autodetect, RDP_TRANS
goto fail;
}
IFCALL(autodetect->ResponseReceived, autodetect, transport, autodetectRspPdu.responseType,
autodetectRspPdu.sequenceNumber);
if (!IFCALLRESULT(TRUE, autodetect->ResponseReceived, autodetect, transport,
autodetectRspPdu.responseType, autodetectRspPdu.sequenceNumber))
goto fail;
switch (autodetectRspPdu.responseType)
{
case RDP_RTT_RESPONSE_TYPE:

View File

@@ -1257,7 +1257,13 @@ static BOOL rdp_recv_logon_error_info(rdpRdp* rdp, wStream* s, logon_info_ex* in
Stream_Read_UINT32(s, errorNotificationData); /* errorNotificationData (4 bytes) */
WLog_DBG(TAG, "LogonErrorInfo: Data: 0x%08" PRIX32 " Type: 0x%08" PRIX32 "",
errorNotificationData, errorNotificationType);
IFCALL(instance->LogonErrorInfo, instance, errorNotificationData, errorNotificationType);
if (instance->LogonErrorInfo)
{
const int rc =
instance->LogonErrorInfo(instance, errorNotificationData, errorNotificationType);
if (rc < 0)
return FALSE;
}
info->ErrorNotificationType = errorNotificationType;
info->ErrorNotificationData = errorNotificationData;
return TRUE;

View File

@@ -407,7 +407,11 @@ static state_run_t peer_recv_data_pdu(freerdp_peer* client, wStream* s,
return STATE_RUN_FAILED;
Stream_Read_UINT32(s, client->ack_frame_id);
IFCALL(update->SurfaceFrameAcknowledge, update->context, client->ack_frame_id);
if (update->SurfaceFrameAcknowledge)
{
if (!update->SurfaceFrameAcknowledge(update->context, client->ack_frame_id))
return STATE_RUN_FAILED;
}
break;
case DATA_PDU_TYPE_REFRESH_RECT:
@@ -802,7 +806,11 @@ static state_run_t peer_recv_callback_internal(WINPR_ATTR_UNUSED rdpTransport* t
rdpSettings* settings = client->context->settings;
WINPR_ASSERT(settings);
IFCALL(client->ReachedState, client, rdp_get_state(rdp));
if (client->ReachedState)
{
if (!client->ReachedState(client, rdp_get_state(rdp)))
return STATE_RUN_FAILED;
}
switch (rdp_get_state(rdp))
{
case CONNECTION_STATE_INITIAL:
@@ -995,7 +1003,11 @@ static state_run_t peer_recv_callback_internal(WINPR_ATTR_UNUSED rdpTransport* t
{
MONITOR_DEF* monitors = NULL;
IFCALL(client->AdjustMonitorsLayout, client);
if (client->AdjustMonitorsLayout)
{
if (!client->AdjustMonitorsLayout(client))
return STATE_RUN_FAILED;
}
/* client supports the monitorLayout PDU, let's send him the monitors if any */
ret = STATE_RUN_SUCCESS;

View File

@@ -2011,7 +2011,8 @@ void transport_layer_free(rdpTransportLayer* layer)
if (!layer)
return;
IFCALL(intern->pub.Close, intern->pub.userContext);
if (intern->pub.Close)
intern->pub.Close(intern->pub.userContext);
free(intern->userContextShadowPtr);
free(intern);
}

View File

@@ -963,7 +963,11 @@ void update_reset_state(rdpUpdate* update)
WINPR_ASSERT(altsec);
altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
IFCALL(altsec->common.SwitchSurface, update->context, &(altsec->switch_surface));
if (altsec->common.SwitchSurface)
{
if (!altsec->common.SwitchSurface(update->context, &(altsec->switch_surface)))
WLog_Print(up->log, WLOG_WARN, "altsec->common.SwitchSurface failed");
}
}
}
@@ -988,9 +992,10 @@ BOOL update_post_connect(rdpUpdate* update)
}
altsec->switch_surface.bitmapId = SCREEN_BITMAP_SURFACE;
IFCALL(update->altsec->SwitchSurface, update->context, &(altsec->switch_surface));
const BOOL rc = IFCALLRESULT(TRUE, update->altsec->SwitchSurface, update->context,
&(altsec->switch_surface));
up->initialState = FALSE;
return TRUE;
return rc;
}
void update_post_disconnect(rdpUpdate* update)

View File

@@ -1048,8 +1048,9 @@ static BOOL gdi_surface_frame_marker(rdpContext* context,
case SURFACECMD_FRAMEACTION_END:
if (freerdp_settings_get_uint32(context->settings, FreeRDP_FrameAcknowledge) > 0)
{
IFCALL(context->update->SurfaceFrameAcknowledge, context,
surfaceFrameMarker->frameId);
if (!IFCALLRESULT(TRUE, context->update->SurfaceFrameAcknowledge, context,
surfaceFrameMarker->frameId))
return FALSE;
}
break;

View File

@@ -119,11 +119,14 @@ static UINT gdi_ResetGraphics(RdpgfxClientContext* context,
if (update)
{
WINPR_ASSERT(update->DesktopResize);
update->DesktopResize(gdi->context);
if (!update->DesktopResize(gdi->context))
goto fail;
}
WINPR_ASSERT(context->GetSurfaceIds);
context->GetSurfaceIds(context, &pSurfaceIds, &count);
rc = context->GetSurfaceIds(context, &pSurfaceIds, &count);
if (rc != CHANNEL_RC_OK)
goto fail;
for (UINT32 index = 0; index < count; index++)
{
@@ -242,20 +245,19 @@ static UINT gdi_WindowUpdate(RdpgfxClientContext* context, gdiGfxSurface* surfac
static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)
{
UINT16 count = 0;
UINT status = ERROR_INTERNAL_ERROR;
UINT16* pSurfaceIds = NULL;
rdpGdi* gdi = NULL;
WINPR_ASSERT(context);
gdi = (rdpGdi*)context->custom;
rdpGdi* gdi = (rdpGdi*)context->custom;
WINPR_ASSERT(gdi);
EnterCriticalSection(&context->mux);
WINPR_ASSERT(context->GetSurfaceIds);
context->GetSurfaceIds(context, &pSurfaceIds, &count);
status = CHANNEL_RC_OK;
UINT status = context->GetSurfaceIds(context, &pSurfaceIds, &count);
if (status != CHANNEL_RC_OK)
goto fail;
for (UINT32 index = 0; index < count; index++)
{
@@ -282,6 +284,7 @@ static UINT gdi_UpdateSurfaces(RdpgfxClientContext* context)
break;
}
fail:
free(pSurfaceIds);
LeaveCriticalSection(&context->mux);
return status;
@@ -1442,15 +1445,14 @@ fail:
static UINT gdi_SurfaceToCache(RdpgfxClientContext* context,
const RDPGFX_SURFACE_TO_CACHE_PDU* surfaceToCache)
{
const RECTANGLE_16* rect = NULL;
gdiGfxSurface* surface = NULL;
gdiGfxCacheEntry* cacheEntry = NULL;
UINT rc = ERROR_INTERNAL_ERROR;
EnterCriticalSection(&context->mux);
rect = &(surfaceToCache->rectSrc);
const RECTANGLE_16* rect = &(surfaceToCache->rectSrc);
WINPR_ASSERT(context->GetSurfaceData);
surface = (gdiGfxSurface*)context->GetSurfaceData(context, surfaceToCache->surfaceId);
gdiGfxSurface* surface =
(gdiGfxSurface*)context->GetSurfaceData(context, surfaceToCache->surfaceId);
if (!surface)
goto fail;
@@ -1476,7 +1478,9 @@ static UINT gdi_SurfaceToCache(RdpgfxClientContext* context,
{
RDPGFX_EVICT_CACHE_ENTRY_PDU evict = { surfaceToCache->cacheSlot };
WINPR_ASSERT(context->EvictCacheEntry);
context->EvictCacheEntry(context, &evict);
rc = context->EvictCacheEntry(context, &evict);
if (rc != CHANNEL_RC_OK)
goto fail;
}
WINPR_ASSERT(context->SetCacheSlotData);

View File

@@ -120,7 +120,11 @@ static pstatus_t general_copy_8u_AC4r(const BYTE* WINPR_RESTRICT pSrc, INT32 src
{
do
{
generic->copy(src, dst, WINPR_ASSERTING_INT_CAST(int32_t, rowbytes));
const pstatus_t rc =
generic->copy(src, dst, WINPR_ASSERTING_INT_CAST(int32_t, rowbytes));
if (rc != PRIMITIVES_SUCCESS)
return rc;
src += srcStep;
dst += dstStep;
} while (--height);

View File

@@ -44,7 +44,6 @@ static pstatus_t general_set_32s(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 l
INT32* dptr = pDst;
size_t span = 0;
size_t remaining = 0;
primitives_t* prims = NULL;
if (len < 256)
{
@@ -58,7 +57,7 @@ static pstatus_t general_set_32s(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 l
span = 1;
*dptr = val;
remaining = len - 1;
prims = primitives_get();
primitives_t* prims = primitives_get();
while (remaining)
{
@@ -69,7 +68,9 @@ static pstatus_t general_set_32s(INT32 val, INT32* WINPR_RESTRICT pDst, UINT32 l
const size_t s = thiswidth << 2;
WINPR_ASSERT(thiswidth <= INT32_MAX);
prims->copy_8u((BYTE*)dptr, (BYTE*)(dptr + span), (INT32)s);
const pstatus_t rc = prims->copy_8u((BYTE*)dptr, (BYTE*)(dptr + span), (INT32)s);
if (rc != PRIMITIVES_SUCCESS)
return rc;
remaining -= thiswidth;
span <<= 1;
}
@@ -108,7 +109,10 @@ static pstatus_t general_set_32u(UINT32 val, UINT32* WINPR_RESTRICT pDst, UINT32
const size_t s = thiswidth << 2;
WINPR_ASSERT(thiswidth <= INT32_MAX);
prims->copy_8u((BYTE*)dptr, (BYTE*)(dptr + span), (INT32)s);
const pstatus_t rc = prims->copy_8u((BYTE*)dptr, (BYTE*)(dptr + span), (INT32)s);
if (rc != PRIMITIVES_SUCCESS)
return rc;
remaining -= thiswidth;
span <<= 1;
}