treewide: add braces around subobject

this change helps to silence the warning of `-Wmissing-braces` from
clang. in general, we can initialize an object without constructor
with braces. this is called aggregate initialization.
but the standard does allow us to initialize each element using
either copy-initialization or direct-initialization. but in our case,
neither of them applies, so the clang warns like

```
suggest braces around initialization of subobject [-Werror,-Wmissing-braces]
                options.elements.push_back({bytes(k.begin(), k.end()), bytes(v.begin(), v.end())});
                                            ^~~~~~~~~~~~~~~~~~~~~~~~~
                                            {                        }
```

in this change,

also, take the opportunity to use structured binding to simplify the
related code.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>
This commit is contained in:
Kefu Chai
2023-04-28 16:21:21 +08:00
parent 91f22b0e81
commit eb7c41767b
2 changed files with 9 additions and 8 deletions

View File

@@ -294,11 +294,12 @@ void compression::set_compressor(compressor_ptr c) {
unqualified_name uqn(compressor::namespace_prefix, c->name());
const sstring& cn = uqn;
name.value = bytes(cn.begin(), cn.end());
for (auto& p : c->options()) {
if (p.first != compression_parameters::SSTABLE_COMPRESSION) {
auto& k = p.first;
auto& v = p.second;
options.elements.push_back({bytes(k.begin(), k.end()), bytes(v.begin(), v.end())});
for (auto& [k, v] : c->options()) {
if (k != compression_parameters::SSTABLE_COMPRESSION) {
options.elements.push_back({
{bytes(k.begin(), k.end())},
{bytes(v.begin(), v.end())}
});
}
}
}
@@ -573,7 +574,7 @@ inline output_stream<char> make_compressed_file_output_stream(output_stream<char
// FIXME: crc_check_chance can be configured by the user.
// probability to verify the checksum of a compressed chunk we read.
// defaults to 1.0.
cm->options.elements.push_back({"crc_check_chance", "1.0"});
cm->options.elements.push_back({{"crc_check_chance"}, {"1.0"}});
return output_stream<char>(compressed_file_data_sink<ChecksumType, mode>(std::move(out), cm, p));
}

View File

@@ -1711,8 +1711,8 @@ create_sharding_metadata(schema_ptr schema, const dht::decorated_key& first_key,
auto&& right_token = right.token();
auto right_exclusive = !right.has_key() && right.bound() == dht::ring_position::token_bound::start;
sm.token_ranges.elements.push_back(disk_token_range{
{left_exclusive, left_token.data()},
{right_exclusive, right_token.data()}});
{left_exclusive, {left_token.data()}},
{right_exclusive, {right_token.data()}}});
}
}
return sm;