summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorliaotonglang <liaotonglang@gmail.com>2023-01-10 11:20:24 +0800
committerAzat Khuzhin <azat@libevent.org>2023-01-22 16:22:58 +0100
commitc01cb1d685b70bc9ef102e08eba6ea3e928ae59c (patch)
tree6e81cd96e1ed372977a0514ba290e3633c55eaa8
parent94cc08fde2c04cde3df2291f02631a26ccf27ee0 (diff)
downloadlibevent-c01cb1d685b70bc9ef102e08eba6ea3e928ae59c.tar.gz
Fix ignoring return value of arc4random() warning (with _FORTIFY_SOURCE defined)
arc4random() defines with __wur (warn-unused-return) macro in glibc, but the problem pops up only for gentoo, since only it really define __wur to __attribute__ ((__warn_unused_result__)), because it defines _FORTIFY_SOURCE unconditionally [1]. [1]: https://gitweb.gentoo.org/proj/gcc-patches.git/tree/9.4.0/gentoo/01_all_default-fortify-source.patch?id=7f7f80a650607c3090ae0790b8daef88434da681 And hence you get this error: ```sh docker run -v $PWD:/src:ro --rm --name le -w /src -it gentoo/stage3 bash -c 'mkdir /build && cd /build && /src/configure --enable-gcc-warnings=yes --disable-samples && make -j && echo OK' /src/evutil_rand.c: In function 'evutil_secure_rng_init': /src/evutil_rand.c:56:16: error: ignoring return value of 'arc4random' declared with attribute 'warn_unused_result' [-Werror=unused-result] 56 | (void) arc4random(); | ^~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:2056: evutil_rand.lo] Error 1 make[1]: *** Waiting for unfinished jobs.... make[1]: Leaving directory '/build' make: *** [Makefile:1523: all] Error 2 ``` Also it seems that GCC works as expected here [2], and will not change the behavior. [2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66425
-rw-r--r--evutil_rand.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/evutil_rand.c b/evutil_rand.c
index 8e9afdaa..139d0d03 100644
--- a/evutil_rand.c
+++ b/evutil_rand.c
@@ -53,7 +53,7 @@ int
evutil_secure_rng_init(void)
{
/* call arc4random() now to force it to self-initialize */
- (void) arc4random();
+ (void)! arc4random();
return 0;
}
#ifndef EVENT__DISABLE_THREAD_SUPPORT