Cleaner implementation of MBEDTLS_IGNORE_RETURN
The previous implementation was misparsed in constructs like
`if (condition) MBEDTLS_IGNORE_RETURN(...); else ...;`.
Implement it as an expression, tested with GCC, Clang and MSVC.
Signed-off-by: Gilles Peskine <Gilles.Peskine@arm.com>
diff --git a/include/mbedtls/platform_util.h b/include/mbedtls/platform_util.h
index a90c10a..7e8046a 100644
--- a/include/mbedtls/platform_util.h
+++ b/include/mbedtls/platform_util.h
@@ -205,8 +205,15 @@
*
* Silences warning about unused return value given by functions
* with \c MBEDTLS_CHECK_RETURN attribute.
+/* GCC doesn't silence the warning with just (void)(result).
+ * !(void)(result) is known to work up at least up to GCC 10, as well
+ * as with Clang and MSVC.
+ *
+ * https://gcc.gnu.org/onlinedocs/gcc-3.4.6/gcc/Non_002dbugs.html
+ * https://stackoverflow.com/questions/40576003/ignoring-warning-wunused-result
+ * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425#c34
*/
-#define MBEDTLS_IGNORE_RETURN(result) if( result ) {}
+#define MBEDTLS_IGNORE_RETURN(result) ( (void) !( result ) )
/**
* \brief Securely zeroize a buffer