diff --git a/Makefile b/Makefile index fd10f29..662bee4 100644 --- a/Makefile +++ b/Makefile @@ -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 ?= diff --git a/examples/BroadcastingEchoServer.cpp b/examples/BroadcastingEchoServer.cpp index c8f391f..c5890e8 100644 --- a/examples/BroadcastingEchoServer.cpp +++ b/examples/BroadcastingEchoServer.cpp @@ -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(); diff --git a/examples/EchoServer.cpp b/examples/EchoServer.cpp index b1f19e4..49e921b 100644 --- a/examples/EchoServer.cpp +++ b/examples/EchoServer.cpp @@ -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(); diff --git a/examples/EchoServerThreaded.cpp b/examples/EchoServerThreaded.cpp index c511ba4..8d9b90a 100644 --- a/examples/EchoServerThreaded.cpp +++ b/examples/EchoServerThreaded.cpp @@ -11,7 +11,7 @@ int main() { /* Simple echo websocket server, using multiple threads */ std::vector 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; diff --git a/examples/HelloWorld.cpp b/examples/HelloWorld.cpp index d18e8d8..c4094e1 100644 --- a/examples/HelloWorld.cpp +++ b/examples/HelloWorld.cpp @@ -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(); diff --git a/examples/HelloWorldThreaded.cpp b/examples/HelloWorldThreaded.cpp index a35e9b5..a1bc734 100644 --- a/examples/HelloWorldThreaded.cpp +++ b/examples/HelloWorldThreaded.cpp @@ -6,13 +6,13 @@ int main() { /* Overly simple hello world app, using multiple threads */ std::vector 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; diff --git a/examples/ServerName.cpp b/examples/ServerName.cpp index 8ca4511..3ed274f 100644 --- a/examples/ServerName.cpp +++ b/examples/ServerName.cpp @@ -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); diff --git a/examples/UpgradeAsync.cpp b/examples/UpgradeAsync.cpp index ee625d8..83bf8dc 100644 --- a/examples/UpgradeAsync.cpp +++ b/examples/UpgradeAsync.cpp @@ -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(); diff --git a/examples/UpgradeSync.cpp b/examples/UpgradeSync.cpp index 48e9c7f..a9f8e44 100644 --- a/examples/UpgradeSync.cpp +++ b/examples/UpgradeSync.cpp @@ -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(); diff --git a/src/HttpContext.h b/src/HttpContext.h index 28f4847..9a4cc34 100644 --- a/src/HttpContext.h +++ b/src/HttpContext.h @@ -62,7 +62,7 @@ private: /* Init the HttpContext by registering libusockets event handlers */ HttpContext *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 *httpResponseData = (HttpResponseData *) us_socket_ext(SSL, s); diff --git a/src/HttpParser.h b/src/HttpParser.h index 4f2abc0..5b69b70 100644 --- a/src/HttpParser.h +++ b/src/HttpParser.h @@ -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; diff --git a/src/WebSocketContext.h b/src/WebSocketContext.h index 2815fa4..8861429 100644 --- a/src/WebSocketContext.h +++ b/src/WebSocketContext.h @@ -41,7 +41,7 @@ private: } /* If we have negotiated compression, set this frame compressed */ - static bool setCompressed(uWS::WebSocketState *wState, void *s) { + static bool setCompressed(uWS::WebSocketState */*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 *wState, void *s, std::string_view reason = {}) { + static void forceClose(uWS::WebSocketState */*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 *wState, void *s) { + static bool refusePayloadLength(uint64_t length, uWS::WebSocketState */*wState*/, void *s) { auto *webSocketContextData = (WebSocketContextData *) 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)); if (!webSocketContext) { return nullptr; diff --git a/src/WebSocketContextData.h b/src/WebSocketContextData.h index 9f99e8f..a0e12ee 100644 --- a/src/WebSocketContextData.h +++ b/src/WebSocketContextData.h @@ -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(); }); diff --git a/src/WebSocketHandshake.h b/src/WebSocketHandshake.h index 901cb1d..808415e 100644 --- a/src/WebSocketHandshake.h +++ b/src/WebSocketHandshake.h @@ -34,7 +34,7 @@ struct WebSocketHandshake { template 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));}