Fix -Wunused-parameter
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
EXAMPLE_FILES := HelloWorld ServerName EchoServer BroadcastingEchoServer UpgradeSync UpgradeAsync
|
||||
THREADED_EXAMPLE_FILES := HelloWorldThreaded EchoServerThreaded
|
||||
override CXXFLAGS += -lpthread -Wextra -Wno-unused-parameter -std=c++17 -Isrc -IuSockets/src
|
||||
override CXXFLAGS += -lpthread -Wextra -std=c++17 -Isrc -IuSockets/src
|
||||
override LDFLAGS += uSockets/*.o -lz
|
||||
|
||||
DESTDIR ?=
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "App.h"
|
||||
|
||||
struct us_listen_socket_t *listen_socket;
|
||||
struct us_listen_socket_t *global_listen_socket;
|
||||
|
||||
int main() {
|
||||
/* ws->getUserData returns one of these */
|
||||
@@ -25,28 +25,28 @@ int main() {
|
||||
/* Exit gracefully if we get a closedown message (ASAN debug) */
|
||||
if (message == "closedown") {
|
||||
/* Bye bye */
|
||||
us_listen_socket_close(0, listen_socket);
|
||||
us_listen_socket_close(0, global_listen_socket);
|
||||
ws->close();
|
||||
}
|
||||
|
||||
/* Simply broadcast every single message we get */
|
||||
ws->publish("broadcast", message, opCode, true);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
.drain = [](auto */*ws*/) {
|
||||
/* Check getBufferedAmount here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
.ping = [](auto */*ws*/) {
|
||||
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
.pong = [](auto */*ws*/) {
|
||||
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
|
||||
/* We automatically unsubscribe from any topic here */
|
||||
}
|
||||
}).listen(9001, [](auto *token) {
|
||||
listen_socket = token;
|
||||
if (token) {
|
||||
}).listen(9001, [](auto *listen_socket) {
|
||||
global_listen_socket = listen_socket;
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 9001 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
@@ -25,26 +25,26 @@ int main() {
|
||||
.maxBackpressure = 1 * 1024 * 1024,
|
||||
/* Handlers */
|
||||
.upgrade = nullptr,
|
||||
.open = [](auto *ws) {
|
||||
.open = [](auto */*ws*/) {
|
||||
/* Open event here, you may access ws->getUserData() which points to a PerSocketData struct */
|
||||
},
|
||||
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||
ws->send(message, opCode, true);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
.drain = [](auto */*ws*/) {
|
||||
/* Check ws->getBufferedAmount() here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
.ping = [](auto */*ws*/) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
.pong = [](auto */*ws*/) {
|
||||
/* Not implemented yet */
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
|
||||
/* You may access ws->getUserData() here */
|
||||
}
|
||||
}).listen(9001, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(9001, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 9001 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
@@ -11,7 +11,7 @@ int main() {
|
||||
/* Simple echo websocket server, using multiple threads */
|
||||
std::vector<std::thread *> threads(std::thread::hardware_concurrency());
|
||||
|
||||
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread *t) {
|
||||
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread */*t*/) {
|
||||
return new std::thread([]() {
|
||||
|
||||
/* Very simple WebSocket echo server */
|
||||
@@ -23,26 +23,26 @@ int main() {
|
||||
.maxBackpressure = 1 * 1024 * 1024,
|
||||
/* Handlers */
|
||||
.upgrade = nullptr,
|
||||
.open = [](auto *ws) {
|
||||
.open = [](auto */*ws*/) {
|
||||
|
||||
},
|
||||
.message = [](auto *ws, std::string_view message, uWS::OpCode opCode) {
|
||||
ws->send(message, opCode);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
.drain = [](auto */*ws*/) {
|
||||
/* Check getBufferedAmount here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
.ping = [](auto */*ws*/) {
|
||||
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
.pong = [](auto */*ws*/) {
|
||||
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
|
||||
|
||||
}
|
||||
}).listen(9001, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(9001, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " listening on port " << 9001 << std::endl;
|
||||
} else {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " failed to listen on port 9001" << std::endl;
|
||||
|
||||
@@ -8,11 +8,11 @@ int main() {
|
||||
.key_file_name = "../misc/key.pem",
|
||||
.cert_file_name = "../misc/cert.pem",
|
||||
.passphrase = "1234"
|
||||
}).get("/*", [](auto *res, auto *req) {
|
||||
}).get("/*", [](auto *res, auto */*req*/) {
|
||||
res->end("Hello world!");
|
||||
}).listen(3000, [](auto *token) {
|
||||
if (token) {
|
||||
std::cout << "Listening on port " << 3000 << std::endl;
|
||||
}).listen(3000, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 3000 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
|
||||
@@ -6,13 +6,13 @@ int main() {
|
||||
/* Overly simple hello world app, using multiple threads */
|
||||
std::vector<std::thread *> threads(std::thread::hardware_concurrency());
|
||||
|
||||
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread *t) {
|
||||
std::transform(threads.begin(), threads.end(), threads.begin(), [](std::thread */*t*/) {
|
||||
return new std::thread([]() {
|
||||
|
||||
uWS::App().get("/*", [](auto *res, auto *req) {
|
||||
uWS::App().get("/*", [](auto *res, auto * /*req*/) {
|
||||
res->end("Hello world!");
|
||||
}).listen(3000, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(3000, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " listening on port " << 3000 << std::endl;
|
||||
} else {
|
||||
std::cout << "Thread " << std::this_thread::get_id() << " failed to listen on port 3000" << std::endl;
|
||||
|
||||
@@ -21,9 +21,9 @@ int main() {
|
||||
.passphrase = "1234"
|
||||
});
|
||||
|
||||
}).get("/*", [](auto *res, auto *req) {
|
||||
}).get("/*", [](auto *res, auto */*req*/) {
|
||||
res->end("Hello world!");
|
||||
}).get("/exit", [](auto *res, auto *req) {
|
||||
}).get("/exit", [](auto *res, auto */*req*/) {
|
||||
res->end("Shutting down!");
|
||||
/* We use this to check graceful closedown */
|
||||
us_listen_socket_close(1, globalListenSocket);
|
||||
|
||||
@@ -103,21 +103,21 @@ int main() {
|
||||
/* We simply echo whatever data we get */
|
||||
ws->send(message, opCode);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
.drain = [](auto */*ws*/) {
|
||||
/* Check ws->getBufferedAmount() here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
.ping = [](auto */*ws*/) {
|
||||
/* You don't need to handle this one, we automatically respond to pings as per standard */
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
.pong = [](auto */*ws*/) {
|
||||
/* You don't need to handle this one either */
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
|
||||
/* You may access ws->getUserData() here, but sending or
|
||||
* doing any kind of I/O with the socket is not valid. */
|
||||
}
|
||||
}).listen(9001, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(9001, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 9001 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
@@ -56,21 +56,21 @@ int main() {
|
||||
/* We simply echo whatever data we get */
|
||||
ws->send(message, opCode);
|
||||
},
|
||||
.drain = [](auto *ws) {
|
||||
.drain = [](auto */*ws*/) {
|
||||
/* Check ws->getBufferedAmount() here */
|
||||
},
|
||||
.ping = [](auto *ws) {
|
||||
.ping = [](auto */*ws*/) {
|
||||
/* You don't need to handle this one, we automatically respond to pings as per standard */
|
||||
},
|
||||
.pong = [](auto *ws) {
|
||||
.pong = [](auto */*ws*/) {
|
||||
/* You don't need to handle this one either */
|
||||
},
|
||||
.close = [](auto *ws, int code, std::string_view message) {
|
||||
.close = [](auto */*ws*/, int /*code*/, std::string_view /*message*/) {
|
||||
/* You may access ws->getUserData() here, but sending or
|
||||
* doing any kind of I/O with the socket is not valid. */
|
||||
}
|
||||
}).listen(9001, [](auto *token) {
|
||||
if (token) {
|
||||
}).listen(9001, [](auto *listen_socket) {
|
||||
if (listen_socket) {
|
||||
std::cout << "Listening on port " << 9001 << std::endl;
|
||||
}
|
||||
}).run();
|
||||
|
||||
+2
-2
@@ -62,7 +62,7 @@ private:
|
||||
/* Init the HttpContext by registering libusockets event handlers */
|
||||
HttpContext<SSL> *init() {
|
||||
/* Handle socket connections */
|
||||
us_socket_context_on_open(SSL, getSocketContext(), [](us_socket_t *s, int is_client, char *ip, int ip_length) {
|
||||
us_socket_context_on_open(SSL, getSocketContext(), [](us_socket_t *s, int /*is_client*/, char */*ip*/, int /*ip_length*/) {
|
||||
/* Any connected socket should timeout until it has a request */
|
||||
us_socket_timeout(SSL, s, HTTP_IDLE_TIMEOUT_S);
|
||||
|
||||
@@ -79,7 +79,7 @@ private:
|
||||
});
|
||||
|
||||
/* Handle socket disconnections */
|
||||
us_socket_context_on_close(SSL, getSocketContext(), [](us_socket_t *s, int code, void *reason) {
|
||||
us_socket_context_on_close(SSL, getSocketContext(), [](us_socket_t *s, int /*code*/, void */*reason*/) {
|
||||
/* Get socket ext */
|
||||
HttpResponseData<SSL> *httpResponseData = (HttpResponseData<SSL> *) us_socket_ext(SSL, s);
|
||||
|
||||
|
||||
+5
-2
@@ -157,7 +157,7 @@ private:
|
||||
return unsignedIntegerValue;
|
||||
}
|
||||
|
||||
static unsigned int getHeaders(char *postPaddedBuffer, char *end, struct HttpRequest::Header *headers, BloomFilter *bf) {
|
||||
static unsigned int getHeaders(char *postPaddedBuffer, char *end, struct HttpRequest::Header *headers) {
|
||||
char *preliminaryKey, *preliminaryValue, *start = postPaddedBuffer;
|
||||
|
||||
for (unsigned int i = 0; i < HttpRequest::MAX_HEADERS; i++) {
|
||||
@@ -207,12 +207,15 @@ private:
|
||||
length -= offset;
|
||||
consumedTotal += offset;
|
||||
}
|
||||
#else
|
||||
/* This one is unused */
|
||||
(void) reserved;
|
||||
#endif
|
||||
|
||||
/* Fence one byte past end of our buffer (buffer has post padded margins) */
|
||||
data[length] = '\r';
|
||||
|
||||
for (unsigned int consumed; length && (consumed = getHeaders(data, data + length, req->headers, &req->bf)); ) {
|
||||
for (unsigned int consumed; length && (consumed = getHeaders(data, data + length, req->headers)); ) {
|
||||
data += consumed;
|
||||
length -= consumed;
|
||||
consumedTotal += consumed;
|
||||
|
||||
@@ -41,7 +41,7 @@ private:
|
||||
}
|
||||
|
||||
/* If we have negotiated compression, set this frame compressed */
|
||||
static bool setCompressed(uWS::WebSocketState<isServer> *wState, void *s) {
|
||||
static bool setCompressed(uWS::WebSocketState<isServer> */*wState*/, void *s) {
|
||||
WebSocketData *webSocketData = (WebSocketData *) us_socket_ext(SSL, (us_socket_t *) s);
|
||||
|
||||
if (webSocketData->compressionStatus == WebSocketData::CompressionStatus::ENABLED) {
|
||||
@@ -52,7 +52,7 @@ private:
|
||||
}
|
||||
}
|
||||
|
||||
static void forceClose(uWS::WebSocketState<isServer> *wState, void *s, std::string_view reason = {}) {
|
||||
static void forceClose(uWS::WebSocketState<isServer> */*wState*/, void *s, std::string_view reason = {}) {
|
||||
us_socket_close(SSL, (us_socket_t *) s, (int) reason.length(), (void *) reason.data());
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ private:
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool refusePayloadLength(uint64_t length, uWS::WebSocketState<isServer> *wState, void *s) {
|
||||
static bool refusePayloadLength(uint64_t length, uWS::WebSocketState<isServer> */*wState*/, void *s) {
|
||||
auto *webSocketContextData = (WebSocketContextData<SSL> *) us_socket_context_ext(SSL, us_socket_context(SSL, (us_socket_t *) s));
|
||||
|
||||
/* Return true for refuse, false for accept */
|
||||
@@ -378,7 +378,7 @@ private:
|
||||
|
||||
public:
|
||||
/* WebSocket contexts are always child contexts to a HTTP context so no SSL options are needed as they are inherited */
|
||||
static WebSocketContext *create(Loop *loop, us_socket_context_t *parentSocketContext) {
|
||||
static WebSocketContext *create(Loop */*loop*/, us_socket_context_t *parentSocketContext) {
|
||||
WebSocketContext *webSocketContext = (WebSocketContext *) us_create_child_socket_context(SSL, parentSocketContext, sizeof(WebSocketContextData<SSL>));
|
||||
if (!webSocketContext) {
|
||||
return nullptr;
|
||||
|
||||
@@ -147,12 +147,12 @@ public:
|
||||
return 0;
|
||||
}) {
|
||||
/* We empty for both pre and post just to make sure */
|
||||
Loop::get()->addPostHandler(this, [this](Loop *loop) {
|
||||
Loop::get()->addPostHandler(this, [this](Loop */*loop*/) {
|
||||
/* Commit pub/sub batches every loop iteration */
|
||||
topicTree.drain();
|
||||
});
|
||||
|
||||
Loop::get()->addPreHandler(this, [this](Loop *loop) {
|
||||
Loop::get()->addPreHandler(this, [this](Loop */*loop*/) {
|
||||
/* Commit pub/sub batches every loop iteration */
|
||||
topicTree.drain();
|
||||
});
|
||||
|
||||
@@ -34,7 +34,7 @@ struct WebSocketHandshake {
|
||||
|
||||
template <typename T>
|
||||
struct static_for<0, T> {
|
||||
void operator()(uint32_t *a, uint32_t *hash) {}
|
||||
void operator()(uint32_t */*a*/, uint32_t */*hash*/) {}
|
||||
};
|
||||
|
||||
static inline uint32_t rol(uint32_t value, size_t bits) {return (value << bits) | (value >> (32 - bits));}
|
||||
|
||||
Reference in New Issue
Block a user