Skip to content

Commit aef5ac7

Browse files
committed
Merge bitcoin/bitcoin#29876: build: add -Wundef
e3dc64f build: add -Wundef (fanquake) 82b4395 refactor: use #ifdef HAVE_SOCKADDR_UN (fanquake) 40cd758 randomenv: use ifdef over if (fanquake) 7839503 zmq: use #ifdef ENABLE_ZMQ (fanquake) 79e197b build: Suppress warnings from boost and capnproto in multiprocess code (Ryan Ofsky) Pull request description: Turn on `-Wundef`. [> Warn if an undefined identifier is evaluated in an #if directive. Such identifiers are replaced with zero.](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wundef). Note that this is still beneficial with CMake, and may even be nice to have enabled prior, to catch any change in behaviour. If we end up with this enabled, it should probably be enough to fix #16419. ACKs for top commit: hebasto: ACK e3dc64f, I have reviewed the code and it looks OK. Tree-SHA512: 73436ead07f3a09ba0d30f7105df50d9b2ec8452f11e866bc1c7ebc10c005772ee77fedaa125f444175663c04dfc472f98c2699c63711da356089b66a8cc3e0a
2 parents cf44adf + e3dc64f commit aef5ac7

File tree

5 files changed

+24
-20
lines changed

5 files changed

+24
-20
lines changed

configure.ac

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,7 @@ AX_CHECK_COMPILE_FLAG([-Wimplicit-fallthrough], [WARN_CXXFLAGS="$WARN_CXXFLAGS -
405405
AX_CHECK_COMPILE_FLAG([-Wunreachable-code], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wunreachable-code"], [], [$CXXFLAG_WERROR])
406406
AX_CHECK_COMPILE_FLAG([-Wdocumentation], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wdocumentation"], [], [$CXXFLAG_WERROR])
407407
AX_CHECK_COMPILE_FLAG([-Wself-assign], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wself-assign"], [], [$CXXFLAG_WERROR])
408+
AX_CHECK_COMPILE_FLAG([-Wundef], [WARN_CXXFLAGS="$WARN_CXXFLAGS -Wundef"], [], [$CXXFLAG_WERROR])
408409

409410
dnl Some compilers (gcc) ignore unknown -Wno-* options, but warn about all
410411
dnl unknown options if any other warning is produced. Test the -Wfoo case, and
@@ -1392,6 +1393,9 @@ if test "$with_libmultiprocess" = "yes" || test "$with_libmultiprocess" = "auto"
13921393
PKG_CHECK_MODULES([LIBMULTIPROCESS], [libmultiprocess], [
13931394
libmultiprocess_found=yes;
13941395
libmultiprocess_prefix=`$PKG_CONFIG --variable=prefix libmultiprocess`;
1396+
if test "$suppress_external_warnings" != "no" ; then
1397+
LIBMULTIPROCESS_CFLAGS=SUPPRESS_WARNINGS($LIBMULTIPROCESS_CFLAGS)
1398+
fi
13951399
], [true])
13961400
elif test "$with_libmultiprocess" != "no"; then
13971401
AC_MSG_ERROR([--with-libmultiprocess=$with_libmultiprocess value is not yes, auto, or no])

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ libbitcoin_ipc_a_SOURCES = \
10881088
ipc/process.cpp \
10891089
ipc/process.h \
10901090
ipc/protocol.h
1091-
libbitcoin_ipc_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
1091+
libbitcoin_ipc_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BOOST_CPPFLAGS)
10921092
libbitcoin_ipc_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) $(LIBMULTIPROCESS_CFLAGS)
10931093

10941094
include $(MPGEN_PREFIX)/include/mpgen.mk

src/init.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
#include <boost/signals2/signal.hpp>
111111

112-
#if ENABLE_ZMQ
112+
#ifdef ENABLE_ZMQ
113113
#include <zmq/zmqabstractnotifier.h>
114114
#include <zmq/zmqnotificationinterface.h>
115115
#include <zmq/zmqrpc.h>
@@ -364,7 +364,7 @@ void Shutdown(NodeContext& node)
364364
client->stop();
365365
}
366366

367-
#if ENABLE_ZMQ
367+
#ifdef ENABLE_ZMQ
368368
if (g_zmq_notification_interface) {
369369
if (node.validation_signals) node.validation_signals->UnregisterValidationInterface(g_zmq_notification_interface.get());
370370
g_zmq_notification_interface.reset();
@@ -531,7 +531,7 @@ void SetupServerArgs(ArgsManager& argsman)
531531
argsman.AddArg("-maxreceivebuffer=<n>", strprintf("Maximum per-connection receive buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXRECEIVEBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
532532
argsman.AddArg("-maxsendbuffer=<n>", strprintf("Maximum per-connection memory usage for the send buffer, <n>*1000 bytes (default: %u)", DEFAULT_MAXSENDBUFFER), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
533533
argsman.AddArg("-maxuploadtarget=<n>", strprintf("Tries to keep outbound traffic under the given target per 24h. Limit does not apply to peers with 'download' permission or blocks created within past week. 0 = no limit (default: %s). Optional suffix units [k|K|m|M|g|G|t|T] (default: M). Lowercase is 1000 base while uppercase is 1024 base", DEFAULT_MAX_UPLOAD_TARGET), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
534-
#if HAVE_SOCKADDR_UN
534+
#ifdef HAVE_SOCKADDR_UN
535535
argsman.AddArg("-onion=<ip:port|path>", "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy). May be a local file path prefixed with 'unix:'.", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
536536
#else
537537
argsman.AddArg("-onion=<ip:port>", "Use separate SOCKS5 proxy to reach peers via Tor onion services, set -noonion to disable (default: -proxy)", ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
@@ -544,7 +544,7 @@ void SetupServerArgs(ArgsManager& argsman)
544544
argsman.AddArg("-peerblockfilters", strprintf("Serve compact block filters to peers per BIP 157 (default: %u)", DEFAULT_PEERBLOCKFILTERS), ArgsManager::ALLOW_ANY, OptionsCategory::CONNECTION);
545545
argsman.AddArg("-txreconciliation", strprintf("Enable transaction reconciliations per BIP 330 (default: %d)", DEFAULT_TXRECONCILIATION_ENABLE), ArgsManager::ALLOW_ANY | ArgsManager::DEBUG_ONLY, OptionsCategory::CONNECTION);
546546
argsman.AddArg("-port=<port>", strprintf("Listen for connections on <port> (default: %u, testnet: %u, signet: %u, regtest: %u). Not relevant for I2P (see doc/i2p.md).", defaultChainParams->GetDefaultPort(), testnetChainParams->GetDefaultPort(), signetChainParams->GetDefaultPort(), regtestChainParams->GetDefaultPort()), ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::CONNECTION);
547-
#if HAVE_SOCKADDR_UN
547+
#ifdef HAVE_SOCKADDR_UN
548548
argsman.AddArg("-proxy=<ip:port|path>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled). May be a local file path prefixed with 'unix:' if the proxy supports it.", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
549549
#else
550550
argsman.AddArg("-proxy=<ip:port>", "Connect through SOCKS5 proxy, set -noproxy to disable (default: disabled)", ArgsManager::ALLOW_ANY | ArgsManager::DISALLOW_ELISION, OptionsCategory::CONNECTION);
@@ -578,7 +578,7 @@ void SetupServerArgs(ArgsManager& argsman)
578578

579579
g_wallet_init_interface.AddWalletOptions(argsman);
580580

581-
#if ENABLE_ZMQ
581+
#ifdef ENABLE_ZMQ
582582
argsman.AddArg("-zmqpubhashblock=<address>", "Enable publish hash block in <address>", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ);
583583
argsman.AddArg("-zmqpubhashtx=<address>", "Enable publish hash transaction in <address>", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ);
584584
argsman.AddArg("-zmqpubrawblock=<address>", "Enable publish raw block in <address>", ArgsManager::ALLOW_ANY, OptionsCategory::ZMQ);
@@ -1200,7 +1200,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
12001200
for (const auto& client : node.chain_clients) {
12011201
client->registerRpcs();
12021202
}
1203-
#if ENABLE_ZMQ
1203+
#ifdef ENABLE_ZMQ
12041204
RegisterZMQRPCCommands(tableRPC);
12051205
#endif
12061206

@@ -1325,7 +1325,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
13251325
std::string host_out;
13261326
uint16_t port_out{0};
13271327
if (!SplitHostPort(socket_addr, port_out, host_out)) {
1328-
#if HAVE_SOCKADDR_UN
1328+
#ifdef HAVE_SOCKADDR_UN
13291329
// Allow unix domain sockets for some options e.g. unix:/some/file/path
13301330
if (!unix || socket_addr.find(ADDR_PREFIX_UNIX) != 0) {
13311331
return InitError(InvalidPortErrMsg(arg, socket_addr));
@@ -1472,7 +1472,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
14721472
return InitError(ResolveErrMsg("externalip", strAddr));
14731473
}
14741474

1475-
#if ENABLE_ZMQ
1475+
#ifdef ENABLE_ZMQ
14761476
g_zmq_notification_interface = CZMQNotificationInterface::Create(
14771477
[&chainman = node.chainman](std::vector<uint8_t>& block, const CBlockIndex& index) {
14781478
assert(chainman);

src/netbase.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#include <limits>
2424
#include <memory>
2525

26-
#if HAVE_SOCKADDR_UN
26+
#ifdef HAVE_SOCKADDR_UN
2727
#include <sys/un.h>
2828
#endif
2929

@@ -218,7 +218,7 @@ CService LookupNumeric(const std::string& name, uint16_t portDefault, DNSLookupF
218218

219219
bool IsUnixSocketPath(const std::string& name)
220220
{
221-
#if HAVE_SOCKADDR_UN
221+
#ifdef HAVE_SOCKADDR_UN
222222
if (name.find(ADDR_PREFIX_UNIX) != 0) return false;
223223

224224
// Split off "unix:" prefix
@@ -527,7 +527,7 @@ std::unique_ptr<Sock> CreateSockOS(int domain, int type, int protocol)
527527
return nullptr;
528528
}
529529

530-
#if HAVE_SOCKADDR_UN
530+
#ifdef HAVE_SOCKADDR_UN
531531
if (domain == AF_UNIX) return sock;
532532
#endif
533533

@@ -638,7 +638,7 @@ std::unique_ptr<Sock> Proxy::Connect() const
638638

639639
if (!m_is_unix_socket) return ConnectDirectly(proxy, /*manual_connection=*/true);
640640

641-
#if HAVE_SOCKADDR_UN
641+
#ifdef HAVE_SOCKADDR_UN
642642
auto sock = CreateSock(AF_UNIX, SOCK_STREAM, 0);
643643
if (!sock) {
644644
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "Cannot create a socket for connecting to %s\n", m_unix_socket_path);

src/randomenv.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@
4242
#if HAVE_DECL_GETIFADDRS && HAVE_DECL_FREEIFADDRS
4343
#include <ifaddrs.h>
4444
#endif
45-
#if HAVE_SYSCTL
45+
#ifdef HAVE_SYSCTL
4646
#include <sys/sysctl.h>
47-
#if HAVE_VM_VM_PARAM_H
47+
#ifdef HAVE_VM_VM_PARAM_H
4848
#include <vm/vm_param.h>
4949
#endif
50-
#if HAVE_SYS_RESOURCES_H
50+
#ifdef HAVE_SYS_RESOURCES_H
5151
#include <sys/resources.h>
5252
#endif
53-
#if HAVE_SYS_VMMETER_H
53+
#ifdef HAVE_SYS_VMMETER_H
5454
#include <sys/vmmeter.h>
5555
#endif
5656
#endif
@@ -162,7 +162,7 @@ void AddPath(CSHA512& hasher, const char *path)
162162
}
163163
#endif
164164

165-
#if HAVE_SYSCTL
165+
#ifdef HAVE_SYSCTL
166166
template<int... S>
167167
void AddSysctl(CSHA512& hasher)
168168
{
@@ -274,7 +274,7 @@ void RandAddDynamicEnv(CSHA512& hasher)
274274
AddFile(hasher, "/proc/self/status");
275275
#endif
276276

277-
#if HAVE_SYSCTL
277+
#ifdef HAVE_SYSCTL
278278
# ifdef CTL_KERN
279279
# if defined(KERN_PROC) && defined(KERN_PROC_ALL)
280280
AddSysctl<CTL_KERN, KERN_PROC, KERN_PROC_ALL>(hasher);
@@ -419,7 +419,7 @@ void RandAddStaticEnv(CSHA512& hasher)
419419

420420
// For MacOS/BSDs, gather data through sysctl instead of /proc. Not all of these
421421
// will exist on every system.
422-
#if HAVE_SYSCTL
422+
#ifdef HAVE_SYSCTL
423423
# ifdef CTL_HW
424424
# ifdef HW_MACHINE
425425
AddSysctl<CTL_HW, HW_MACHINE>(hasher);

0 commit comments

Comments
 (0)