[warnings] add WINPR_CAST_CONST_PTR_AWAY
simple macro casting a const pointer to a non const one.
This commit is contained in:
parent
245afb706c
commit
889ae65a1f
@ -1311,17 +1311,12 @@ static DWORD WINAPI xf_handle_pipe(void* arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
WINPR_PRAGMA_DIAG_PUSH
|
||||
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
|
||||
freerdp_add_signal_cleanup_handler(pipe, cleanup_pipe);
|
||||
WINPR_PRAGMA_DIAG_POP
|
||||
void* ctx = WINPR_CAST_CONST_PTR_AWAY(pipe, void*);
|
||||
freerdp_add_signal_cleanup_handler(ctx, cleanup_pipe);
|
||||
|
||||
xf_process_pipe(context, pipe);
|
||||
|
||||
WINPR_PRAGMA_DIAG_PUSH
|
||||
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
|
||||
freerdp_del_signal_cleanup_handler(pipe, cleanup_pipe);
|
||||
WINPR_PRAGMA_DIAG_POP
|
||||
freerdp_del_signal_cleanup_handler(ctx, cleanup_pipe);
|
||||
|
||||
unlink(pipe);
|
||||
return 0;
|
||||
|
@ -137,6 +137,17 @@ WINPR_API const char* winpr_get_build_config(void);
|
||||
#define WINPR_UNUSED(x) (void)(x)
|
||||
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) \
|
||||
({ \
|
||||
union \
|
||||
{ \
|
||||
typeof(ptr) src; \
|
||||
dstType dst; \
|
||||
} cnv; \
|
||||
cnv.src = ptr; \
|
||||
cnv.dst; \
|
||||
})
|
||||
|
||||
#define WINPR_FUNC_PTR_CAST(ptr, dstType) \
|
||||
({ \
|
||||
union \
|
||||
@ -148,7 +159,8 @@ WINPR_API const char* winpr_get_build_config(void);
|
||||
cnv.dst; \
|
||||
})
|
||||
#else
|
||||
#define WINPR_FUNC_PTR_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
|
||||
#define WINPR_CAST_CONST_PTR_AWAY(ptr, dstType) (dstType) ptr
|
||||
#define WINPR_CONST_PTR_AWAY_CAST(ptr, dstType) (dstType)(uintptr_t) ptr
|
||||
#endif
|
||||
|
||||
#endif /* WINPR_H */
|
||||
|
@ -230,17 +230,14 @@ BOOL winpr_HMAC_Init(WINPR_HMAC_CTX* ctx, WINPR_MD_TYPE md, const void* key, siz
|
||||
|
||||
#if defined(WITH_OPENSSL)
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x30000000L
|
||||
const char* hash = winpr_md_type_to_string(md);
|
||||
char* hash = WINPR_CAST_CONST_PTR_AWAY(winpr_md_type_to_string(md), char*);
|
||||
|
||||
if (!ctx->xhmac)
|
||||
return FALSE;
|
||||
|
||||
WINPR_PRAGMA_DIAG_PUSH
|
||||
WINPR_PRAGMA_DIAG_IGNORED_QUALIFIERS
|
||||
const char* param_name = OSSL_MAC_PARAM_DIGEST;
|
||||
const OSSL_PARAM param[] = { OSSL_PARAM_construct_utf8_string(param_name, hash, 0),
|
||||
OSSL_PARAM_construct_end() };
|
||||
WINPR_PRAGMA_DIAG_POP
|
||||
|
||||
if (EVP_MAC_init(ctx->xhmac, key, keylen, param) == 1)
|
||||
return TRUE;
|
||||
|
Loading…
Reference in New Issue
Block a user