]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
arc4random: Fix 'redundant redeclaration’ warnings 13197/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 31 Aug 2023 09:40:46 +0000 (11:40 +0200)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 31 Aug 2023 09:40:46 +0000 (11:40 +0200)
If `arc4random.hh` is included before `config.h`, the `HAVE_*` defines
are not yet available and thus we include the definition of the following
functions even though they might be available in the standard headers:
- `arc4random`
- `arc4random_buf`
- `arc4random_uniform`
- `explicit_bzero`

Yielding warnings:
```
In file included from dns_random.hh:27,
                 from tsigutils.cc:25:
../ext/arc4random/arc4random.hh:9:12: warning: redundant redeclaration of ‘uint32_t arc4random()’ in same scope [-Wredundant-decls]
    9 |   uint32_t arc4random(void);
      |            ^~~~~~~~~~
In file included from /usr/include/c++/13.2.1/cstdlib:79,
                 from /usr/include/c++/13.2.1/ext/string_conversions.h:43,
                 from /usr/include/c++/13.2.1/bits/basic_string.h:4097,
                 from /usr/include/c++/13.2.1/string:54,
                 from dnsname.hh:26,
                 from tsigutils.cc:23:
/usr/include/stdlib.h:657:19: note: previous declaration of ‘__uint32_t arc4random()’
  657 | extern __uint32_t arc4random (void)
      |                   ^~~~~~~~~~
../ext/arc4random/arc4random.hh:12:8: warning: redundant redeclaration of ‘void arc4random_buf(void*, size_t)’ in same scope [-Wredundant-decls]
   12 |   void arc4random_buf(void* buf, size_t nbytes);
      |        ^~~~~~~~~~~~~~
/usr/include/stdlib.h:661:13: note: previous declaration of ‘void arc4random_buf(void*, size_t)’
  661 | extern void arc4random_buf (void *__buf, size_t __size)
      |             ^~~~~~~~~~~~~~
../ext/arc4random/arc4random.hh:15:12: warning: redundant redeclaration of ‘uint32_t arc4random_uniform(uint32_t)’ in same scope [-Wredundant-decls]
   15 |   uint32_t arc4random_uniform(uint32_t upper_bound);
      |            ^~~~~~~~~~~~~~~~~~
/usr/include/stdlib.h:666:19: note: previous declaration of ‘__uint32_t arc4random_uniform(__uint32_t)’
  666 | extern __uint32_t arc4random_uniform (__uint32_t __upper_bound)
      |                   ^~~~~~~~~~~~~~~~~~
../ext/arc4random/arc4random.hh:18:8: warning: redundant redeclaration of ‘void explicit_bzero(void*, size_t)’ in same scope [-Wredundant-decls]
   18 |   void explicit_bzero(void*, size_t len);
```

ext/arc4random/arc4random.hh

index cff8dd031ecda124fd23dd29c691efd7dab093c1..6e01712a4f9023eb19d8ca7cd88a52ad36a01c6a 100644 (file)
@@ -1,8 +1,9 @@
 #pragma once
-
 #include <cstddef>
 #include <cinttypes>
 
+#include "config.h"
+
 extern "C"
 {
 #ifndef HAVE_ARC4RANDOM