mirror of
https://github.com/morgan9e/FreeRDP
synced 2026-04-15 00:44:19 +09:00
[utils,smartcard] log all call failures
Use GNU expression statement to log a call failure if the compiler supports that extension.
This commit is contained in:
@@ -49,17 +49,30 @@
|
|||||||
#if defined(WITH_SMARTCARD_EMULATE)
|
#if defined(WITH_SMARTCARD_EMULATE)
|
||||||
#include <freerdp/emulate/scard/smartcard_emulate.h>
|
#include <freerdp/emulate/scard/smartcard_emulate.h>
|
||||||
|
|
||||||
#define wrap(ctx, fkt, ...) \
|
#define wrap_raw(ctx, fkt, ...) \
|
||||||
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) \
|
ctx->useEmulatedCard ? Emulate_##fkt(ctx->emulation, ##__VA_ARGS__) \
|
||||||
: ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
: ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||||
#define wrap_ptr(ctx, fkt, ...) wrap(ctx, fkt, ##__VA_ARGS__)
|
#define wrap_ptr(ctx, fkt, ...) wrap_raw(ctx, fkt, ##__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define wrap(ctx, fkt, ...) \
|
#define wrap_raw(ctx, fkt, ...) \
|
||||||
ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
ctx->useEmulatedCard ? SCARD_F_INTERNAL_ERROR : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||||
#define wrap_ptr(ctx, fkt, ...) \
|
#define wrap_ptr(ctx, fkt, ...) \
|
||||||
ctx->useEmulatedCard ? nullptr : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
ctx->useEmulatedCard ? nullptr : ctx->pWinSCardApi->pfn##fkt(__VA_ARGS__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
#define wrap(ctx, fkt, ...) wrap_raw(ctx, fkt, ##__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define wrap(ctx, fkt, ...) \
|
||||||
|
__extension__({ \
|
||||||
|
LONG defstatus = wrap_raw(ctx, fkt, ##__VA_ARGS__); \
|
||||||
|
if (defstatus != SCARD_S_SUCCESS) \
|
||||||
|
WLog_Print(ctx->log, WLOG_TRACE, "[" #fkt "] failed with %s", \
|
||||||
|
SCardGetErrorString(defstatus)); \
|
||||||
|
defstatus; \
|
||||||
|
})
|
||||||
|
#endif
|
||||||
|
|
||||||
struct s_scard_call_context
|
struct s_scard_call_context
|
||||||
{
|
{
|
||||||
BOOL useEmulatedCard;
|
BOOL useEmulatedCard;
|
||||||
@@ -1999,7 +2012,7 @@ void smartcard_call_context_free(scard_call_context* ctx)
|
|||||||
if (ctx->StartedEvent)
|
if (ctx->StartedEvent)
|
||||||
{
|
{
|
||||||
WINPR_ASSERT(ctx->useEmulatedCard || ctx->pWinSCardApi);
|
WINPR_ASSERT(ctx->useEmulatedCard || ctx->pWinSCardApi);
|
||||||
wrap(ctx, SCardReleaseStartedEvent);
|
wrap_raw(ctx, SCardReleaseStartedEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->useEmulatedCard)
|
if (ctx->useEmulatedCard)
|
||||||
|
|||||||
Reference in New Issue
Block a user