Skip to content

Commit 1822136

Browse files
tchaikovavikivity
authored andcommitted
io_queue: fix static member access to comply with CWG2813
Fix build failure with recent Clang implementations of CWG2813, which makes accessing static members through instance expressions into discarded-value expressions. This caused nodiscard warnings when accessing static member `tokens_capacity()` through `fgs[i]`. Before: ```c++ fgs[i].tokens_capacity() // Warns: ignoring nodiscard return value ``` After: ```c++ const auto& fg = fgs[i]); // not discarded fg.tokens_capacity(); // access static member function ``` Additionally, this refactoring reduces repetition of `fgs[g_idx]` expressions throughout the code. See: - https://cplusplus.github.io/CWG/issues/2813.html - https://eel.is/c++draft/expr.ref#2 Fixes Scylla build failure with the latest Clang, as Scylla enables Seastar_UNUSED_RESULT_ERROR. Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
1 parent 19dbc3e commit 1822136

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/core/io_queue.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,10 +639,11 @@ io_group::io_group(io_queue::config io_cfg, unsigned nr_queues)
639639
*/
640640
auto update_max_size = [this] (unsigned idx) {
641641
auto g_idx = _config.duplex ? idx : 0;
642-
auto max_cap = _fgs[g_idx].maximum_capacity();
642+
const auto& fg = _fgs[g_idx];
643+
auto max_cap = fg.maximum_capacity();
643644
for (unsigned shift = 0; ; shift++) {
644645
auto tokens = internal::request_tokens(io_direction_and_length(idx, 1 << (shift + io_queue::block_size_shift)), _config);
645-
auto cap = _fgs[g_idx].tokens_capacity(tokens);
646+
auto cap = fg.tokens_capacity(tokens);
646647
if (cap > max_cap) {
647648
if (shift == 0) {
648649
throw std::runtime_error("IO-group limits are too low");

0 commit comments

Comments
 (0)