Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clang warnings. #508

Merged
merged 1 commit into from
Nov 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/server/bitops_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ uint8_t GetByteAt(std::string_view s, std::size_t at) {
// For XOR, OR, AND operations on a collection of bytes
template <typename BitOp, typename SkipOp>
std::string BitOpString(BitOp operation_f, SkipOp skip_f, const BitsStrVec& values,
std::string&& new_value) {
std::string new_value) {
// at this point, values are not empty
std::size_t max_size = new_value.size();

Expand Down Expand Up @@ -441,7 +441,7 @@ OpResult<std::string> RunBitOpOnShard(std::string_view op, const OpArgs& op_args
for (auto& key : keys) {
OpResult<PrimeIterator> find_res = es->db_slice().Find(op_args.db_cntx, key, OBJ_STRING);
if (find_res) {
values.emplace_back(std::move(GetString(find_res.value()->second, es)));
values.emplace_back(GetString(find_res.value()->second, es));
} else {
if (find_res.status() == OpStatus::KEY_NOTFOUND) {
continue; // this is allowed, just return empty string per Redis
Expand Down
2 changes: 1 addition & 1 deletion src/server/generic_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -948,7 +948,7 @@ void GenericFamily::Sort(CmdArgList args, ConnectionContext* cntx) {
if (!entries.ok())
return (*cntx)->SendEmptyArray();

auto sort_call = [cntx, bounds, reversed, key](auto& entries) {
auto sort_call = [cntx, bounds, reversed](auto& entries) {
if (bounds) {
auto sort_it = entries.begin() + std::min(bounds->first + bounds->second, entries.size());
std::partial_sort(entries.begin(), sort_it, entries.end(),
Expand Down
1 change: 0 additions & 1 deletion src/server/rdb_load.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,6 @@ void RdbLoader::FlushShardAsync(ShardId sid) {
}

std::error_code RdbLoaderBase::Visit(const Item& item, CompactObj* pv) {
std::string_view key{item.key};
OpaqueObjLoader visitor(item.val.rdb_type, pv);
std::visit(visitor, item.val.obj);
return visitor.ec();
Expand Down
4 changes: 2 additions & 2 deletions src/server/replica.cc
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ error_code Replica::InitiateDflySync() {
auto partition = Partition(num_df_flows_);
shard_set->pool()->AwaitFiberOnAll([&](unsigned index, auto*) {
for (auto id : partition[index]) {
if (ec = shard_flows_[id]->StartFullSyncFlow(&sb))
if ((ec = shard_flows_[id]->StartFullSyncFlow(&sb)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe the new still "if" with "if (ec = shard_flows_[id]->StartFullSyncFlow(&sb); ec) {..} would be more readable? right now this look a little bit like a classic C bug where you're assign and then git the side effect from assignment.

break;
}
});
Expand Down Expand Up @@ -610,7 +610,7 @@ void Replica::FullSyncDflyFb(SyncBlock* sb, string eof_token) {
io::PrefixSource ps{leftover_buf_->InputBuffer(), &ss};

RdbLoader loader(NULL);
loader.SetFullSyncCutCb([this, sb, ran = false]() mutable {
loader.SetFullSyncCutCb([sb, ran = false]() mutable {
if (!ran) {
std::unique_lock lk(sb->mu_);
sb->flows_left--;
Expand Down
4 changes: 2 additions & 2 deletions src/server/server_family.cc
Original file line number Diff line number Diff line change
Expand Up @@ -871,7 +871,7 @@ error_code ServerFamily::DoSave(bool new_version, Transaction* trans, string* er
const auto scripts = script_mgr_->GetLuaScripts();
auto& summary_snapshot = snapshots[shard_set->size()];
summary_snapshot.reset(new RdbSnapshot(fq_threadpool_.get()));
if (ec = DoPartialSave(filename, path, start, scripts, summary_snapshot.get(), nullptr)) {
if ((ec = DoPartialSave(filename, path, start, scripts, summary_snapshot.get(), nullptr))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the previous comment - I think that it would look more like the intent is to assign then check. assign with side effect is the classic that you;re not sure if this is a bug or you're using the side effect

summary_snapshot.reset();
}
}
Expand All @@ -880,7 +880,7 @@ error_code ServerFamily::DoSave(bool new_version, Transaction* trans, string* er
auto cb = [&](Transaction* t, EngineShard* shard) {
auto& snapshot = snapshots[shard->shard_id()];
snapshot.reset(new RdbSnapshot(fq_threadpool_.get()));
if (ec = DoPartialSave(filename, path, start, {}, snapshot.get(), shard)) {
if ((ec = DoPartialSave(filename, path, start, {}, snapshot.get(), shard))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same issue as with above

snapshot.reset();
}
return OpStatus::OK;
Expand Down