Skip to content

Commit 2796c6e

Browse files
author
MarcoFalke
committed
Merge #14214: convert C-style (void) parameter lists to C++ style ()
3ccfa34 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
2 parents 9a3a984 + 3ccfa34 commit 2796c6e

16 files changed

+27
-27
lines changed

src/httprpc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ static const char* WWW_AUTH_HEADER_DATA = "Basic realm=\"jsonrpc\"";
3131
class HTTPRPCTimer : public RPCTimerBase
3232
{
3333
public:
34-
HTTPRPCTimer(struct event_base* eventBase, std::function<void(void)>& func, int64_t millis) :
34+
HTTPRPCTimer(struct event_base* eventBase, std::function<void()>& func, int64_t millis) :
3535
ev(eventBase, false, func)
3636
{
3737
struct timeval tv;
@@ -53,7 +53,7 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
5353
{
5454
return "HTTP";
5555
}
56-
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) override
56+
RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis) override
5757
{
5858
return new HTTPRPCTimer(base, func, millis);
5959
}

src/httpserver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ static void httpevent_callback_fn(evutil_socket_t, short, void* data)
498498
delete self;
499499
}
500500

501-
HTTPEvent::HTTPEvent(struct event_base* base, bool _deleteWhenTriggered, const std::function<void(void)>& _handler):
501+
HTTPEvent::HTTPEvent(struct event_base* base, bool _deleteWhenTriggered, const std::function<void()>& _handler):
502502
deleteWhenTriggered(_deleteWhenTriggered), handler(_handler)
503503
{
504504
ev = event_new(base, -1, 0, httpevent_callback_fn, this);

src/httpserver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class HTTPEvent
134134
* deleteWhenTriggered deletes this event object after the event is triggered (and the handler called)
135135
* handler is the handler to call when the event is triggered.
136136
*/
137-
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void(void)>& handler);
137+
HTTPEvent(struct event_base* base, bool deleteWhenTriggered, const std::function<void()>& handler);
138138
~HTTPEvent();
139139

140140
/** Trigger the event. If tv is 0, trigger it immediately. Otherwise trigger it after
@@ -143,7 +143,7 @@ class HTTPEvent
143143
void trigger(struct timeval* tv);
144144

145145
bool deleteWhenTriggered;
146-
std::function<void(void)> handler;
146+
std::function<void()> handler;
147147
private:
148148
struct event* ev;
149149
};

src/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static void ThreadImport(std::vector<fs::path> vImportFiles)
691691
* Ensure that Bitcoin is running in a usable environment with all
692692
* necessary library support.
693693
*/
694-
static bool InitSanityCheck(void)
694+
static bool InitSanityCheck()
695695
{
696696
if(!ECC_InitSanityCheck()) {
697697
InitError("Elliptic curve cryptography sanity check failure. Aborting.");

src/key.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -181,12 +181,12 @@ struct CExtKey {
181181
};
182182

183183
/** Initialize the elliptic curve support. May not be called twice without calling ECC_Stop first. */
184-
void ECC_Start(void);
184+
void ECC_Start();
185185

186186
/** Deinitialize the elliptic curve support. No-op if ECC_Start wasn't called first. */
187-
void ECC_Stop(void);
187+
void ECC_Stop();
188188

189189
/** Check that required EC support is available at runtime. */
190-
bool ECC_InitSanityCheck(void);
190+
bool ECC_InitSanityCheck();
191191

192192
#endif // BITCOIN_KEY_H

src/qt/bitcoin.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,7 @@ int main(int argc, char *argv[])
586586
// Need to pass name here as CAmount is a typedef (see http://qt-project.org/doc/qt-5/qmetatype.html#qRegisterMetaType)
587587
// IMPORTANT if it is no longer a typedef use the normal variant above
588588
qRegisterMetaType< CAmount >("CAmount");
589-
qRegisterMetaType< std::function<void(void)> >("std::function<void(void)>");
589+
qRegisterMetaType< std::function<void()> >("std::function<void()>");
590590
#ifdef ENABLE_WALLET
591591
qRegisterMetaType<WalletModel*>("WalletModel*");
592592
#endif

src/qt/macnotificationhandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class MacNotificationHandler : public QObject
1919
void showNotification(const QString &title, const QString &text);
2020

2121
/** check if OS can handle UserNotifications */
22-
bool hasUserNotificationCenterSupport(void);
22+
bool hasUserNotificationCenterSupport();
2323
static MacNotificationHandler *instance();
2424
};
2525

src/qt/rpcconsole.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase
101101
{
102102
Q_OBJECT
103103
public:
104-
QtRPCTimerBase(std::function<void(void)>& _func, int64_t millis):
104+
QtRPCTimerBase(std::function<void()>& _func, int64_t millis):
105105
func(_func)
106106
{
107107
timer.setSingleShot(true);
@@ -111,15 +111,15 @@ class QtRPCTimerBase: public QObject, public RPCTimerBase
111111
~QtRPCTimerBase() {}
112112
private:
113113
QTimer timer;
114-
std::function<void(void)> func;
114+
std::function<void()> func;
115115
};
116116

117117
class QtRPCTimerInterface: public RPCTimerInterface
118118
{
119119
public:
120120
~QtRPCTimerInterface() {}
121121
const char *Name() { return "Qt"; }
122-
RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis)
122+
RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis)
123123
{
124124
return new QtRPCTimerBase(func, millis);
125125
}

src/rpc/server.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface)
540540
timerInterface = nullptr;
541541
}
542542

543-
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds)
543+
void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds)
544544
{
545545
if (!timerInterface)
546546
throw JSONRPCError(RPC_INTERNAL_ERROR, "No timer handler registered for RPC");

src/rpc/server.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ class RPCTimerInterface
110110
* This is needed to cope with the case in which there is no HTTP server, but
111111
* only GUI RPC console, and to break the dependency of pcserver on httprpc.
112112
*/
113-
virtual RPCTimerBase* NewTimer(std::function<void(void)>& func, int64_t millis) = 0;
113+
virtual RPCTimerBase* NewTimer(std::function<void()>& func, int64_t millis) = 0;
114114
};
115115

116116
/** Set the factory function for timers */
@@ -124,7 +124,7 @@ void RPCUnsetTimerInterface(RPCTimerInterface *iface);
124124
* Run func nSeconds from now.
125125
* Overrides previous timer <name> (if any).
126126
*/
127-
void RPCRunLater(const std::string& name, std::function<void(void)> func, int64_t nSeconds);
127+
void RPCRunLater(const std::string& name, std::function<void()> func, int64_t nSeconds);
128128

129129
typedef UniValue(*rpcfn_type)(const JSONRPCRequest& jsonRequest);
130130

0 commit comments

Comments
 (0)