From 92c3fd5d5993dfb1a9d305b8037c804dd606f7a3 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 31 Jan 2022 08:38:34 +0100 Subject: [PATCH] Fixed unnecessary cast in headers --- winpr/include/winpr/error.h | 35 ++++---- winpr/include/winpr/smartcard.h | 146 ++++++++++++++++---------------- winpr/test/TestTypes.c | 4 +- 3 files changed, 93 insertions(+), 92 deletions(-) diff --git a/winpr/include/winpr/error.h b/winpr/include/winpr/error.h index b4aac00fa..b0b78db13 100644 --- a/winpr/include/winpr/error.h +++ b/winpr/include/winpr/error.h @@ -42,16 +42,16 @@ #define NO_ERROR 0 #endif -#define E_UNEXPECTED (HRESULT)0x8000FFFFL -#define E_NOTIMPL (HRESULT)0x80004001L -#define E_OUTOFMEMORY (HRESULT)0x8007000EL -#define E_INVALIDARG (HRESULT)0x80070057L -#define E_NOINTERFACE (HRESULT)0x80004002L -#define E_POINTER (HRESULT)0x80004003L -#define E_HANDLE (HRESULT)0x80070006L -#define E_ABORT (HRESULT)0x80004004L -#define E_FAIL (HRESULT)0x80004005L -#define E_ACCESSDENIED (HRESULT)0x80070005L +#define E_UNEXPECTED 0x8000FFFFL +#define E_NOTIMPL 0x80004001L +#define E_OUTOFMEMORY 0x8007000EL +#define E_INVALIDARG 0x80070057L +#define E_NOINTERFACE 0x80004002L +#define E_POINTER 0x80004003L +#define E_HANDLE 0x80070006L +#define E_ABORT 0x80004004L +#define E_FAIL 0x80004005L +#define E_ACCESSDENIED 0x80070005L #define CO_E_INIT_TLS 0x80004006 #define CO_E_INIT_SHARED_ALLOCATOR 0x80004007 @@ -136,16 +136,15 @@ #define HRESULT_CODE(hr) ((hr)&0xFFFF) #define HRESULT_FACILITY(hr) (((hr) >> 16) & 0x1FFF) -#define HRESULT_FROM_NT(x) ((HRESULT)((x) | FACILITY_NT_BIT)) +#define HRESULT_FROM_NT(x) (((x) | FACILITY_NT_BIT)) #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wreserved-id-macro" #endif -#define __HRESULT_FROM_WIN32(x) \ - ((HRESULT)(x) <= 0 ? ((HRESULT)(x)) \ - : ((HRESULT)(((x)&0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000))) +#define __HRESULT_FROM_WIN32(x) \ + ((x) <= 0 ? ((x)) : ((((x)&0x0000FFFF) | (FACILITY_WIN32 << 16) | 0x80000000))) #define HRESULT_FROM_WIN32(x) __HRESULT_FROM_WIN32(x) #if defined(__clang__) @@ -154,8 +153,8 @@ #define HRESULT_SEVERITY(hr) (((hr) >> 31) & 0x1) -#define SUCCEEDED(hr) (((HRESULT)(hr)) >= 0) -#define FAILED(hr) (((HRESULT)(hr)) < 0) +#define SUCCEEDED(hr) (((hr)) >= 0) +#define FAILED(hr) (((hr)) < 0) #define IS_ERROR(Status) (((unsigned long)(Status)) >> 31 == SEVERITY_ERROR) #define MAKE_HRESULT(sev, fac, code) \ @@ -169,8 +168,8 @@ #define MAKE_SCODE(sev, fac, code) \ ((SCODE)(((unsigned long)(sev) << 31) | ((unsigned long)(fac) << 16) | ((unsigned long)(code)))) -#define S_OK ((HRESULT)0L) -#define S_FALSE ((HRESULT)1L) +#define S_OK (0L) +#define S_FALSE (1L) /* System Error Codes (0-499) */ diff --git a/winpr/include/winpr/smartcard.h b/winpr/include/winpr/smartcard.h index 4ec89f5c6..f4caa3796 100644 --- a/winpr/include/winpr/smartcard.h +++ b/winpr/include/winpr/smartcard.h @@ -45,91 +45,91 @@ #define SCARD_S_SUCCESS NO_ERROR -#define SCARD_F_INTERNAL_ERROR (HRESULT)(0x80100001L) -#define SCARD_E_CANCELLED (HRESULT)(0x80100002L) -#define SCARD_E_INVALID_HANDLE (HRESULT)(0x80100003L) -#define SCARD_E_INVALID_PARAMETER (HRESULT)(0x80100004L) -#define SCARD_E_INVALID_TARGET (HRESULT)(0x80100005L) -#define SCARD_E_NO_MEMORY (HRESULT)(0x80100006L) -#define SCARD_F_WAITED_TOO_LONG (HRESULT)(0x80100007L) -#define SCARD_E_INSUFFICIENT_BUFFER (HRESULT)(0x80100008L) -#define SCARD_E_UNKNOWN_READER (HRESULT)(0x80100009L) -#define SCARD_E_TIMEOUT (HRESULT)(0x8010000AL) -#define SCARD_E_SHARING_VIOLATION (HRESULT)(0x8010000BL) -#define SCARD_E_NO_SMARTCARD (HRESULT)(0x8010000CL) -#define SCARD_E_UNKNOWN_CARD (HRESULT)(0x8010000DL) -#define SCARD_E_CANT_DISPOSE (HRESULT)(0x8010000EL) -#define SCARD_E_PROTO_MISMATCH (HRESULT)(0x8010000FL) -#define SCARD_E_NOT_READY (HRESULT)(0x80100010L) -#define SCARD_E_INVALID_VALUE (HRESULT)(0x80100011L) -#define SCARD_E_SYSTEM_CANCELLED (HRESULT)(0x80100012L) -#define SCARD_F_COMM_ERROR (HRESULT)(0x80100013L) -#define SCARD_F_UNKNOWN_ERROR (HRESULT)(0x80100014L) -#define SCARD_E_INVALID_ATR (HRESULT)(0x80100015L) -#define SCARD_E_NOT_TRANSACTED (HRESULT)(0x80100016L) -#define SCARD_E_READER_UNAVAILABLE (HRESULT)(0x80100017L) -#define SCARD_P_SHUTDOWN (HRESULT)(0x80100018L) -#define SCARD_E_PCI_TOO_SMALL (HRESULT)(0x80100019L) -#define SCARD_E_READER_UNSUPPORTED (HRESULT)(0x8010001AL) -#define SCARD_E_DUPLICATE_READER (HRESULT)(0x8010001BL) -#define SCARD_E_CARD_UNSUPPORTED (HRESULT)(0x8010001CL) -#define SCARD_E_NO_SERVICE (HRESULT)(0x8010001DL) -#define SCARD_E_SERVICE_STOPPED (HRESULT)(0x8010001EL) -#define SCARD_E_UNEXPECTED (HRESULT)(0x8010001FL) -#define SCARD_E_ICC_INSTALLATION (HRESULT)(0x80100020L) -#define SCARD_E_ICC_CREATEORDER (HRESULT)(0x80100021L) -#define SCARD_E_UNSUPPORTED_FEATURE (HRESULT)(0x80100022L) -#define SCARD_E_DIR_NOT_FOUND (HRESULT)(0x80100023L) -#define SCARD_E_FILE_NOT_FOUND (HRESULT)(0x80100024L) -#define SCARD_E_NO_DIR (HRESULT)(0x80100025L) -#define SCARD_E_NO_FILE (HRESULT)(0x80100026L) -#define SCARD_E_NO_ACCESS (HRESULT)(0x80100027L) -#define SCARD_E_WRITE_TOO_MANY (HRESULT)(0x80100028L) -#define SCARD_E_BAD_SEEK (HRESULT)(0x80100029L) -#define SCARD_E_INVALID_CHV (HRESULT)(0x8010002AL) -#define SCARD_E_UNKNOWN_RES_MNG (HRESULT)(0x8010002BL) -#define SCARD_E_NO_SUCH_CERTIFICATE (HRESULT)(0x8010002CL) -#define SCARD_E_CERTIFICATE_UNAVAILABLE (HRESULT)(0x8010002DL) -#define SCARD_E_NO_READERS_AVAILABLE (HRESULT)(0x8010002EL) -#define SCARD_E_COMM_DATA_LOST (HRESULT)(0x8010002FL) -#define SCARD_E_NO_KEY_CONTAINER (HRESULT)(0x80100030L) -#define SCARD_E_SERVER_TOO_BUSY (HRESULT)(0x80100031L) -#define SCARD_E_PIN_CACHE_EXPIRED (HRESULT)(0x80100032L) -#define SCARD_E_NO_PIN_CACHE (HRESULT)(0x80100033L) -#define SCARD_E_READ_ONLY_CARD (HRESULT)(0x80100034L) +#define SCARD_F_INTERNAL_ERROR (0x80100001L) +#define SCARD_E_CANCELLED (0x80100002L) +#define SCARD_E_INVALID_HANDLE (0x80100003L) +#define SCARD_E_INVALID_PARAMETER (0x80100004L) +#define SCARD_E_INVALID_TARGET (0x80100005L) +#define SCARD_E_NO_MEMORY (0x80100006L) +#define SCARD_F_WAITED_TOO_LONG (0x80100007L) +#define SCARD_E_INSUFFICIENT_BUFFER (0x80100008L) +#define SCARD_E_UNKNOWN_READER (0x80100009L) +#define SCARD_E_TIMEOUT (0x8010000AL) +#define SCARD_E_SHARING_VIOLATION (0x8010000BL) +#define SCARD_E_NO_SMARTCARD (0x8010000CL) +#define SCARD_E_UNKNOWN_CARD (0x8010000DL) +#define SCARD_E_CANT_DISPOSE (0x8010000EL) +#define SCARD_E_PROTO_MISMATCH (0x8010000FL) +#define SCARD_E_NOT_READY (0x80100010L) +#define SCARD_E_INVALID_VALUE (0x80100011L) +#define SCARD_E_SYSTEM_CANCELLED (0x80100012L) +#define SCARD_F_COMM_ERROR (0x80100013L) +#define SCARD_F_UNKNOWN_ERROR (0x80100014L) +#define SCARD_E_INVALID_ATR (0x80100015L) +#define SCARD_E_NOT_TRANSACTED (0x80100016L) +#define SCARD_E_READER_UNAVAILABLE (0x80100017L) +#define SCARD_P_SHUTDOWN (0x80100018L) +#define SCARD_E_PCI_TOO_SMALL (0x80100019L) +#define SCARD_E_READER_UNSUPPORTED (0x8010001AL) +#define SCARD_E_DUPLICATE_READER (0x8010001BL) +#define SCARD_E_CARD_UNSUPPORTED (0x8010001CL) +#define SCARD_E_NO_SERVICE (0x8010001DL) +#define SCARD_E_SERVICE_STOPPED (0x8010001EL) +#define SCARD_E_UNEXPECTED (0x8010001FL) +#define SCARD_E_ICC_INSTALLATION (0x80100020L) +#define SCARD_E_ICC_CREATEORDER (0x80100021L) +#define SCARD_E_UNSUPPORTED_FEATURE (0x80100022L) +#define SCARD_E_DIR_NOT_FOUND (0x80100023L) +#define SCARD_E_FILE_NOT_FOUND (0x80100024L) +#define SCARD_E_NO_DIR (0x80100025L) +#define SCARD_E_NO_FILE (0x80100026L) +#define SCARD_E_NO_ACCESS (0x80100027L) +#define SCARD_E_WRITE_TOO_MANY (0x80100028L) +#define SCARD_E_BAD_SEEK (0x80100029L) +#define SCARD_E_INVALID_CHV (0x8010002AL) +#define SCARD_E_UNKNOWN_RES_MNG (0x8010002BL) +#define SCARD_E_NO_SUCH_CERTIFICATE (0x8010002CL) +#define SCARD_E_CERTIFICATE_UNAVAILABLE (0x8010002DL) +#define SCARD_E_NO_READERS_AVAILABLE (0x8010002EL) +#define SCARD_E_COMM_DATA_LOST (0x8010002FL) +#define SCARD_E_NO_KEY_CONTAINER (0x80100030L) +#define SCARD_E_SERVER_TOO_BUSY (0x80100031L) +#define SCARD_E_PIN_CACHE_EXPIRED (0x80100032L) +#define SCARD_E_NO_PIN_CACHE (0x80100033L) +#define SCARD_E_READ_ONLY_CARD (0x80100034L) -#define SCARD_W_UNSUPPORTED_CARD (HRESULT)(0x80100065L) -#define SCARD_W_UNRESPONSIVE_CARD (HRESULT)(0x80100066L) -#define SCARD_W_UNPOWERED_CARD (HRESULT)(0x80100067L) -#define SCARD_W_RESET_CARD (HRESULT)(0x80100068L) -#define SCARD_W_REMOVED_CARD (HRESULT)(0x80100069L) -#define SCARD_W_SECURITY_VIOLATION (HRESULT)(0x8010006AL) -#define SCARD_W_WRONG_CHV (HRESULT)(0x8010006BL) -#define SCARD_W_CHV_BLOCKED (HRESULT)(0x8010006CL) -#define SCARD_W_EOF (HRESULT)(0x8010006DL) -#define SCARD_W_CANCELLED_BY_USER (HRESULT)(0x8010006EL) -#define SCARD_W_CARD_NOT_AUTHENTICATED (HRESULT)(0x8010006FL) -#define SCARD_W_CACHE_ITEM_NOT_FOUND (HRESULT)(0x80100070L) -#define SCARD_W_CACHE_ITEM_STALE (HRESULT)(0x80100071L) -#define SCARD_W_CACHE_ITEM_TOO_BIG (HRESULT)(0x80100072L) +#define SCARD_W_UNSUPPORTED_CARD (0x80100065L) +#define SCARD_W_UNRESPONSIVE_CARD (0x80100066L) +#define SCARD_W_UNPOWERED_CARD (0x80100067L) +#define SCARD_W_RESET_CARD (0x80100068L) +#define SCARD_W_REMOVED_CARD (0x80100069L) +#define SCARD_W_SECURITY_VIOLATION (0x8010006AL) +#define SCARD_W_WRONG_CHV (0x8010006BL) +#define SCARD_W_CHV_BLOCKED (0x8010006CL) +#define SCARD_W_EOF (0x8010006DL) +#define SCARD_W_CANCELLED_BY_USER (0x8010006EL) +#define SCARD_W_CARD_NOT_AUTHENTICATED (0x8010006FL) +#define SCARD_W_CACHE_ITEM_NOT_FOUND (0x80100070L) +#define SCARD_W_CACHE_ITEM_STALE (0x80100071L) +#define SCARD_W_CACHE_ITEM_TOO_BIG (0x80100072L) #endif /* ------------------------ missing definition with mingw --------------------*/ #ifndef SCARD_E_PIN_CACHE_EXPIRED -#define SCARD_E_PIN_CACHE_EXPIRED (HRESULT)(0x80100032L) +#define SCARD_E_PIN_CACHE_EXPIRED (0x80100032L) #endif #ifndef SCARD_E_NO_PIN_CACHE -#define SCARD_E_NO_PIN_CACHE (HRESULT)(0x80100033L) +#define SCARD_E_NO_PIN_CACHE (0x80100033L) #endif #ifndef SCARD_E_READ_ONLY_CARD -#define SCARD_E_READ_ONLY_CARD (HRESULT)(0x80100034L) +#define SCARD_E_READ_ONLY_CARD (0x80100034L) #endif #ifndef SCARD_W_CACHE_ITEM_TOO_BIG -#define SCARD_W_CACHE_ITEM_TOO_BIG (HRESULT)(0x80100072L) +#define SCARD_W_CACHE_ITEM_TOO_BIG (0x80100072L) #endif /* -------------------------------------------------------------------------- */ @@ -277,7 +277,8 @@ typedef struct { SCARD_IO_REQUEST ioRequest; BYTE bSw1, bSw2; - union { + union + { SCARD_T0_COMMAND CmdBytes; BYTE rgbHeader[5]; } DUMMYUNIONNAME; @@ -499,7 +500,8 @@ typedef struct DWORD dwShareMode; DWORD dwPreferredProtocols; READER_SEL_REQUEST_MATCH_TYPE MatchType; - union { + union + { struct { DWORD cbReaderNameOffset; diff --git a/winpr/test/TestTypes.c b/winpr/test/TestTypes.c index db12b80f9..639e2ca5d 100644 --- a/winpr/test/TestTypes.c +++ b/winpr/test/TestTypes.c @@ -56,12 +56,12 @@ int TestTypes(int argc, char* argv[]) WINPR_UNUSED(argc); WINPR_UNUSED(argv); - if (S_OK != (HRESULT)0L) + if (S_OK != 0L) { printf("Error: S_OK should be 0\n"); goto err; } - if (S_FALSE != (HRESULT)1L) + if (S_FALSE != 1L) { printf("Error: S_FALSE should be 1\n"); goto err;