Skip to content

Commit ad1d6fa

Browse files
committed
Fix -Wunused-parameter
1 parent cb58246 commit ad1d6fa

14 files changed

+61
-58
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
22
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
3-
override CXXFLAGS += -lpthread -Wextra -Wno-unused-parameter -std=c++17 -Isrc -IuSockets/src
3+
override CXXFLAGS += -lpthread -Wextra -std=c++17 -Isrc -IuSockets/src
44
override LDFLAGS += uSockets/*.o -lz
55

66
DESTDIR ?=

examples/BroadcastingEchoServer.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "App.h"
22

3-
struct us_listen_socket_t *listen_socket;
3+
struct us_listen_socket_t *global_listen_socket;
44

55
int main() {
66
/* ws->getUserData returns one of these */
@@ -25,28 +25,28 @@ int main() {
2525
/* Exit gracefully if we get a closedown message (ASAN debug) */
2626
if (message == "closedown") {
2727
/* Bye bye */
28-
us_listen_socket_close(0, listen_socket);
28+
us_listen_socket_close(0, global_listen_socket);
2929
ws->close();
3030
}
3131

3232
/* Simply broadcast every single message we get */
3333
ws->publish("broadcast", message, opCode, true);
3434
},
35-
.drain = [](auto *ws) {
35+
.drain = [](auto */*ws*/) {
3636
/* Check getBufferedAmount here */
3737
},
38-
.ping = [](auto *ws) {
38+
.ping = [](auto */*ws*/) {
3939

4040
},
41-
.pong = [](auto *ws) {
41+
.pong = [](auto */*ws*/) {
4242

4343
},
44-
.close = [](auto *ws, int code, std::string_view message) {
44+
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
4545
/* We automatically unsubscribe from any topic here */
4646
}
47-
}).listen(9001, [](auto *token) {
48-
listen_socket = token;
49-
if (token) {
47+
}).listen(9001, [](auto *listen_socket) {
48+
global_listen_socket = listen_socket;
49+
if (listen_socket) {
5050
std::cout << "Listening on port " << 9001 << std::endl;
5151
}
5252
}).run();

examples/EchoServer.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ int main() {
2525
.maxBackpressure = 1 * 1024 * 1024,
2626
/* Handlers */
2727
.upgrade = nullptr,
28-
.open = [](auto *ws) {
28+
.open = [](auto */*ws*/) {
2929
/* Open event here, you may access ws->getUserData() which points to a PerSocketData struct */
3030
},
3131
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
3232
ws->send(message, opCode, true);
3333
},
34-
.drain = [](auto *ws) {
34+
.drain = [](auto */*ws*/) {
3535
/* Check ws->getBufferedAmount() here */
3636
},
37-
.ping = [](auto *ws) {
37+
.ping = [](auto */*ws*/) {
3838
/* Not implemented yet */
3939
},
40-
.pong = [](auto *ws) {
40+
.pong = [](auto */*ws*/) {
4141
/* Not implemented yet */
4242
},
43-
.close = [](auto *ws, int code, std::string_view message) {
43+
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
4444
/* You may access ws->getUserData() here */
4545
}
46-
}).listen(9001, [](auto *token) {
47-
if (token) {
46+
}).listen(9001, [](auto *listen_socket) {
47+
if (listen_socket) {
4848
std::cout << "Listening on port " << 9001 << std::endl;
4949
}
5050
}).run();

examples/EchoServerThreaded.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ int main() {
1111
/* Simple echo websocket server, using multiple threads */
1212
std::vector<std::thread *> threads(std::thread::hardware_concurrency());
1313

14-
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread *t) {
14+
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread */*t*/) {
1515
return new std::thread([]() {
1616

1717
/* Very simple WebSocket echo server */
@@ -23,26 +23,26 @@ int main() {
2323
.maxBackpressure = 1 * 1024 * 1024,
2424
/* Handlers */
2525
.upgrade = nullptr,
26-
.open = [](auto *ws) {
26+
.open = [](auto */*ws*/) {
2727

2828
},
2929
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
3030
ws->send(message, opCode);
3131
},
32-
.drain = [](auto *ws) {
32+
.drain = [](auto */*ws*/) {
3333
/* Check getBufferedAmount here */
3434
},
35-
.ping = [](auto *ws) {
35+
.ping = [](auto */*ws*/) {
3636

3737
},
38-
.pong = [](auto *ws) {
38+
.pong = [](auto */*ws*/) {
3939

4040
},
41-
.close = [](auto *ws, int code, std::string_view message) {
41+
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
4242

4343
}
44-
}).listen(9001, [](auto *token) {
45-
if (token) {
44+
}).listen(9001, [](auto *listen_socket) {
45+
if (listen_socket) {
4646
std::cout << "Thread " << std::this_thread::get_id() << " listening on port " << 9001 << std::endl;
4747
} else {
4848
std::cout << "Thread " << std::this_thread::get_id() << " failed to listen on port 9001" << std::endl;

examples/HelloWorld.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ int main() {
88
.key_file_name = "../misc/key.pem",
99
.cert_file_name = "../misc/cert.pem",
1010
.passphrase = "1234"
11-
}).get("/*", [](auto *res, auto *req) {
11+
}).get("/*", [](auto *res, auto */*req*/) {
1212
res->end("Hello world!");
13-
}).listen(3000, [](auto *token) {
14-
if (token) {
15-
std::cout << "Listening on port " << 3000 << std::endl;
13+
}).listen(3000, [](auto *listen_socket) {
14+
if (listen_socket) {
15+
std::cout << "Listening on port " << 3000 << std::endl;
1616
}
1717
}).run();
1818

examples/HelloWorldThreaded.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ int main() {
66
/* Overly simple hello world app, using multiple threads */
77
std::vector<std::thread *> threads(std::thread::hardware_concurrency());
88

9-
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread *t) {
9+
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread */*t*/) {
1010
return new std::thread([]() {
1111

12-
uWS::App().get("/*", [](auto *res, auto *req) {
12+
uWS::App().get("/*", [](auto *res, auto * /*req*/) {
1313
res->end("Hello world!");
14-
}).listen(3000, [](auto *token) {
15-
if (token) {
14+
}).listen(3000, [](auto *listen_socket) {
15+
if (listen_socket) {
1616
std::cout << "Thread " << std::this_thread::get_id() << " listening on port " << 3000 << std::endl;
1717
} else {
1818
std::cout << "Thread " << std::this_thread::get_id() << " failed to listen on port 3000" << std::endl;

examples/ServerName.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ int main() {
2121
.passphrase = "1234"
2222
});
2323

24-
}).get("/*", [](auto *res, auto *req) {
24+
}).get("/*", [](auto *res, auto */*req*/) {
2525
res->end("Hello world!");
26-
}).get("/exit", [](auto *res, auto *req) {
26+
}).get("/exit", [](auto *res, auto */*req*/) {
2727
res->end("Shutting down!");
2828
/* We use this to check graceful closedown */
2929
us_listen_socket_close(1, globalListenSocket);

examples/UpgradeAsync.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,21 @@ int main() {
103103
/* We simply echo whatever data we get */
104104
ws->send(message, opCode);
105105
},
106-
.drain = [](auto *ws) {
106+
.drain = [](auto */*ws*/) {
107107
/* Check ws->getBufferedAmount() here */
108108
},
109-
.ping = [](auto *ws) {
109+
.ping = [](auto */*ws*/) {
110110
/* You don't need to handle this one, we automatically respond to pings as per standard */
111111
},
112-
.pong = [](auto *ws) {
112+
.pong = [](auto */*ws*/) {
113113
/* You don't need to handle this one either */
114114
},
115-
.close = [](auto *ws, int code, std::string_view message) {
115+
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
116116
/* You may access ws->getUserData() here, but sending or
117117
* doing any kind of I/O with the socket is not valid. */
118118
}
119-
}).listen(9001, [](auto *token) {
120-
if (token) {
119+
}).listen(9001, [](auto *listen_socket) {
120+
if (listen_socket) {
121121
std::cout << "Listening on port " << 9001 << std::endl;
122122
}
123123
}).run();

examples/UpgradeSync.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,21 +56,21 @@ int main() {
5656
/* We simply echo whatever data we get */
5757
ws->send(message, opCode);
5858
},
59-
.drain = [](auto *ws) {
59+
.drain = [](auto */*ws*/) {
6060
/* Check ws->getBufferedAmount() here */
6161
},
62-
.ping = [](auto *ws) {
62+
.ping = [](auto */*ws*/) {
6363
/* You don't need to handle this one, we automatically respond to pings as per standard */
6464
},
65-
.pong = [](auto *ws) {
65+
.pong = [](auto */*ws*/) {
6666
/* You don't need to handle this one either */
6767
},
68-
.close = [](auto *ws, int code, std::string_view message) {
68+
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
6969
/* You may access ws->getUserData() here, but sending or
7070
* doing any kind of I/O with the socket is not valid. */
7171
}
72-
}).listen(9001, [](auto *token) {
73-
if (token) {
72+
}).listen(9001, [](auto *listen_socket) {
73+
if (listen_socket) {
7474
std::cout << "Listening on port " << 9001 << std::endl;
7575
}
7676
}).run();

src/HttpContext.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct HttpContext {
6262
/* Init the HttpContext by registering libusockets event handlers */
6363
HttpContext<SSL> *init() {
6464
/* Handle socket connections */
65-
us_socket_context_on_open(SSL, getSocketContext(), [](us_socket_t *s, int is_client, char *ip, int ip_length) {
65+
us_socket_context_on_open(SSL, getSocketContext(), [](us_socket_t *s, int /*is_client*/, char */*ip*/, int /*ip_length*/) {
6666
/* Any connected socket should timeout until it has a request */
6767
us_socket_timeout(SSL, s, HTTP_IDLE_TIMEOUT_S);
6868

@@ -79,7 +79,7 @@ struct HttpContext {
7979
});
8080

8181
/* Handle socket disconnections */
82-
us_socket_context_on_close(SSL, getSocketContext(), [](us_socket_t *s, int code, void *reason) {
82+
us_socket_context_on_close(SSL, getSocketContext(), [](us_socket_t *s, int /*code*/, void */*reason*/) {
8383
/* Get socket ext */
8484
HttpResponseData<SSL> *httpResponseData = (HttpResponseData<SSL> *) us_socket_ext(SSL, s);
8585

0 commit comments

Comments
 (0)