[freerdp,api] log NULL IFCALL/IFCALLRET calls

This commit is contained in:
akallabeth 2023-08-04 10:14:42 +02:00 committed by akallabeth
parent 8877614d50
commit 22fffdd5ea
2 changed files with 29 additions and 22 deletions

View File

@ -21,6 +21,7 @@
#define FREERDP_API_H #define FREERDP_API_H
#include <winpr/winpr.h> #include <winpr/winpr.h>
#include <winpr/wlog.h>
#include <winpr/platform.h> #include <winpr/platform.h>
#ifdef _WIN32 #ifdef _WIN32
@ -65,24 +66,34 @@
#endif #endif
#endif #endif
#define IFCALL(_cb, ...) \ #define IFCALL(_cb, ...) \
do \ do \
{ \ { \
if (_cb != NULL) \ if (_cb != NULL) \
{ \ _cb(__VA_ARGS__); \
_cb(__VA_ARGS__); \ else \
} \ WLog_VRB("com.freerdp.api", "IFCALL(" #_cb ") == NULL"); \
} while (0) } while (0)
#define IFCALLRET(_cb, _ret, ...) \ #define IFCALLRET(_cb, _ret, ...) \
do \ do \
{ \ { \
if (_cb != NULL) \ if (_cb != NULL) \
{ \ _ret = _cb(__VA_ARGS__); \
_ret = _cb(__VA_ARGS__); \ else \
} \ WLog_VRB("com.freerdp.api", "IFCALLRET(" #_cb ") == NULL"); \
} while (0) } while (0)
#define IFCALLRESULT(_default_return, _cb, ...) \
((_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)) #if __GNUC__
#define IFCALLRESULT(_default_return, _cb, ...) \
({ \
(_cb != NULL) ? _cb(__VA_ARGS__) : ({ \
WLog_VRB("com.freerdp.api", "IFCALLRESULT(" #_cb ") == NULL"); \
(_default_return); \
}); \
})
#else
#define IFCALLRESULT(_default_return, _cb, ...) (_cb != NULL) ? _cb(__VA_ARGS__) : (_default_return)
#endif
#ifdef __GNUC__ #ifdef __GNUC__
#define ALIGN64 __attribute__((aligned(8))) #define ALIGN64 __attribute__((aligned(8)))

View File

@ -3286,10 +3286,7 @@ BOOL update_begin_paint(rdpUpdate* update)
WINPR_ASSERT(update); WINPR_ASSERT(update);
rdp_update_lock(update); rdp_update_lock(update);
if (!update->BeginPaint) return IFCALLRESULT(TRUE, update->BeginPaint, update->context);
return TRUE;
return update->BeginPaint(update->context);
} }
BOOL update_end_paint(rdpUpdate* update) BOOL update_end_paint(rdpUpdate* update)
@ -3299,8 +3296,7 @@ BOOL update_end_paint(rdpUpdate* update)
if (!update) if (!update)
return FALSE; return FALSE;
if (update->EndPaint) IFCALLRET(update->EndPaint, rc, update->context);
rc = update->EndPaint(update->context);
rdp_update_unlock(update); rdp_update_unlock(update);
return rc; return rc;