diff options
-rw-r--r-- | include/libssh/priv.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h index 0859f4b..d7ba68d 100644 --- a/include/libssh/priv.h +++ b/include/libssh/priv.h @@ -278,6 +278,25 @@ SSH_PACKET_CALLBACK(ssh_packet_kexdh_init); /** Overwrite the complete string with 'X' */ #define BURN_STRING(x) do { if ((x) != NULL) memset((x), 'X', strlen((x))); } while(0) +/** + * This is a hack to fix warnings. The idea is to use this everywhere that we + * get the "discarding const" warning by the compiler. That doesn't actually + * fix the real issue, but marks the place and you can search the code for + * discard_const. + * + * Please use this macro only when there is no other way to fix the warning. + * We should use this function in only in a very few places. + * + * Also, please call this via the discard_const_p() macro interface, as that + * makes the return type safe. + */ +#define discard_const(ptr) ((void *)((uintptr_t)(ptr))) + +/** + * Type-safe version of discard_const + */ +#define discard_const_p(type, ptr) ((type *)discard_const(ptr)) + #ifdef HAVE_LIBGCRYPT /* gcrypt_missing.c */ int my_gcry_dec2bn(bignum *bn, const char *data); |