Assert function arguments in freerdp.c

This commit is contained in:
akallabeth 2022-06-24 13:34:32 +02:00 committed by akallabeth
parent ada4671435
commit d745ba7c28
1 changed files with 27 additions and 0 deletions

View File

@ -558,7 +558,12 @@ BOOL freerdp_focus_required(freerdp* instance)
{
rdpRdp* rdp;
BOOL bRetCode = FALSE;
WINPR_ASSERT(instance);
WINPR_ASSERT(instance->context);
rdp = instance->context->rdp;
WINPR_ASSERT(rdp);
if (rdp->resendFocus)
{
@ -572,7 +577,13 @@ BOOL freerdp_focus_required(freerdp* instance)
void freerdp_set_focus(freerdp* instance)
{
rdpRdp* rdp;
WINPR_ASSERT(instance);
WINPR_ASSERT(instance->context);
rdp = instance->context->rdp;
WINPR_ASSERT(rdp);
rdp->resendFocus = TRUE;
}
@ -787,11 +798,15 @@ void freerdp_context_free(freerdp* instance)
int freerdp_get_disconnect_ultimatum(rdpContext* context)
{
WINPR_ASSERT(context);
return context->disconnectUltimatum;
}
UINT32 freerdp_error_info(freerdp* instance)
{
WINPR_ASSERT(instance);
WINPR_ASSERT(instance->context);
WINPR_ASSERT(instance->context->rdp);
return instance->context->rdp->errorInfo;
}
@ -813,6 +828,7 @@ BOOL freerdp_send_error_info(rdpRdp* rdp)
UINT32 freerdp_get_last_error(rdpContext* context)
{
WINPR_ASSERT(context);
return context->LastError;
}
@ -908,6 +924,8 @@ void freerdp_set_last_error(rdpContext* context, UINT32 lastError)
void freerdp_set_last_error_ex(rdpContext* context, UINT32 lastError, const char* fkt,
const char* file, int line)
{
WINPR_ASSERT(context);
if (lastError)
WLog_ERR(TAG, "%s:%s %s [0x%08" PRIX32 "]", fkt, __FUNCTION__,
freerdp_get_last_error_name(lastError), lastError);
@ -1044,11 +1062,14 @@ BOOL freerdp_nla_revert_to_self(rdpContext* context)
HANDLE getChannelErrorEventHandle(rdpContext* context)
{
WINPR_ASSERT(context);
return context->channelErrorEvent;
}
BOOL checkChannelErrorEvent(rdpContext* context)
{
WINPR_ASSERT(context);
if (WaitForSingleObject(context->channelErrorEvent, 0) == WAIT_OBJECT_0)
{
WLog_ERR(TAG, "%s. Error was %" PRIu32 "", context->errorDescription,
@ -1066,16 +1087,19 @@ BOOL checkChannelErrorEvent(rdpContext* context)
*/
UINT getChannelError(rdpContext* context)
{
WINPR_ASSERT(context);
return context->channelErrorNum;
}
const char* getChannelErrorDescription(rdpContext* context)
{
WINPR_ASSERT(context);
return context->errorDescription;
}
void clearChannelError(rdpContext* context)
{
WINPR_ASSERT(context);
context->channelErrorNum = 0;
memset(context->errorDescription, 0, 500);
ResetEvent(context->channelErrorEvent);
@ -1085,6 +1109,9 @@ void setChannelError(rdpContext* context, UINT errorNum, const char* format, ...
{
va_list ap;
va_start(ap, format);
WINPR_ASSERT(context);
context->channelErrorNum = errorNum;
vsnprintf(context->errorDescription, 499, format, ap);
va_end(ap);