aboutsummaryrefslogtreecommitdiff
path: root/include/libssh/priv.h
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2011-08-21 10:10:27 +0200
committerAndreas Schneider <asn@cryptomilk.org>2011-08-21 10:10:27 +0200
commitab0354dbb69aa6aa55427ccb8a6e696879b272cf (patch)
treed3d351cccaf838b67abc8f64dc1fe02fc83de1b7 /include/libssh/priv.h
parentce41747faef799e8723840c0cd640ba44bbcc834 (diff)
downloadlibssh-ab0354dbb69aa6aa55427ccb8a6e696879b272cf.tar.gz
libssh-ab0354dbb69aa6aa55427ccb8a6e696879b272cf.tar.xz
libssh-ab0354dbb69aa6aa55427ccb8a6e696879b272cf.zip
priv: Add discard_const macros.
Diffstat (limited to 'include/libssh/priv.h')
-rw-r--r--include/libssh/priv.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 0859f4b9..d7ba68df 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);