From 26d5cf784a2174c4cde90cf71d88848d606d54e8 Mon Sep 17 00:00:00 2001 From: Olaf Bergmann Date: Thu, 31 May 2018 11:03:51 +0200 Subject: [PATCH] coap_{notls,openssl,tinydtls}.c: quiet 'unused function' warning Depending on the TLS library being used (which may be none), the code that depends on other TLS libraries is not compiled. Because some compilers are not happy compiling empty modules, each of these files contains an empty static inline function dummy() that gets compiled instead. As clang happens to emit a warning for this function when -Wunused-function is set, this change introduces a GCC pragma (sic!) to suppress this warning for the dummy function. --- src/coap_notls.c | 7 ++++++- src/coap_openssl.c | 7 ++++++- src/coap_tinydtls.c | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/coap_notls.c b/src/coap_notls.c index 621ab0f4..64dd9f04 100644 --- a/src/coap_notls.c +++ b/src/coap_notls.c @@ -165,8 +165,13 @@ ssize_t coap_tls_read(coap_session_t *session UNUSED, #else /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL */ -/* make compilers happy that do not like empty modules */ +/* Make compilers happy that do not like empty modules. As this + * function is never used, we ignore -Wunused-function temporarily. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" static inline void dummy(void) { } +#pragma GCC diagnostic pop #endif /* !HAVE_LIBTINYDTLS && !HAVE_OPENSSL */ diff --git a/src/coap_openssl.c b/src/coap_openssl.c index 58db28f3..2a20ecdb 100644 --- a/src/coap_openssl.c +++ b/src/coap_openssl.c @@ -1174,8 +1174,13 @@ ssize_t coap_tls_read(coap_session_t *session, #else /* !HAVE_OPENSSL */ -/* make compilers happy that do not like empty modules */ +/* Make compilers happy that do not like empty modules. As this + * function is never used, we ignore -Wunused-function temporarily. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" static inline void dummy(void) { } +#pragma GCC diagnostic pop #endif /* HAVE_OPENSSL */ diff --git a/src/coap_tinydtls.c b/src/coap_tinydtls.c index f718c0a4..3a5e6493 100644 --- a/src/coap_tinydtls.c +++ b/src/coap_tinydtls.c @@ -503,8 +503,13 @@ ssize_t coap_tls_read(coap_session_t *session UNUSED, #else /* !HAVE_LIBTINYDTLS */ - /* make compilers happy that do not like empty modules */ +/* Make compilers happy that do not like empty modules. As this + * function is never used, we ignore -Wunused-function temporarily. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-function" static inline void dummy(void) { } +#pragma GCC diagnostic pop #endif /* HAVE_LIBTINYDTLS */