From: Nick Mathewson <nickm@torproject.org>
Date: Thu, 19 Sep 2013 14:43:54 +0000 (-0400)
Subject: Fix a compiler warning when checking for arc4random_buf linker breakage.
X-Git-Tag: release-2.0.22-stable~25
X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cb3865a40d1c42ecf7a3dd2dc4a42e0d5b13d49;p=libevent

Fix a compiler warning when checking for arc4random_buf linker breakage.

Patch by Ralph Castain.
---

diff --git a/evutil_rand.c b/evutil_rand.c
index 3c2c81de..4df685ca 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -76,8 +76,11 @@ ev_arc4random_buf(void *buf, size_t n)
 	 * and fall back otherwise.  (OSX does this using some linker
 	 * trickery.)
 	 */
-	if (arc4random_buf != NULL) {
-		return arc4random_buf(buf, n);
+	{
+		void (*tptr)() = (void*)arc4random_buf;
+		if (tptr != NULL) {
+			return arc4random_buf(buf, n);
+		}
 	}
 #endif
 	/* Make sure that we start out with b at a 4-byte alignment; plenty