Skip to content

Commit

Permalink
Fix std::...::erase return value usages.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: d9729ccd619e3b99554f1e1c2262d8826f0a8571
  • Loading branch information
levlam committed Oct 8, 2020
1 parent 54f32eb commit 35a9a93
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions td/telegram/Client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ class MultiTd : public Actor {
}

void close(int32 td_id) {
size_t erased = tds_.erase(td_id);
CHECK(erased > 0);
size_t erased_count = tds_.erase(td_id);
CHECK(erased_count > 0);
}

private:
Expand Down
8 changes: 4 additions & 4 deletions td/telegram/MessagesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14426,8 +14426,8 @@ unique_ptr<MessagesManager::Message> MessagesManager::do_delete_scheduled_messag
auto result = treap_delete_message(v);

if (message_id.is_scheduled_server()) {
size_t erased = d->scheduled_message_date.erase(message_id.get_scheduled_server_message_id());
CHECK(erased != 0);
size_t erased_count = d->scheduled_message_date.erase(message_id.get_scheduled_server_message_id());
CHECK(erased_count != 0);
}

cancel_send_deleted_message(d->dialog_id, result.get(), is_permanently_deleted);
Expand Down Expand Up @@ -20909,8 +20909,8 @@ void MessagesManager::on_get_dialog_message_by_date_success(DialogId dialog_id,
}

void MessagesManager::on_get_dialog_message_by_date_fail(int64 random_id) {
auto erased = get_dialog_message_by_date_results_.erase(random_id);
CHECK(erased > 0);
auto erased_count = get_dialog_message_by_date_results_.erase(random_id);
CHECK(erased_count > 0);
}

tl_object_ptr<td_api::message> MessagesManager::get_dialog_message_by_date_object(int64 random_id) {
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/PollManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ void PollManager::unregister_poll(PollId poll_id, FullMessageId full_message_id,
}
LOG(INFO) << "Unregister " << poll_id << " from " << full_message_id << " from " << source;
auto &message_ids = poll_messages_[poll_id];
auto is_deleted = message_ids.erase(full_message_id);
auto is_deleted = message_ids.erase(full_message_id) > 0;
LOG_CHECK(is_deleted) << source << " " << poll_id << " " << full_message_id;
if (message_ids.empty()) {
poll_messages_.erase(poll_id);
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/StickersManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3558,7 +3558,7 @@ void StickersManager::unregister_dice(const string &emoji, int32 value, FullMess
LOG(INFO) << "Unregister dice " << emoji << " with value " << value << " from " << full_message_id << " from "
<< source;
auto &message_ids = dice_messages_[emoji];
auto is_deleted = message_ids.erase(full_message_id);
auto is_deleted = message_ids.erase(full_message_id) > 0;
LOG_CHECK(is_deleted) << source << " " << emoji << " " << value << " " << full_message_id;

if (message_ids.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/WebPagesManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,7 @@ void WebPagesManager::unregister_web_page(WebPageId web_page_id, FullMessageId f

LOG(INFO) << "Unregister " << web_page_id << " from " << full_message_id << " from " << source;
auto &message_ids = web_page_messages_[web_page_id];
auto is_deleted = message_ids.erase(full_message_id);
auto is_deleted = message_ids.erase(full_message_id) > 0;
LOG_CHECK(is_deleted) << source << " " << web_page_id << " " << full_message_id;

if (message_ids.empty()) {
Expand Down
2 changes: 1 addition & 1 deletion tddb/td/db/TQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ class TQueueImpl : public TQueue {

void schedule_queue_gc(QueueId queue_id, Queue &q, int32 gc_at) {
if (q.gc_at != 0) {
bool is_deleted = queue_gc_at_.erase({q.gc_at, queue_id});
bool is_deleted = queue_gc_at_.erase({q.gc_at, queue_id}) > 0;
CHECK(is_deleted);
}
q.gc_at = gc_at;
Expand Down
4 changes: 2 additions & 2 deletions tdutils/td/utils/port/FileFd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,8 @@ void FileFd::remove_local_lock(const string &path) {
if (!path.empty()) {
VLOG(fd) << "Unlock file \"" << path << '"';
std::unique_lock<std::mutex> lock(in_process_lock_mutex);
auto erased = locked_files.erase(path);
CHECK(erased > 0);
auto erased_count = locked_files.erase(path);
CHECK(erased_count > 0);
}
}

Expand Down
8 changes: 4 additions & 4 deletions test/tdclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1009,8 +1009,8 @@ TEST(Client, Close) {
receive_count++;
{
std::unique_lock<std::mutex> guard(request_ids_mutex);
size_t erase_count = request_ids.erase(response.id);
CHECK(erase_count > 0);
size_t erased_count = request_ids.erase(response.id);
CHECK(erased_count > 0);
}
}
if (can_stop_receive && receive_count == send_count) {
Expand Down Expand Up @@ -1071,8 +1071,8 @@ TEST(Client, ManagerClose) {
receive_count++;
{
std::unique_lock<std::mutex> guard(request_ids_mutex);
size_t erase_count = request_ids.erase(response.request_id);
CHECK(erase_count > 0);
size_t erased_count = request_ids.erase(response.request_id);
CHECK(erased_count > 0);
}
}
if (can_stop_receive && receive_count == send_count) {
Expand Down

0 comments on commit 35a9a93

Please sign in to comment.