Skip to content

Commit

Permalink
chore: fixed building with clang-17
Browse files Browse the repository at this point in the history
The two changes were required to build Redpanda with clang-17.

1. Do not catch `ss::sleep_aborted_exception` when `ss::abort_requested`
   is already captured. As `ss::sleep_aborted_exception` inherits from
   more general `ss::abort_requested_exception` it is already handled

2. Boost `boost::basic_static_string` is not longer implicitly
   convertible to `std::string_view`

Signed-off-by: Michal Maslanka <michal@redpadna.com>
  • Loading branch information
Michal Maslanka committed Nov 13, 2023
1 parent 3a7d07e commit d0cde02
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 26 deletions.
3 changes: 0 additions & 3 deletions src/v/archival/ntp_archiver_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ ss::future<> ntp_archiver::upload_until_abort() {
_conf->upload_scheduling_group,
[this] { return upload_until_term_change(); })
.handle_exception_type([](const ss::abort_requested_exception&) {})
.handle_exception_type([](const ss::sleep_aborted&) {})
.handle_exception_type([](const ss::gate_closed_exception&) {})
.handle_exception_type([](const ss::broken_semaphore&) {})
.handle_exception_type([](const ss::broken_named_semaphore&) {})
Expand Down Expand Up @@ -429,7 +428,6 @@ ss::future<> ntp_archiver::sync_manifest_until_abort() {
[](const ss::abort_requested_exception&) {})
.handle_exception_type([](const ss::broken_semaphore&) {})
.handle_exception_type([](const ss::broken_named_semaphore&) {})
.handle_exception_type([](const ss::sleep_aborted&) {})
.handle_exception_type([](const ss::gate_closed_exception&) {});
} catch (const ss::semaphore_timed_out& e) {
vlog(
Expand Down Expand Up @@ -2138,7 +2136,6 @@ ss::future<> ntp_archiver::housekeeping() {
co_await apply_spillover();
}
} catch (const ss::abort_requested_exception&) {
} catch (const ss::sleep_aborted&) {
} catch (const ss::gate_closed_exception&) {
} catch (const ss::broken_semaphore&) {
} catch (const ss::semaphore_timed_out&) {
Expand Down
2 changes: 1 addition & 1 deletion src/v/cloud_roles/request_response_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ ss::future<api_response> make_request_with_payload(
std::optional<std::chrono::milliseconds> timeout) {
req.set(
boost::beast::http::field::content_length,
boost::beast::to_static_string(content.size_bytes()));
fmt::format("{}", content.size_bytes()));

auto stream = make_iobuf_input_stream(std::move(content));
auto tout = timeout.value_or(
Expand Down
2 changes: 0 additions & 2 deletions src/v/cluster/log_eviction_stm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ ss::future<> log_eviction_stm::handle_log_eviction_events() {
} catch (const ss::gate_closed_exception&) {
// ignore gate closed exception, shutting down
} catch (const ss::broken_semaphore&) {
} catch (const ss::sleep_aborted&) {
// ignore broken sem exception, shutting down
} catch (const std::exception& e) {
vlog(
_log.error,
Expand Down
2 changes: 1 addition & 1 deletion src/v/cluster/metrics_reporter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ metrics_reporter::make_header(const iobuf& buffer) {
header.target(std::string(_address.path));
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(buffer.size_bytes()));
fmt::format("{}", buffer.size_bytes()));
header.insert(
boost::beast::http::field::host,
fmt::format("{}:{}", _address.host, _address.port));
Expand Down
2 changes: 1 addition & 1 deletion src/v/http/demo/client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ http::client::request_header make_header(const test_conf& cfg) {
header.target(cfg.target);
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(cfg.data.length()));
fmt::format("{}", cfg.data.length()));
auto host = fmt::format("{}", cfg.client_cfg.server_addr);
header.insert(boost::beast::http::field::host, host);
header.insert(boost::beast::http::field::content_type, "application/json");
Expand Down
27 changes: 13 additions & 14 deletions src/v/http/tests/http_client_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <boost/beast/http/field.hpp>
#include <boost/test/tools/old/interface.hpp>
#include <boost/test/unit_test.hpp>
#include <fmt/core.h>

#include <exception>
#include <initializer_list>
Expand Down Expand Up @@ -188,7 +189,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_POST_roundtrip) {
header.target("/echo");
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(header, config.server_addr);
header.insert(boost::beast::http::field::content_type, "application/json");
test_http_request(
Expand Down Expand Up @@ -251,8 +252,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_GET_streaming_roundtrip) {
header.method(boost::beast::http::verb::get);
header.target("/get");
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(0));
boost::beast::http::field::content_length, fmt::format("{}", 0));
header_set_host(header, config.server_addr);
header.insert(boost::beast::http::field::content_type, "application/json");
constexpr size_t skip_bytes = 100;
Expand Down Expand Up @@ -281,7 +281,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_POST_streaming_roundtrip) {
header.target("/echo");
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(header, config.server_addr);
header.insert(boost::beast::http::field::content_type, "application/json");

Expand Down Expand Up @@ -351,7 +351,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_PUT_roundtrip) {
header.target("/put");
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(header, config.server_addr);
header.insert(boost::beast::http::field::content_type, "application/json");
test_http_request(
Expand All @@ -374,8 +374,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_PUT_empty_roundtrip) {
header.method(boost::beast::http::verb::put);
header.target("/empty");
header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(0));
boost::beast::http::field::content_length, fmt::format("{}", 0));
header_set_host(header, config.server_addr);
header.insert(boost::beast::http::field::content_type, "application/json");
iobuf empty;
Expand Down Expand Up @@ -562,7 +561,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor) {
request_header.target("/");
request_header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(request_header, config.server_addr);
request_header.insert(
boost::beast::http::field::content_type, "application/json");
Expand All @@ -574,7 +573,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor) {
header_set_host(resp_hdr, config.server_addr);
resp_hdr.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(response_data.size()));
fmt::format("{}", response_data.size()));
auto full_response = get_response_header(resp_hdr) + response_data;

// Run test case
Expand Down Expand Up @@ -603,7 +602,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_incorrect_reply) {
request_header.target("/");
request_header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(request_header, config.server_addr);
request_header.insert(
boost::beast::http::field::content_type, "application/json");
Expand Down Expand Up @@ -639,7 +638,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_chunked_encoding) {
request_header.target("/");
request_header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(request_header, config.server_addr);
request_header.insert(
boost::beast::http::field::content_type, "application/json");
Expand Down Expand Up @@ -704,7 +703,7 @@ void run_framing_test_using_impostor(
request_header.target("/");
request_header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(request_header, config.server_addr);
request_header.insert(
boost::beast::http::field::content_type, "application/json");
Expand All @@ -719,7 +718,7 @@ void run_framing_test_using_impostor(
} else {
resp_hdr.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(response_data.size()));
fmt::format("{}", response_data.size()));
}
header_set_host(resp_hdr, config.server_addr);
auto header_str = get_response_header(resp_hdr);
Expand Down Expand Up @@ -795,7 +794,7 @@ SEASTAR_THREAD_TEST_CASE(test_http_via_impostor_no_content_length) {
request_header.target("/");
request_header.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(std::strlen(httpd_server_reply)));
fmt::format("{}", std::strlen(httpd_server_reply)));
header_set_host(request_header, config.server_addr);
request_header.insert(
boost::beast::http::field::content_type, "application/json");
Expand Down
3 changes: 2 additions & 1 deletion src/v/pandaproxy/test/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "pandaproxy/json/types.h"

#include <boost/beast/core/string_type.hpp>
#include <fmt/core.h>
#include <http/client.h>

using serialization_format = pandaproxy::json::serialization_format;
Expand Down Expand Up @@ -50,7 +51,7 @@ inline http::client::request_header make_header(
hdr.target(target);
hdr.insert(
boost::beast::http::field::content_length,
boost::beast::to_static_string(body.size_bytes()));
fmt::format("{}", body.size_bytes()));
if (content != serialization_format::none) {
hdr.insert(
boost::beast::http::field::content_type, to_header_value(content));
Expand Down
3 changes: 0 additions & 3 deletions src/v/ssx/future-util.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,6 @@ ignore_shutdown_exceptions(seastar::future<> fut) noexcept {
} catch (const seastar::broken_semaphore&) {
} catch (const seastar::broken_promise&) {
} catch (const seastar::broken_condition_variable&) {
} catch (const seastar::sleep_aborted&) {
}
}

Expand All @@ -294,8 +293,6 @@ inline bool is_shutdown_exception(const std::exception_ptr& e) {
return true;
} catch (const seastar::broken_condition_variable&) {
return true;
} catch (const seastar::sleep_aborted&) {
return true;
} catch (...) {
}
return false;
Expand Down

0 comments on commit d0cde02

Please sign in to comment.