From 0cfc0a505597c55b1f6c9b3a96f48f94dd819114 Mon Sep 17 00:00:00 2001 From: R Date: Sun, 15 Nov 2026 20:54:02 -0300 Subject: [PATCH] beast: opt into the nodiscard-results lint rule; set_server_name is [[nodiscard]] --- doc/changelog.adoc | 1 + include/webcpp/beast/browser/ssl_stream.hpp | 5 +++-- meta/lint.json | 3 +++ 3 files changed, 7 insertions(+), 2 deletions(-) create mode 100644 meta/lint.json diff --git a/doc/changelog.adoc b/doc/changelog.adoc index 6717b47..93576f4 100644 --- a/doc/changelog.adoc +++ b/doc/changelog.adoc @@ -17,6 +17,7 @@ Changes to the unreleased Beast facade. * Fixed browser HTTP and WebSocket transfers with shared Wasm memory. * Added current application coverage and shared Release parser measurements. * Added a WebSocket client layer that bounds the handshake response it reads. +* Changed set_server_name to `+[[nodiscard]]+`, so a dropped refusal of a server name is diagnosed. // end::unreleased[] [#beast-changelog-0-1-0] diff --git a/include/webcpp/beast/browser/ssl_stream.hpp b/include/webcpp/beast/browser/ssl_stream.hpp index ddfa79e..28d8766 100644 --- a/include/webcpp/beast/browser/ssl_stream.hpp +++ b/include/webcpp/beast/browser/ssl_stream.hpp @@ -282,7 +282,7 @@ class ssl_stream { @param host Hostname to match against the recorded destination authority. @return Success, or invalid_argument for an invalid server-name record. */ - boost::system::result set_server_name(std::string_view host) { + [[nodiscard]] boost::system::result set_server_name(std::string_view host) { if (host.empty() || host.size() > 255 || host.find('\0') != std::string_view::npos) { return ::webcpp::asio_backend::error::invalid_argument; } @@ -299,7 +299,8 @@ class ssl_stream { @return Success, or invalid_argument for an invalid server-name record. */ template -boost::system::result set_server_name(ssl_stream& stream, std::string_view host) { +[[nodiscard]] boost::system::result set_server_name(ssl_stream& stream, + std::string_view host) { return stream.set_server_name(host); } } diff --git a/meta/lint.json b/meta/lint.json new file mode 100644 index 0000000..ece8c1a --- /dev/null +++ b/meta/lint.json @@ -0,0 +1,3 @@ +{ + "nodiscard-results": "a dropped result, a server name's, would pass as a name the handshake checks" +}