From b1398584c4bcb62a1ea1f239c9cbdd2b63be1ebf Mon Sep 17 00:00:00 2001 From: MarcoFalke Date: Thu, 20 Sep 2018 17:57:13 -0400 Subject: [PATCH] Merge #14214: convert C-style (void) parameter lists to C++ style () 3ccfa34b32 convert C-style (void) parameter lists to C++ style () (Arvid Norberg) Pull request description: In C, an empty parameter list, `()`, means the function takes any arguments, and `(void)` means the function does not take any parameters. In C++, an empty parameter list means the function does not take any parameters. So, C++ still supports `(void)` parameter lists with the same semantics, why change to `()`? 1. removing the redundant `void` improves signal-to-noise ratio of the code 2. using `(void)` exposes a rare inconsistency in that a template taking a template `(T)` parameter list, cannot be instantiated with `T=void` Tree-SHA512: be2897b6c5e474873aa878ed6bac098382cd21866aec33752fe40b089a6331aa6263cae749aba1b4a41e8467f1a47086d32eb74abaf09927fd5a2f44a4b2109a # Conflicts: # src/qt/rpcconsole.cpp --- src/httprpc.cpp | 4 ++-- src/httpserver.cpp | 2 +- src/httpserver.h | 4 ++-- src/init.cpp | 2 +- src/key.h | 6 +++--- src/qt/dash.cpp | 2 +- src/qt/macnotificationhandler.h | 2 +- src/qt/rpcconsole.cpp | 6 +++--- src/rpc/server.cpp | 2 +- src/rpc/server.h | 4 ++-- src/scheduler.cpp | 4 ++-- src/scheduler.h | 6 +++--- src/test/crypto_tests.cpp | 2 +- src/util/system.cpp | 2 +- src/util/system.h | 2 +- src/validation.cpp | 4 ++-- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/httprpc.cpp b/src/httprpc.cpp index bc65581b27..2305c9d704 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -30,7 +30,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\""; class HTTPRPCTimer : public RPCTimerBase { public: - HTTPRPCTimer(struct event_base* eventBase, std::function& func, int64_t millis) : + HTTPRPCTimer(struct event_base* eventBase, std::function& func, int64_t millis) : ev(eventBase, false, func) { struct timeval tv; @@ -52,7 +52,7 @@ public: { return "HTTP"; } - RPCTimerBase* NewTimer(std::function& func, int64_t millis) override + RPCTimerBase* NewTimer(std::function& func, int64_t millis) override { return new HTTPRPCTimer(base, func, millis); } diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 23d0eacb95..127edc2594 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -507,7 +507,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data) delete self; } -HTTPEvent::HTTPEvent(struct event_base* base, bool _deleteWhenTriggered, const std::function& _handler): +HTTPEvent::HTTPEvent(struct event_base* base, bool _deleteWhenTriggered, const std::function& _handler): deleteWhenTriggered(_deleteWhenTriggered), handler(_handler) { ev = event_new(base, -1, 0, httpevent_callback_fn, this); diff --git a/src/httpserver.h b/src/httpserver.h index b1f21e5f26..d73a250885 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -134,7 +134,7 @@ public: * deleteWhenTriggered deletes this event object after the event is triggered (and the handler called) * handler is the handler to call when the event is triggered. */ - HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function& handler); + HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function& handler); ~HTTPEvent(); /** Trigger the event. If tv is 0, trigger it immediately. Otherwise trigger it after @@ -143,7 +143,7 @@ public: void trigger(struct timeval* tv); bool deleteWhenTriggered; - std::function handler; + std::function handler; private: struct event* ev; }; diff --git a/src/init.cpp b/src/init.cpp index 1a0a4d5f26..b7a443f354 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -994,7 +994,7 @@ void PeriodicStats() * Ensure that Dash Core is running in a usable environment with all * necessary library support. */ -static bool InitSanityCheck(void) +static bool InitSanityCheck() { if(!ECC_InitSanityCheck()) { InitError("Elliptic curve cryptography sanity check failure. Aborting."); diff --git a/src/key.h b/src/key.h index 92e31652da..46be6f4772 100644 --- a/src/key.h +++ b/src/key.h @@ -181,12 +181,12 @@ struct CExtKey { }; /** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */ -void ECC_Start(void); +void ECC_Start(); /** Deinitialize the elliptic curve support. No-op if ECC_Start wasn't called first. */ -void ECC_Stop(void); +void ECC_Stop(); /** Check that required EC support is available at runtime. */ -bool ECC_InitSanityCheck(void); +bool ECC_InitSanityCheck(); #endif // BITCOIN_KEY_H diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index 4cacd11b92..5ee7705622 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -598,7 +598,7 @@ int main(int argc, char *argv[]) // Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType) // IMPORTANT if it is no longer a typedef use the normal variant above qRegisterMetaType< CAmount >("CAmount"); - qRegisterMetaType< std::function >("std::function"); + qRegisterMetaType< std::function >("std::function"); #ifdef ENABLE_WALLET qRegisterMetaType("WalletModel*"); #endif diff --git a/src/qt/macnotificationhandler.h b/src/qt/macnotificationhandler.h index 3a005c3c46..b1c07bcfe5 100644 --- a/src/qt/macnotificationhandler.h +++ b/src/qt/macnotificationhandler.h @@ -19,7 +19,7 @@ public: void showNotification(const QString &title, const QString &text); /** check if OS can handle UserNotifications */ - bool hasUserNotificationCenterSupport(void); + bool hasUserNotificationCenterSupport(); static MacNotificationHandler *instance(); }; diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index e4e7b24b27..3d58f5b61f 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -104,7 +104,7 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase { Q_OBJECT public: - QtRPCTimerBase(std::function& _func, int64_t millis): + QtRPCTimerBase(std::function& _func, int64_t millis): func(_func) { timer.setSingleShot(true); @@ -116,7 +116,7 @@ private Q_SLOTS: void timeout() { func(); } private: QTimer timer; - std::function func; + std::function func; }; class QtRPCTimerInterface: public RPCTimerInterface @@ -124,7 +124,7 @@ class QtRPCTimerInterface: public RPCTimerInterface public: ~QtRPCTimerInterface() {} const char *Name() override { return "Qt"; } - RPCTimerBase* NewTimer(std::function& func, int64_t millis) override + RPCTimerBase* NewTimer(std::function& func, int64_t millis) override { return new QtRPCTimerBase(func, millis); } diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 5eec1be298..b8700f163c 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -671,7 +671,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface) timerInterface = nullptr; } -void RPCRunLater(const std::string& name, std::function func, int64_t nSeconds) +void RPCRunLater(const std::string& name, std::function func, int64_t nSeconds) { if (!timerInterface) throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC"); diff --git a/src/rpc/server.h b/src/rpc/server.h index 20a0f7be7e..ee9cc431fb 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -108,7 +108,7 @@ public: * This is needed to cope with the case in which there is no HTTP server, but * only GUI RPC console, and to break the dependency of pcserver on httprpc. */ - virtual RPCTimerBase* NewTimer(std::function& func, int64_t millis) = 0; + virtual RPCTimerBase* NewTimer(std::function& func, int64_t millis) = 0; }; /** Set the factory function for timers */ @@ -122,7 +122,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface); * Run func nSeconds from now. * Overrides previous timer (if any). */ -void RPCRunLater(const std::string& name, std::function func, int64_t nSeconds); +void RPCRunLater(const std::string& name, std::function func, int64_t nSeconds); typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest); diff --git a/src/scheduler.cpp b/src/scheduler.cpp index 9440317ba1..5efe2bf3d2 100644 --- a/src/scheduler.cpp +++ b/src/scheduler.cpp @@ -159,7 +159,7 @@ void SingleThreadedSchedulerClient::MaybeScheduleProcessQueue() { } void SingleThreadedSchedulerClient::ProcessQueue() { - std::function callback; + std::function callback; { LOCK(m_cs_callbacks_pending); if (m_are_callbacks_running) return; @@ -187,7 +187,7 @@ void SingleThreadedSchedulerClient::ProcessQueue() { callback(); } -void SingleThreadedSchedulerClient::AddToProcessQueue(std::function func) { +void SingleThreadedSchedulerClient::AddToProcessQueue(std::function func) { assert(m_pscheduler); { diff --git a/src/scheduler.h b/src/scheduler.h index 0a46c52482..3ad073ee19 100644 --- a/src/scheduler.h +++ b/src/scheduler.h @@ -40,7 +40,7 @@ public: CScheduler(); ~CScheduler(); - typedef std::function Function; + typedef std::function Function; // Call func at/after time t void schedule(Function f, boost::chrono::system_clock::time_point t=boost::chrono::system_clock::now()); @@ -99,7 +99,7 @@ private: CScheduler *m_pscheduler; CCriticalSection m_cs_callbacks_pending; - std::list> m_callbacks_pending GUARDED_BY(m_cs_callbacks_pending); + std::list> m_callbacks_pending GUARDED_BY(m_cs_callbacks_pending); bool m_are_callbacks_running GUARDED_BY(m_cs_callbacks_pending) = false; void MaybeScheduleProcessQueue(); @@ -114,7 +114,7 @@ public: * Practially, this means that callbacks can behave as if they are executed * in order by a single thread. */ - void AddToProcessQueue(std::function func); + void AddToProcessQueue(std::function func); // Processes all remaining queue members on the calling thread, blocking until queue is empty // Must be called after the CScheduler has no remaining processing threads! diff --git a/src/test/crypto_tests.cpp b/src/test/crypto_tests.cpp index 8350226ce8..772d915e0b 100644 --- a/src/test/crypto_tests.cpp +++ b/src/test/crypto_tests.cpp @@ -233,7 +233,7 @@ static void TestPoly1305(const std::string &hexmessage, const std::string &hexke BOOST_CHECK(tag == tagres); } -static std::string LongTestString(void) { +static std::string LongTestString() { std::string ret; for (int i=0; i<200000; i++) { ret += (unsigned char)(i); diff --git a/src/util/system.cpp b/src/util/system.cpp index 94a63f28fb..50dedeecda 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -1322,7 +1322,7 @@ fs::path AbsPathForConfigVal(const fs::path& path, bool net_specific) return fs::absolute(path, GetDataDir(net_specific)); } -int ScheduleBatchPriority(void) +int ScheduleBatchPriority() { #ifdef SCHED_BATCH const static sched_param param{}; diff --git a/src/util/system.h b/src/util/system.h index fc820e2772..bf05dbd551 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -385,7 +385,7 @@ std::string CopyrightHolders(const std::string& strPrefix, unsigned int nStartYe * @return The return value of sched_setschedule(), or 1 on systems without * sched_setchedule(). */ -int ScheduleBatchPriority(void); +int ScheduleBatchPriority(); namespace util { diff --git a/src/validation.cpp b/src/validation.cpp index 5803de7221..4e7b949484 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -5175,7 +5175,7 @@ int VersionBitsTipStateSinceHeight(const Consensus::Params& params, Consensus::D static const uint64_t MEMPOOL_DUMP_VERSION = 1; -bool LoadMempool(void) +bool LoadMempool() { const CChainParams& chainparams = Params(); int64_t nExpiryTimeout = gArgs.GetArg("-mempoolexpiry", DEFAULT_MEMPOOL_EXPIRY) * 60 * 60; @@ -5251,7 +5251,7 @@ bool LoadMempool(void) return true; } -bool DumpMempool(void) +bool DumpMempool() { int64_t start = GetTimeMicros();