diff options
| -rw-r--r-- | td/telegram/LanguagePackManager.cpp | 6 | ||||
| -rw-r--r-- | td/telegram/LinkManager.cpp | 8 | ||||
| -rw-r--r-- | td/telegram/MessageContent.cpp | 5 | ||||
| -rw-r--r-- | td/telegram/MessageContent.h | 4 | ||||
| -rw-r--r-- | td/telegram/MessageImportManager.cpp | 2 | ||||
| -rw-r--r-- | td/telegram/MessagesManager.cpp | 42 | ||||
| -rw-r--r-- | td/telegram/MessagesManager.h | 14 | ||||
| -rw-r--r-- | td/telegram/NotificationManager.cpp | 2 | ||||
| -rw-r--r-- | td/telegram/NotificationSound.cpp | 4 | ||||
| -rw-r--r-- | td/telegram/PhoneNumberManager.h | 4 | ||||
| -rw-r--r-- | td/telegram/ReactionManager.cpp | 2 | ||||
| -rw-r--r-- | td/telegram/UserManager.h | 16 | ||||
| -rw-r--r-- | td/telegram/WebPageBlock.cpp | 8 | ||||
| -rw-r--r-- | td/telegram/WebPagesManager.cpp | 14 | ||||
| -rw-r--r-- | td/telegram/net/ConnectionCreator.h | 2 | ||||
| -rw-r--r-- | td/telegram/net/DcAuthManager.cpp | 1 | ||||
| -rw-r--r-- | td/telegram/net/DcAuthManager.h | 2 | ||||
| -rw-r--r-- | td/telegram/net/Session.h | 4 | ||||
| -rw-r--r-- | tdutils/td/utils/ChainScheduler.h | 2 | ||||
| -rw-r--r-- | tdutils/td/utils/ConcurrentHashTable.h | 8 | ||||
| -rw-r--r-- | tdutils/td/utils/FlatHashMapChunks.h | 2 | ||||
| -rw-r--r-- | tdutils/test/ChainScheduler.cpp | 2 | ||||
| -rw-r--r-- | test/online.cpp | 8 |
23 files changed, 84 insertions, 78 deletions
diff --git a/td/telegram/LanguagePackManager.cpp b/td/telegram/LanguagePackManager.cpp index 4b157f602..eb4eae7c3 100644 --- a/td/telegram/LanguagePackManager.cpp +++ b/td/telegram/LanguagePackManager.cpp @@ -1199,9 +1199,9 @@ static td_api::object_ptr<td_api::LanguagePackStringValue> copy_language_pack_st } case td_api::languagePackStringValuePluralized::ID: { auto old_value = static_cast<const td_api::languagePackStringValuePluralized *>(value); - return make_tl_object<td_api::languagePackStringValuePluralized>( - std::move(old_value->zero_value_), std::move(old_value->one_value_), std::move(old_value->two_value_), - std::move(old_value->few_value_), std::move(old_value->many_value_), std::move(old_value->other_value_)); + return make_tl_object<td_api::languagePackStringValuePluralized>(old_value->zero_value_, old_value->one_value_, + old_value->two_value_, old_value->few_value_, + old_value->many_value_, old_value->other_value_); } case td_api::languagePackStringValueDeleted::ID: return make_tl_object<td_api::languagePackStringValueDeleted>(); diff --git a/td/telegram/LinkManager.cpp b/td/telegram/LinkManager.cpp index 238b8c1cf..c78b1a938 100644 --- a/td/telegram/LinkManager.cpp +++ b/td/telegram/LinkManager.cpp @@ -1459,7 +1459,7 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_tg_link_query(Slice que } if (arg.first == "ref" && is_valid_start_parameter(arg.second) && !arg.second.empty()) { // resolve?domain=<bot_username>&ref=<referrer> - return td::make_unique<InternalLinkDialogReferralProgram>(std::move(username), std::move(arg.second)); + return td::make_unique<InternalLinkDialogReferralProgram>(std::move(username), arg.second); } if (arg.first == "start" && is_valid_start_parameter(arg.second)) { auto prefixes = get_referral_program_start_parameter_prefixes(); @@ -1964,7 +1964,7 @@ unique_ptr<LinkManager::InternalLink> LinkManager::parse_t_me_link_query(Slice q } if (arg.first == "ref" && is_valid_start_parameter(arg.second) && !arg.second.empty()) { // /<bot_username>?ref=<referrer> - return td::make_unique<InternalLinkDialogReferralProgram>(std::move(username), std::move(arg.second)); + return td::make_unique<InternalLinkDialogReferralProgram>(std::move(username), arg.second); } if (arg.first == "start" && is_valid_start_parameter(arg.second)) { auto prefixes = get_referral_program_start_parameter_prefixes(); @@ -2486,10 +2486,10 @@ Result<string> LinkManager::get_internal_link_impl(const td_api::InternalLinkTyp return std::move(static_cast<td_api::internalLinkTypeMessage &>(*parsed_object).url_); } case td_api::internalLinkTypeMessageDraft::ID: { - auto link = static_cast<const td_api::internalLinkTypeMessageDraft *>(type_ptr); + auto *link = static_cast<const td_api::internalLinkTypeMessageDraft *>(type_ptr); string text; if (link->text_ != nullptr) { - text = std::move(link->text_->text_); + text = link->text_->text_; } string url; if (link->contains_link_) { diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 73d5adc92..b5f895c5d 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -3183,9 +3183,7 @@ InlineMessageContent create_inline_message_content(Td *td, FileId file_id, file_id.is_valid()); InlineMessageContent result; - tl_object_ptr<telegram_api::ReplyMarkup> reply_markup; - result.disable_web_page_preview = false; - result.invert_media = false; + telegram_api::object_ptr<telegram_api::ReplyMarkup> reply_markup; switch (bot_inline_message->get_id()) { case telegram_api::botInlineMessageText::ID: { auto inline_message = telegram_api::move_object_as<telegram_api::botInlineMessageText>(bot_inline_message); @@ -7343,6 +7341,7 @@ unique_ptr<MessageContent> get_message_content(Td *td, FormattedText message, auto m = make_unique<MessageGame>( Game(td, via_bot_user_id, std::move(media->game_), std::move(message), owner_dialog_id)); if (m->game.is_empty()) { + message = m->game.get_text(); break; } return std::move(m); diff --git a/td/telegram/MessageContent.h b/td/telegram/MessageContent.h index d379c0481..fe3ac2e03 100644 --- a/td/telegram/MessageContent.h +++ b/td/telegram/MessageContent.h @@ -87,8 +87,8 @@ struct InputMessageContent { struct InlineMessageContent { unique_ptr<MessageContent> message_content; unique_ptr<ReplyMarkup> message_reply_markup; - bool disable_web_page_preview; - bool invert_media; + bool disable_web_page_preview = false; + bool invert_media = false; }; void store_message_content(const MessageContent *content, LogEventStorerCalcLength &storer); diff --git a/td/telegram/MessageImportManager.cpp b/td/telegram/MessageImportManager.cpp index 0bce37c9b..247472404 100644 --- a/td/telegram/MessageImportManager.cpp +++ b/td/telegram/MessageImportManager.cpp @@ -441,7 +441,7 @@ void MessageImportManager::start_import_messages(DialogId dialog_id, int64 impor })); auto lock_promise = multipromise.get_promise(); - for (auto attached_file_upload_id : attached_file_upload_ids) { + for (const auto &attached_file_upload_id : attached_file_upload_ids) { upload_imported_message_attachment(dialog_id, import_id, attached_file_upload_id, false, multipromise.get_promise()); } diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 39edf8ea1..331c7c9f9 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -3825,7 +3825,7 @@ void MessagesManager::on_live_location_expire_timeout() { LOG(INFO) << "Have no messages to delete"; schedule_active_live_location_expiration(); } else { - for (auto message_full_id : to_delete_message_full_ids) { + for (const auto &message_full_id : to_delete_message_full_ids) { bool is_deleted = delete_active_live_location(message_full_id); CHECK(is_deleted); } @@ -6685,7 +6685,7 @@ void MessagesManager::restore_missing_messages_after_get_difference() { } } } - for (auto message_full_id : restored_message_full_ids) { + for (const auto &message_full_id : restored_message_full_ids) { messages_to_restore_.erase(message_full_id); } if (missing_messages.empty()) { @@ -13541,7 +13541,6 @@ void MessagesManager::get_dialogs_from_list(DialogListId dialog_list_id, int32 l auto &task = get_dialogs_tasks_[task_id]; task.dialog_list_id = dialog_list_id; task.dialog_list_unique_id = list->unique_id_; - task.retry_count = 5; task.limit = limit; task.promise = std::move(promise); get_dialogs_from_list_impl(task_id); @@ -14410,13 +14409,13 @@ void MessagesManager::get_messages(DialogId dialog_id, const vector<MessageId> & void MessagesManager::get_message_from_server(MessageFullId message_full_id, Promise<Unit> &&promise, const char *source, - tl_object_ptr<telegram_api::InputMessage> input_message) { + telegram_api::object_ptr<telegram_api::InputMessage> input_message) { get_messages_from_server({message_full_id}, std::move(promise), source, std::move(input_message)); } void MessagesManager::get_messages_from_server(vector<MessageFullId> &&message_ids, Promise<Unit> &&promise, const char *source, - tl_object_ptr<telegram_api::InputMessage> input_message) { + telegram_api::object_ptr<telegram_api::InputMessage> input_message) { TRY_STATUS_PROMISE(promise, G()->close_status()); if (message_ids.empty()) { @@ -14428,8 +14427,9 @@ void MessagesManager::get_messages_from_server(vector<MessageFullId> &&message_i CHECK(message_ids.size() == 1); } - vector<tl_object_ptr<telegram_api::InputMessage>> ordinary_message_ids; - FlatHashMap<ChannelId, vector<tl_object_ptr<telegram_api::InputMessage>>, ChannelIdHash> channel_message_ids; + vector<telegram_api::object_ptr<telegram_api::InputMessage>> ordinary_message_ids; + FlatHashMap<ChannelId, vector<telegram_api::object_ptr<telegram_api::InputMessage>>, ChannelIdHash> + channel_message_ids; FlatHashMap<DialogId, vector<int32>, DialogIdHash> scheduled_message_ids; for (auto &message_full_id : message_ids) { auto dialog_id = message_full_id.get_dialog_id(); @@ -14442,7 +14442,7 @@ void MessagesManager::get_messages_from_server(vector<MessageFullId> &&message_i } if (input_message == nullptr) { - input_message = make_tl_object<telegram_api::inputMessageID>(message_id.get_server_message_id().get()); + input_message = telegram_api::make_object<telegram_api::inputMessageID>(message_id.get_server_message_id().get()); } switch (dialog_id.get_type()) { @@ -14951,7 +14951,8 @@ void MessagesManager::on_get_message_link_dialog(MessageLinkInfo &&info, DialogI Dialog *d = get_dialog_force(dialog_id, "on_get_message_link_dialog"); CHECK(d != nullptr); - get_message_force_from_server(d, info.message_id, + auto message_id = info.message_id; + get_message_force_from_server(d, message_id, PromiseCreator::lambda([actor_id = actor_id(this), info = std::move(info), dialog_id, promise = std::move(promise)](Result<Unit> &&result) mutable { if (result.is_error()) { @@ -17637,7 +17638,7 @@ void MessagesManager::schedule_active_live_location_expiration() { live_location_expire_timeout_.cancel_timeout(); } else { double expires_in = std::numeric_limits<int32>::max(); - for (auto message_full_id : active_live_location_message_full_ids_) { + for (const auto &message_full_id : active_live_location_message_full_ids_) { const auto *m = get_message(message_full_id); CHECK(m != nullptr); double live_period = get_message_content_live_location_period(m->content.get()); @@ -18588,6 +18589,7 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId auto debug_last_new_message_id = d->last_new_message_id; bool have_error = false; + auto message_count = messages.size(); auto message_ids = on_get_messages_from_database( d, std::move(messages), d->have_full_history ? MessageId::min() : d->first_database_message_id, have_error, "on_get_history_from_database"); @@ -18650,7 +18652,7 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId } } - if (from_the_end && messages.empty() && d->ordered_messages.empty()) { + if (from_the_end && message_count == 0 && d->ordered_messages.empty()) { if (d->have_full_history) { set_dialog_is_empty(d, "on_get_history_from_database empty"); } else if (d->last_database_message_id.is_valid()) { @@ -18691,10 +18693,10 @@ void MessagesManager::on_get_history_from_database(DialogId dialog_id, MessageId << " from database from the end, but expected messages from " << d->first_database_message_id << " up to " << d->last_database_message_id << ". Have old last_database_message_id = " << old_last_database_message_id << " and " - << messages.size() << " received messages"; + << message_count << " received messages"; } else { - LOG(ERROR) << "Receive " << messages.size() << " unusable messages [" << first_received_message_id - << " ... " << last_received_message_id << "] in " << dialog_id + LOG(ERROR) << "Receive " << message_count << " unusable messages [" << first_received_message_id << " ... " + << last_received_message_id << "] in " << dialog_id << " from database from the end, but expected messages from " << d->first_database_message_id << " up to " << d->last_database_message_id; } @@ -20178,12 +20180,12 @@ vector<FileId> MessagesManager::get_message_file_ids(const Message *m) const { void MessagesManager::cancel_upload_message_content_files(const vector<FileUploadId> &file_upload_ids, const vector<FileUploadId> &thumbnail_file_upload_ids) { // always cancel file upload, it should be a no-op in the worst case - for (auto file_upload_id : file_upload_ids) { + for (const auto &file_upload_id : file_upload_ids) { if (being_uploaded_files_.erase(file_upload_id) || file_upload_id.is_valid()) { cancel_upload_file(file_upload_id, "cancel_upload_message_content_files"); } } - for (auto file_upload_id : thumbnail_file_upload_ids) { + for (const auto &file_upload_id : thumbnail_file_upload_ids) { if (being_uploaded_thumbnails_.erase(file_upload_id) || being_loaded_secret_thumbnails_.erase(file_upload_id) || file_upload_id.is_valid()) { cancel_upload_file(file_upload_id, "cancel_upload_message_content_files"); @@ -20225,7 +20227,7 @@ void MessagesManager::cancel_send_message_query(DialogId dialog_id, Message *m) { auto it = replied_yet_unsent_messages_.find({dialog_id, m->message_id}); if (it != replied_yet_unsent_messages_.end()) { - for (auto message_full_id : it->second) { + for (const auto &message_full_id : it->second) { auto reply_d = get_dialog(message_full_id.get_dialog_id()); CHECK(reply_d != nullptr); auto replied_m = get_message(reply_d, message_full_id.get_message_id()); @@ -22914,7 +22916,7 @@ void MessagesManager::update_message_max_reply_media_timestamp_in_replied_messag LOG(INFO) << "Update max_reply_media_timestamp for replies of " << message_full_id; - for (auto replied_message_full_id : it->second) { + for (const auto &replied_message_full_id : it->second) { auto replied_dialog_id = replied_message_full_id.get_dialog_id(); Dialog *d = get_dialog(replied_dialog_id); auto m = get_message(d, replied_message_full_id.get_message_id()); @@ -22932,7 +22934,7 @@ void MessagesManager::update_story_max_reply_media_timestamp_in_replied_messages LOG(INFO) << "Update max_reply_media_timestamp for replies of " << story_full_id; - for (auto replied_message_full_id : it->second) { + for (const auto &replied_message_full_id : it->second) { auto replied_dialog_id = replied_message_full_id.get_dialog_id(); Dialog *d = get_dialog(replied_dialog_id); auto m = get_message(d, replied_message_full_id.get_message_id()); @@ -26410,7 +26412,7 @@ void MessagesManager::update_reply_to_message_id(DialogId dialog_id, MessageId o CHECK(old_message_id.is_yet_unsent()); CHECK(new_message_id == MessageId() || new_message_id.is_valid() || new_message_id.is_valid_scheduled()); - for (auto message_full_id : it->second) { + for (const auto &message_full_id : it->second) { auto reply_d = get_dialog(message_full_id.get_dialog_id()); CHECK(reply_d != nullptr); auto replied_m = get_message(reply_d, message_full_id.get_message_id()); diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index cf0a3ad03..8b13dd183 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -564,10 +564,10 @@ class MessagesManager final : public Actor { void get_messages(DialogId dialog_id, const vector<MessageId> &message_ids, Promise<Unit> &&promise); void get_message_from_server(MessageFullId message_full_id, Promise<Unit> &&promise, const char *source, - tl_object_ptr<telegram_api::InputMessage> input_message = nullptr); + telegram_api::object_ptr<telegram_api::InputMessage> input_message = nullptr); void get_messages_from_server(vector<MessageFullId> &&message_ids, Promise<Unit> &&promise, const char *source, - tl_object_ptr<telegram_api::InputMessage> input_message = nullptr); + telegram_api::object_ptr<telegram_api::InputMessage> input_message = nullptr); void get_message_properties(DialogId dialog_id, MessageId message_id, Promise<td_api::object_ptr<td_api::messageProperties>> &&promise); @@ -1818,9 +1818,9 @@ class MessagesManager final : public Actor { bool drop_author = false; bool drop_media_captions = false; - Dialog *from_dialog; + Dialog *from_dialog = nullptr; MessageId top_thread_message_id; - Dialog *to_dialog; + Dialog *to_dialog = nullptr; MessageSendOptions message_send_options; }; @@ -3255,9 +3255,9 @@ class MessagesManager final : public Actor { struct GetDialogsTask { DialogListId dialog_list_id; - int64 dialog_list_unique_id; - int32 limit; - int32 retry_count; + int64 dialog_list_unique_id = 0; + int32 limit = 0; + int32 retry_count = 5; DialogDate last_dialog_date = MIN_DIALOG_DATE; Promise<td_api::object_ptr<td_api::chats>> promise; }; diff --git a/td/telegram/NotificationManager.cpp b/td/telegram/NotificationManager.cpp index 641ed74b9..47517efaf 100644 --- a/td/telegram/NotificationManager.cpp +++ b/td/telegram/NotificationManager.cpp @@ -1114,7 +1114,7 @@ void NotificationManager::flush_pending_updates(int32 group_id, const char *sour // all other additions and edits can be merged to the first addition/edit // i.e. in edit+delete+add chain we want to remove deletion and merge addition to the edit - auto group_key = group_keys_[NotificationGroupId(group_id)]; + const auto &group_key = group_keys_[NotificationGroupId(group_id)]; bool is_hidden = group_key.last_notification_date == 0 || get_last_updated_group_key() < group_key; bool is_changed = true; while (is_changed) { diff --git a/td/telegram/NotificationSound.cpp b/td/telegram/NotificationSound.cpp index 46d7d4e44..e93e44123 100644 --- a/td/telegram/NotificationSound.cpp +++ b/td/telegram/NotificationSound.cpp @@ -36,7 +36,7 @@ class NotificationSoundLocal final : public NotificationSound { class NotificationSoundRingtone final : public NotificationSound { public: - int64 ringtone_id_; + int64 ringtone_id_ = 0; NotificationSoundRingtone() = default; explicit NotificationSoundRingtone(int64 ringtone_id) : ringtone_id_(ringtone_id) { @@ -234,7 +234,7 @@ unique_ptr<NotificationSound> get_notification_sound(telegram_api::NotificationS case telegram_api::notificationSoundNone::ID: return make_unique<NotificationSoundNone>(); case telegram_api::notificationSoundLocal::ID: { - const auto *sound = static_cast<telegram_api::notificationSoundLocal *>(notification_sound); + auto *sound = static_cast<telegram_api::notificationSoundLocal *>(notification_sound); return td::make_unique<NotificationSoundLocal>(std::move(sound->title_), std::move(sound->data_)); } case telegram_api::notificationSoundRingtone::ID: { diff --git a/td/telegram/PhoneNumberManager.h b/td/telegram/PhoneNumberManager.h index 201ba0cf3..92495e2cd 100644 --- a/td/telegram/PhoneNumberManager.h +++ b/td/telegram/PhoneNumberManager.h @@ -38,7 +38,7 @@ class PhoneNumberManager final : public Actor { void check_code(string code, Promise<Unit> &&promise); private: - enum class Type : int32 { ChangePhone, VerifyPhone, ConfirmPhone }; + enum class Type : int32 { None, ChangePhone, VerifyPhone, ConfirmPhone }; enum class State : int32 { Ok, WaitCode } state_ = State::Ok; void tear_down() final; @@ -56,7 +56,7 @@ class PhoneNumberManager final : public Actor { Td *td_; ActorShared<> parent_; - Type type_; + Type type_ = Type::None; SendCodeHelper send_code_helper_; int64 generation_ = 0; }; diff --git a/td/telegram/ReactionManager.cpp b/td/telegram/ReactionManager.cpp index 2593de7d2..b33c792de 100644 --- a/td/telegram/ReactionManager.cpp +++ b/td/telegram/ReactionManager.cpp @@ -1344,7 +1344,7 @@ void ReactionManager::on_get_message_effects( for (const auto &available_effect : effects->effects_) { Effect effect; effect.id_ = MessageEffectId(available_effect->id_); - effect.emoji_ = std::move(available_effect->emoticon_); + effect.emoji_ = available_effect->emoticon_; effect.is_premium_ = available_effect->premium_required_; if (available_effect->static_icon_id_ != 0) { auto it = stickers.find(available_effect->static_icon_id_); diff --git a/td/telegram/UserManager.h b/td/telegram/UserManager.h index 4c771840a..21fe919dd 100644 --- a/td/telegram/UserManager.h +++ b/td/telegram/UserManager.h @@ -239,14 +239,14 @@ class UserManager final : public Actor { struct BotData { string username; - bool can_be_edited; - bool can_join_groups; - bool can_read_all_group_messages; - bool has_main_app; - bool is_inline; - bool is_business; - bool need_location; - bool can_be_added_to_attach_menu; + bool can_be_edited = false; + bool can_join_groups = false; + bool can_read_all_group_messages = false; + bool has_main_app = false; + bool is_inline = false; + bool is_business = false; + bool need_location = false; + bool can_be_added_to_attach_menu = false; }; Result<BotData> get_bot_data(UserId user_id) const TD_WARN_UNUSED_RESULT; diff --git a/td/telegram/WebPageBlock.cpp b/td/telegram/WebPageBlock.cpp index dc8902af3..03dbd3c1c 100644 --- a/td/telegram/WebPageBlock.cpp +++ b/td/telegram/WebPageBlock.cpp @@ -1211,8 +1211,8 @@ class WebPageBlockEmbedded final : public WebPageBlock { Photo poster_photo; Dimensions dimensions; WebPageBlockCaption caption; - bool is_full_width; - bool allow_scrolling; + bool is_full_width = false; + bool allow_scrolling = false; public: WebPageBlockEmbedded() = default; @@ -1277,7 +1277,7 @@ class WebPageBlockEmbeddedPost final : public WebPageBlock { string url; string author; Photo author_photo; - int32 date; + int32 date = 0; vector<unique_ptr<WebPageBlock>> page_blocks; WebPageBlockCaption caption; @@ -1651,7 +1651,7 @@ class WebPageBlockTable final : public WebPageBlock { class WebPageBlockDetails final : public WebPageBlock { RichText header; vector<unique_ptr<WebPageBlock>> page_blocks; - bool is_open; + bool is_open = false; public: WebPageBlockDetails() = default; diff --git a/td/telegram/WebPagesManager.cpp b/td/telegram/WebPagesManager.cpp index 97a972abf..91e673d9c 100644 --- a/td/telegram/WebPagesManager.cpp +++ b/td/telegram/WebPagesManager.cpp @@ -721,7 +721,7 @@ void WebPagesManager::update_web_page(unique_ptr<WebPage> web_page, WebPageId we if (from_binlog || from_database) { if (!web_page->story_full_ids_.empty()) { Dependencies dependencies; - for (auto story_full_id : web_page->story_full_ids_) { + for (const auto &story_full_id : web_page->story_full_ids_) { dependencies.add(story_full_id); } if (!dependencies.resolve_force(td_, "update_web_page 1")) { @@ -749,7 +749,7 @@ void WebPagesManager::update_web_page(unique_ptr<WebPage> web_page, WebPageId we } if (page->story_full_ids_ != web_page->story_full_ids_) { - for (auto story_full_id : page->story_full_ids_) { + for (const auto &story_full_id : page->story_full_ids_) { auto it = story_web_pages_.find(story_full_id); if (it != story_web_pages_.end()) { it->second.erase(web_page_id); @@ -758,7 +758,7 @@ void WebPagesManager::update_web_page(unique_ptr<WebPage> web_page, WebPageId we } } } - for (auto story_full_id : web_page->story_full_ids_) { + for (const auto &story_full_id : web_page->story_full_ids_) { story_web_pages_[story_full_id].insert(web_page_id); } } @@ -1438,7 +1438,7 @@ td_api::object_ptr<td_api::LinkPreviewType> WebPagesManager::get_link_preview_ty } } if (caption != nullptr && caption->text_ != nullptr && caption->text_->get_id() == td_api::richTextPlain::ID) { - caption_text = std::move(static_cast<const td_api::richTextPlain *>(caption->text_.get())->text_); + caption_text = std::move(static_cast<td_api::richTextPlain *>(caption->text_.get())->text_); } else { LOG(ERROR) << "Receive instead of caption text: " << to_string(caption); } @@ -2233,7 +2233,7 @@ void WebPagesManager::on_get_web_page_instant_view(WebPage *web_page, tl_object_ class WebPagesManager::WebPageLogEvent { public: WebPageId web_page_id; - const WebPage *web_page_in; + const WebPage *web_page_in = nullptr; unique_ptr<WebPage> web_page_out; WebPageLogEvent() = default; @@ -2503,7 +2503,7 @@ vector<UserId> WebPagesManager::get_web_page_user_ids(WebPageId web_page_id) con const WebPage *web_page = get_web_page(web_page_id); vector<UserId> user_ids; if (web_page != nullptr && !web_page->story_full_ids_.empty()) { - for (auto story_full_id : web_page->story_full_ids_) { + for (const auto &story_full_id : web_page->story_full_ids_) { auto dialog_id = story_full_id.get_dialog_id(); if (dialog_id.get_type() == DialogType::User) { user_ids.push_back(dialog_id.get_user_id()); @@ -2517,7 +2517,7 @@ vector<ChannelId> WebPagesManager::get_web_page_channel_ids(WebPageId web_page_i const WebPage *web_page = get_web_page(web_page_id); vector<ChannelId> channel_ids; if (web_page != nullptr && !web_page->story_full_ids_.empty()) { - for (auto story_full_id : web_page->story_full_ids_) { + for (const auto &story_full_id : web_page->story_full_ids_) { auto dialog_id = story_full_id.get_dialog_id(); if (dialog_id.get_type() == DialogType::Channel) { channel_ids.push_back(dialog_id.get_channel_id()); diff --git a/td/telegram/net/ConnectionCreator.h b/td/telegram/net/ConnectionCreator.h index 5c45f325b..2083c4142 100644 --- a/td/telegram/net/ConnectionCreator.h +++ b/td/telegram/net/ConnectionCreator.h @@ -180,7 +180,7 @@ class ConnectionCreator final : public NetQueryCallback { struct TestProxyRequest { Proxy proxy_; - int16 dc_id_; + int16 dc_id_ = -1; ActorOwn<> child_; Promise<Unit> promise_; diff --git a/td/telegram/net/DcAuthManager.cpp b/td/telegram/net/DcAuthManager.cpp index d60e553e6..f92eddda0 100644 --- a/td/telegram/net/DcAuthManager.cpp +++ b/td/telegram/net/DcAuthManager.cpp @@ -85,6 +85,7 @@ DcAuthManager::DcInfo &DcAuthManager::get_dc(int32 dc_id) { CHECK(dc); return *dc; } + DcAuthManager::DcInfo *DcAuthManager::find_dc(int32 dc_id) { auto it = std::find_if(dcs_.begin(), dcs_.end(), [&](auto &x) { return x.dc_id.get_raw_id() == dc_id; }); if (it == dcs_.end()) { diff --git a/td/telegram/net/DcAuthManager.h b/td/telegram/net/DcAuthManager.h index 2f57cf405..d036fda70 100644 --- a/td/telegram/net/DcAuthManager.h +++ b/td/telegram/net/DcAuthManager.h @@ -38,7 +38,7 @@ class DcAuthManager final : public NetQueryCallback { struct DcInfo { DcId dc_id; std::shared_ptr<AuthDataShared> shared_auth_data; - AuthKeyState auth_key_state; + AuthKeyState auth_key_state = AuthKeyState::Empty; enum class State : int32 { Waiting, Export, Import, BeforeOk, Ok }; State state = State::Waiting; diff --git a/td/telegram/net/Session.h b/td/telegram/net/Session.h index a557ffb1a..9c1e9ccb2 100644 --- a/td/telegram/net/Session.h +++ b/td/telegram/net/Session.h @@ -162,7 +162,7 @@ class Session final double created_at_ = 0; }; - ConnectionInfo *current_info_; + ConnectionInfo *current_info_ = nullptr; ConnectionInfo main_connection_; ConnectionInfo long_poll_connection_; mtproto::ConnectionManager::ConnectionToken connection_token_; @@ -195,7 +195,7 @@ class Session final enum HandshakeId : int32 { MainAuthKeyHandshake = 0, TmpAuthKeyHandshake = 1 }; std::array<HandshakeInfo, 2> handshake_info_; - double wakeup_at_; + double wakeup_at_ = 0.0; // mtproto::AuthData should be the last field, because it's size is about 32 KB mtproto::AuthData auth_data_; diff --git a/tdutils/td/utils/ChainScheduler.h b/tdutils/td/utils/ChainScheduler.h index 9d6bce64f..10dc96122 100644 --- a/tdutils/td/utils/ChainScheduler.h +++ b/tdutils/td/utils/ChainScheduler.h @@ -138,7 +138,7 @@ class ChainScheduler final : public ChainSchedulerBase { struct Task { enum class State { Pending, Active, Paused } state{State::Pending}; vector<TaskChainInfo> chains; - ExtraT extra; + ExtraT extra{}; }; FlatHashMap<ChainId, unique_ptr<ChainInfo>> chains_; FlatHashMap<ChainId, TaskId> limited_tasks_; diff --git a/tdutils/td/utils/ConcurrentHashTable.h b/tdutils/td/utils/ConcurrentHashTable.h index b7bad15a7..dab06fc61 100644 --- a/tdutils/td/utils/ConcurrentHashTable.h +++ b/tdutils/td/utils/ConcurrentHashTable.h @@ -209,12 +209,15 @@ class ConcurrentHashMap { int migrate_generation_{0}; HashMap *migrate_from_hash_map_{nullptr}; HashMap *migrate_to_hash_map_{nullptr}; + struct Task { size_t begin; size_t end; + bool empty() const { return begin >= end; } + size_t size() const { if (empty()) { return 0; @@ -224,9 +227,10 @@ class ConcurrentHashMap { }; struct TaskCreator { - size_t chunk_size; - size_t size; + size_t chunk_size{0}; + size_t size{0}; std::atomic<size_t> pos{0}; + Task create() { auto i = pos++; auto begin = i * chunk_size; diff --git a/tdutils/td/utils/FlatHashMapChunks.h b/tdutils/td/utils/FlatHashMapChunks.h index 35a7aee6a..97f822bd5 100644 --- a/tdutils/td/utils/FlatHashMapChunks.h +++ b/tdutils/td/utils/FlatHashMapChunks.h @@ -68,7 +68,7 @@ struct MaskPortable { static MaskIterator<1> equal_mask(uint8 *bytes, uint8 needle) { uint64 res = 0; for (int i = 0; i < 16; i++) { - res |= (bytes[i] == needle) << i; + res |= static_cast<int>(bytes[i] == needle) << i; } return {res & ((1u << 14) - 1)}; } diff --git a/tdutils/test/ChainScheduler.cpp b/tdutils/test/ChainScheduler.cpp index 19df4f8ce..d338eeccd 100644 --- a/tdutils/test/ChainScheduler.cpp +++ b/tdutils/test/ChainScheduler.cpp @@ -109,7 +109,7 @@ TEST(ChainScheduler, Stress) { int ChainsN = 4; struct QueryWithParents { - TaskId task_id; + TaskId task_id = -1; QueryPtr id; td::vector<QueryPtr> parents; }; diff --git a/test/online.cpp b/test/online.cpp index a85858b91..ca8396373 100644 --- a/test/online.cpp +++ b/test/online.cpp @@ -212,7 +212,7 @@ class InitTask : public Task { public: struct Options { string name; - int32 api_id; + int32 api_id = 0; string api_hash; }; InitTask(Options options, td::Promise<> promise) : options_(std::move(options)), promise_(std::move(promise)) { @@ -279,8 +279,8 @@ class InitTask : public Task { class GetMe : public Task { public: struct Result { - int64 user_id; - int64 chat_id; + int64 user_id = 0; + int64 chat_id = 0; }; explicit GetMe(Promise<Result> promise) : promise_(std::move(promise)) { } @@ -491,7 +491,7 @@ class TestTd : public Actor { private: Options options_; ActorOwn<TestClient> alice_; - GetMe::Result alice_id_; + GetMe::Result alice_id_ = 0; std::string alice_cache_dir_; ActorOwn<TestClient> bob_; |
