Merge pull request #3282 from gabor-mezei-arm/2905_missing_cleanup_in_ssl_tests

Force cleanup by using goto exit instead of direct return
diff --git a/ChangeLog.d/_GNU_SOURCE-redefined.txt b/ChangeLog.d/_GNU_SOURCE-redefined.txt
new file mode 100644
index 0000000..59c8a15
--- /dev/null
+++ b/ChangeLog.d/_GNU_SOURCE-redefined.txt
@@ -0,0 +1,3 @@
+Bugfix
+   * Fix the build when the macro _GNU_SOURCE is defined to a non-empty value.
+     Fix #3432.
diff --git a/ChangeLog.d/getrandom.txt b/ChangeLog.d/getrandom.txt
deleted file mode 100644
index 87a3a6c..0000000
--- a/ChangeLog.d/getrandom.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-Changes
-   Use glibc's getrandom() instead of syscall when glibc > 2.25.
diff --git a/library/entropy_poll.c b/library/entropy_poll.c
index 0f992f3..5250a7b 100644
--- a/library/entropy_poll.c
+++ b/library/entropy_poll.c
@@ -17,16 +17,10 @@
  *  limitations under the License.
  */
 
-#if defined(__linux__)
-#if !defined(_GNU_SOURCE)
+#if defined(__linux__) && !defined(_GNU_SOURCE)
 /* Ensure that syscall() is available even when compiling with -std=c99 */
 #define _GNU_SOURCE
 #endif
-#include <features.h>
-#if __GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 25)
-#define HAVE_SYS_RANDOM 1
-#endif
-#endif
 
 #include "common.h"
 
@@ -92,16 +86,10 @@
 
 /*
  * Test for Linux getrandom() support.
- * When the C library is GNU libc and its version is greater than 2.25,
- * include sys/random.h to use getrandom(),
- * otherwise use the generic use the generic syscall wrapper
+ * Since there is no wrapper in the libc yet, use the generic syscall wrapper
  * available in GNU libc and compatible libc's (eg uClibc).
  */
-#if HAVE_SYS_RANDOM
-#include <sys/random.h>
-#include <errno.h>
-#define HAVE_GETRANDOM
-#elif (defined(__linux__) && defined(__GLIBC__)) || defined(__midipix__)
+#if ((defined(__linux__) && defined(__GLIBC__)) || defined(__midipix__))
 #include <unistd.h>
 #include <sys/syscall.h>
 #if defined(SYS_getrandom)
@@ -167,11 +155,7 @@
     ((void) data);
 
 #if defined(HAVE_GETRANDOM)
-#if HAVE_SYS_RANDOM
-    ret = getrandom(output, len, 0);
-#else
     ret = getrandom_wrapper( output, len, 0 );
-#endif
     if( ret >= 0 )
     {
         *olen = ret;