aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@cryptomilk.org>2018-11-30 17:37:07 +0100
committerAndreas Schneider <asn@cryptomilk.org>2018-11-30 18:25:12 +0100
commit109a203453e782bcaa8ac5662aac74397fa0cc1a (patch)
tree78de66037b2622030fe547e433f2d24fa1340966
parentac8b9540198c7df5314f8ab709d6a5ecdd2c37a4 (diff)
downloadlibssh-109a203453e782bcaa8ac5662aac74397fa0cc1a.tar.gz
libssh-109a203453e782bcaa8ac5662aac74397fa0cc1a.tar.xz
libssh-109a203453e782bcaa8ac5662aac74397fa0cc1a.zip
include: Add macro for unused arguments and variables
Signed-off-by: Andreas Schneider <asn@cryptomilk.org>
-rw-r--r--ConfigureChecks.cmake20
-rw-r--r--config.h.cmake1
-rw-r--r--include/libssh/priv.h18
-rw-r--r--src/pki_crypto.c3
4 files changed, 38 insertions, 4 deletions
diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake
index c549d8fc..d4e9f105 100644
--- a/ConfigureChecks.cmake
+++ b/ConfigureChecks.cmake
@@ -344,6 +344,26 @@ int main(void) {
}" HAVE_FALLTHROUGH_ATTRIBUTE)
check_c_source_compiles("
+#define __unused __attribute__((unused))
+
+static int do_nothing(int i __unused)
+{
+ return 0;
+}
+
+int main(void)
+{
+ int i;
+
+ i = do_nothing(5);
+ if (i > 5) {
+ return 1;
+ }
+
+ return 0;
+}" HAVE_UNUSED_ATTRIBUTE)
+
+check_c_source_compiles("
#include <string.h>
int main(void)
diff --git a/config.h.cmake b/config.h.cmake
index f4659049..ff87538c 100644
--- a/config.h.cmake
+++ b/config.h.cmake
@@ -213,6 +213,7 @@
#cmakedefine HAVE_MSC_THREAD_LOCAL_STORAGE 1
#cmakedefine HAVE_FALLTHROUGH_ATTRIBUTE 1
+#cmakedefine HAVE_UNUSED_ATTRIBUTE 1
#cmakedefine HAVE_CONSTRUCTOR_ATTRIBUTE 1
#cmakedefine HAVE_DESTRUCTOR_ATTRIBUTE 1
diff --git a/include/libssh/priv.h b/include/libssh/priv.h
index 01659411..de7ffdf2 100644
--- a/include/libssh/priv.h
+++ b/include/libssh/priv.h
@@ -302,8 +302,6 @@ int ssh_connector_remove_event(ssh_connector connector);
void explicit_bzero(void *s, size_t n);
#endif /* !HAVE_EXPLICIT_BZERO */
-#define UNUSED(x) (void)(x)
-
/**
* 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
@@ -388,6 +386,22 @@ void explicit_bzero(void *s, size_t n);
# endif /* HAVE_FALLTHROUGH_ATTRIBUTE */
#endif /* FALL_THROUGH */
+#ifndef __unused__
+# ifdef HAVE_UNUSED_ATTRIBUTE
+# define __unused__ __attribute__((unused))
+# else /* HAVE_UNUSED_ATTRIBUTE */
+# define __unused__
+# endif /* HAVE_UNUSED_ATTRIBUTE */
+#endif /* __unused__ */
+
+#ifndef UNUSED_PARAM
+#define UNUSED_PARAM(param) param __unused__
+#endif /* UNUSED_PARAM */
+
+#ifndef UNUSED_VAR
+#define UNUSED_VAR(var) __unused__ var
+#endif /* UNUSED_VAR */
+
void ssh_agent_state_free(void *data);
#endif /* _LIBSSH_PRIV_H */
diff --git a/src/pki_crypto.c b/src/pki_crypto.c
index 617f9bea..f37dc093 100644
--- a/src/pki_crypto.c
+++ b/src/pki_crypto.c
@@ -1038,7 +1038,7 @@ int pki_privkey_build_rsa(ssh_key key,
ssh_string n,
ssh_string e,
ssh_string d,
- ssh_string iqmp,
+ UNUSED_PARAM(ssh_string iqmp),
ssh_string p,
ssh_string q)
{
@@ -1053,7 +1053,6 @@ int pki_privkey_build_rsa(ssh_key key,
bn = ssh_make_string_bn(n);
be = ssh_make_string_bn(e);
bd = ssh_make_string_bn(d);
- UNUSED(iqmp);
/*biqmp = ssh_make_string_bn(iqmp);*/
bp = ssh_make_string_bn(p);
bq = ssh_make_string_bn(q);