Init some fields just in case.

This commit is contained in:
levlam 2021-11-11 17:39:09 +03:00
parent 712197ad6d
commit b731414d42
46 changed files with 118 additions and 114 deletions

View File

@ -61,7 +61,7 @@ class HttpClient final : public td::HttpOutboundConnection::Callback {
}
td::ActorOwn<td::HttpOutboundConnection> connection_;
int cnt_;
int cnt_ = 0;
};
int main() {

View File

@ -49,7 +49,7 @@ class Transport final : public IStreamTransport {
string secret_;
HttpReader reader_;
HttpQuery http_query_;
ChainBufferWriter *output_;
ChainBufferWriter *output_ = nullptr;
enum { Write, Read } turn_ = Write;
};

View File

@ -14,17 +14,17 @@ namespace mtproto {
struct PacketInfo {
enum { Common, EndToEnd } type = Common;
uint64 auth_key_id;
uint32 message_ack;
UInt128 message_key;
uint64 auth_key_id{0};
uint32 message_ack{0};
UInt128 message_key{};
uint64 salt;
uint64 session_id;
uint64 salt{0};
uint64 session_id{0};
uint64 message_id;
int32 seq_no;
uint64 message_id{0};
int32 seq_no{0};
int32 version{1};
bool no_crypto_flag;
bool no_crypto_flag{false};
bool is_creator{false};
bool check_mod4{true};
bool use_random_padding{false};

View File

@ -188,8 +188,8 @@ class SessionConnection final
uint64 last_ping_message_id_ = 0;
uint64 last_ping_container_id_ = 0;
bool need_destroy_auth_key_{false};
bool sent_destroy_auth_key_{false};
bool need_destroy_auth_key_ = false;
bool sent_destroy_auth_key_ = false;
double wakeup_at_ = 0;
double flush_packet_at_ = 0;
@ -206,7 +206,7 @@ class SessionConnection final
unique_ptr<RawConnection> raw_connection_;
AuthData *auth_data_;
SessionConnection::Callback *callback_ = nullptr;
BufferSlice *current_buffer_slice_;
BufferSlice *current_buffer_slice_ = nullptr;
BufferSlice as_buffer_slice(Slice packet);
auto set_buffer_slice(BufferSlice *buffer_slice) TD_WARN_UNUSED_RESULT {

View File

@ -122,8 +122,8 @@ class OldTransport final : public IStreamTransport {
private:
TransportImpl impl_{false};
ChainBufferReader *input_;
ChainBufferWriter *output_;
ChainBufferReader *input_{nullptr};
ChainBufferWriter *output_{nullptr};
};
class ObfuscatedTransport final : public IStreamTransport {
@ -193,9 +193,9 @@ class ObfuscatedTransport final : public IStreamTransport {
// TODO: use ByteFlow?
// One problem is that BufferedFd owns output_buffer_
// The other problem is that first 56 bytes must be sent unencrypted.
UInt256 output_key_;
UInt256 output_key_{};
AesCtrState output_state_;
ChainBufferWriter *output_;
ChainBufferWriter *output_ = nullptr;
void do_write_tls(BufferWriter &&message);
void do_write_tls(BufferBuilder &&builder);

View File

@ -128,7 +128,6 @@ class TlsHello {
Op::string("\x03\x04\x03\x03\x03\x02\x03\x01"),
Op::grease(3),
Op::string("\x00\x01\x00\x00\x15")};
res.grease_size_ = 7;
#else
res.ops_ = {
Op::string("\x16\x03\x01\x02\x00\x01\x00\x01\xfc\x03\x03"),
@ -163,7 +162,6 @@ class TlsHello {
Op::string("\x03\x04\x03\x03\x03\x02\x03\x01\x00\x1b\x00\x03\x02\x00\x02"),
Op::grease(3),
Op::string("\x00\x01\x00\x00\x15")};
res.grease_size_ = 7;
#endif
return res;
}();
@ -180,7 +178,7 @@ class TlsHello {
private:
std::vector<Op> ops_;
size_t grease_size_;
size_t grease_size_ = 7;
};
class TlsHelloContext {

View File

@ -211,7 +211,7 @@ class AuthManager final : public NetActor {
bool was_check_bot_token_ = false;
bool is_bot_ = false;
uint64 net_query_id_ = 0;
NetQueryType net_query_type_;
NetQueryType net_query_type_ = NetQueryType::None;
vector<uint64> pending_get_authorization_state_requests_;

View File

@ -809,8 +809,9 @@ void BackgroundManager::save_local_backgrounds(bool for_dark_theme) {
void BackgroundManager::upload_background_file(FileId file_id, const BackgroundType &type, bool for_dark_theme,
Promise<Unit> &&promise) {
auto upload_file_id = td_->file_manager_->dup_file_id(file_id);
being_uploaded_files_[upload_file_id] = {type, for_dark_theme, std::move(promise)};
bool is_inserted =
being_uploaded_files_.emplace(upload_file_id, UploadedFileInfo(type, for_dark_theme, std::move(promise))).second;
CHECK(is_inserted);
LOG(INFO) << "Ask to upload background file " << upload_file_id;
td_->file_manager_->upload(upload_file_id, upload_background_file_callback_, 1, 0);
}
@ -821,9 +822,9 @@ void BackgroundManager::on_upload_background_file(FileId file_id, tl_object_ptr<
auto it = being_uploaded_files_.find(file_id);
CHECK(it != being_uploaded_files_.end());
auto type = it->second.type;
auto for_dark_theme = it->second.for_dark_theme;
auto promise = std::move(it->second.promise);
auto type = it->second.type_;
auto for_dark_theme = it->second.for_dark_theme_;
auto promise = std::move(it->second.promise_);
being_uploaded_files_.erase(it);
@ -842,7 +843,7 @@ void BackgroundManager::on_upload_background_file_error(FileId file_id, Status s
auto it = being_uploaded_files_.find(file_id);
CHECK(it != being_uploaded_files_.end());
auto promise = std::move(it->second.promise);
auto promise = std::move(it->second.promise_);
being_uploaded_files_.erase(it);

View File

@ -182,9 +182,13 @@ class BackgroundManager final : public Actor {
std::shared_ptr<UploadBackgroundFileCallback> upload_background_file_callback_;
struct UploadedFileInfo {
BackgroundType type;
bool for_dark_theme;
Promise<Unit> promise;
BackgroundType type_;
bool for_dark_theme_;
Promise<Unit> promise_;
UploadedFileInfo(BackgroundType type, bool for_dark_theme, Promise<Unit> &&promise)
: type_(type), for_dark_theme_(for_dark_theme), promise_(std::move(promise)) {
}
};
std::unordered_map<FileId, UploadedFileInfo, FileIdHash> being_uploaded_files_;

View File

@ -728,7 +728,7 @@ class ConfigRecoverer final : public Actor {
DcOptions dc_options_; // dc_options_update_ + simple_config_
double dc_options_at_{0};
size_t dc_options_i_;
size_t dc_options_i_{0};
size_t date_option_i_{0};

View File

@ -907,7 +907,7 @@ class ContactsManager final : public Actor {
struct SecretChat {
int64 access_hash = 0;
UserId user_id;
SecretChatState state;
SecretChatState state = SecretChatState::Unknown;
string key_hash;
int32 ttl = 0;
int32 date = 0;

View File

@ -79,7 +79,7 @@ class DialogAction {
string get_watching_animations_emoji() const;
struct ClickingAnimateEmojiInfo {
int32 message_id;
int32 message_id = 0;
string emoji;
string data;
};

View File

@ -21,7 +21,7 @@ class ContactsManager;
class DraftMessage {
public:
int32 date;
int32 date = 0;
MessageId reply_to_message_id;
InputMessageText input_message_text;
};

View File

@ -80,13 +80,13 @@ class FileReferenceManager final : public Actor {
return node_id.empty();
}
NodeId node_id;
int64 generation;
int64 generation{0};
};
struct Query {
std::vector<Promise<>> promises;
int32 active_queries{0};
Destination proxy;
int64 generation;
int64 generation{0};
};
struct Node {

View File

@ -452,8 +452,8 @@ class Global final : public ActorContext {
unique_ptr<MtprotoHeader> mtproto_header_;
TdParameters parameters_;
int32 gc_scheduler_id_;
int32 slow_net_scheduler_id_;
int32 gc_scheduler_id_ = 0;
int32 slow_net_scheduler_id_ = 0;
std::atomic<bool> store_all_files_in_files_directory_{false};

View File

@ -157,12 +157,7 @@ Result<InputMessageLocation> process_input_message_location(
return Status::Error(400, "Wrong live location proximity alert radius specified");
}
InputMessageLocation result;
result.location = std::move(location);
result.live_period = period;
result.heading = heading;
result.proximity_alert_radius = proximity_alert_radius;
return std::move(result);
return InputMessageLocation(std::move(location), period, heading, proximity_alert_radius);
}
} // namespace td

View File

@ -126,6 +126,13 @@ struct InputMessageLocation {
int32 live_period;
int32 heading;
int32 proximity_alert_radius;
InputMessageLocation(Location &&location, int32 live_period, int32 heading, int32 proximity_alert_radius)
: location(std::move(location))
, live_period(live_period)
, heading(heading)
, proximity_alert_radius(proximity_alert_radius) {
}
};
Result<InputMessageLocation> process_input_message_location(
td_api::object_ptr<td_api::InputMessageContent> &&input_message_content) TD_WARN_UNUSED_RESULT;

View File

@ -1035,7 +1035,7 @@ class MessagesManager final : public Actor {
// Do not forget to update MessagesManager::update_message and all make_unique<Message> when this class is changed
struct Message {
int32 random_y;
int32 random_y = 0;
MessageId message_id;
UserId sender_user_id;

View File

@ -112,10 +112,10 @@ class PasswordManager final : public NetQueryCallback {
string current_client_salt;
string current_server_salt;
int32 current_srp_g;
int32 current_srp_g = 0;
string current_srp_p;
string current_srp_B;
int64 current_srp_id;
int64 current_srp_id = 0;
NewPasswordState new_state;

View File

@ -42,7 +42,7 @@ class PhoneNumberManager final : public NetActor {
ActorShared<> parent_;
uint64 query_id_ = 0;
uint64 net_query_id_ = 0;
NetQueryType net_query_type_;
NetQueryType net_query_type_ = NetQueryType::None;
SendCodeHelper send_code_helper_;

View File

@ -45,7 +45,7 @@ struct PhotoSizeSource {
Thumbnail(FileType file_type, int32 thumbnail_type) : file_type(file_type), thumbnail_type(thumbnail_type) {
}
FileType file_type;
FileType file_type = FileType::None;
int32 thumbnail_type = 0;
};

View File

@ -520,7 +520,7 @@ class SecretChatActor final : public NetQueryCallback {
return sb;
}
int32 message_id;
int32 message_id = 0;
private:
std::string data;
@ -537,7 +537,7 @@ class SecretChatActor final : public NetQueryCallback {
};
ChangesProcessor<StateChange> changes_processor_;
int32 saved_pfs_state_message_id_;
int32 saved_pfs_state_message_id_ = 0;
SeqNoState seq_no_state_;
bool seq_no_state_changed_ = false;
@ -559,7 +559,7 @@ class SecretChatActor final : public NetQueryCallback {
bool save_changes_finish = false;
bool save_message_finish = false;
LogEvent::Id log_event_id = 0;
int32 message_id;
int32 message_id = 0;
};
Container<InboundMessageState> inbound_message_states_;

View File

@ -183,7 +183,7 @@ struct SecureFileCredentials {
};
struct SecureValueCredentials {
SecureValueType type;
SecureValueType type = SecureValueType::None;
string hash;
optional<SecureDataCredentials> data;
std::vector<SecureFileCredentials> files;

View File

@ -396,8 +396,8 @@ class StickersManager final : public Actor {
UserId user_id;
string title;
string short_name;
bool is_masks;
bool is_animated;
bool is_masks = false;
bool is_animated = false;
vector<FileId> file_ids;
vector<tl_object_ptr<td_api::InputSticker>> stickers;
string software;
@ -789,7 +789,7 @@ class StickersManager final : public Actor {
struct StickerSetLoadRequest {
Promise<Unit> promise;
Status error;
size_t left_queries;
size_t left_queries = 0;
};
std::unordered_map<uint32, StickerSetLoadRequest> sticker_set_load_requests_;

View File

@ -2114,7 +2114,7 @@ class GetArchivedStickerSetsRequest final : public RequestActor<> {
StickerSetId offset_sticker_set_id_;
int32 limit_;
int32 total_count_;
int32 total_count_ = -1;
vector<StickerSetId> sticker_set_ids_;
void do_run(Promise<Unit> &&promise) final {
@ -2555,7 +2555,7 @@ class GetEmojiSuggestionsUrlRequest final : public RequestOnceActor {
public:
GetEmojiSuggestionsUrlRequest(ActorShared<Td> td, uint64 request_id, string &&language_code)
: RequestOnceActor(std::move(td), request_id), language_code_(std::move(language_code)) {
: RequestOnceActor(std::move(td), request_id), language_code_(std::move(language_code)), random_id_(0) {
}
};

View File

@ -42,7 +42,7 @@ class ThemeManager final : public Actor {
int32 message_accent_color = 0;
BackgroundId background_id;
BackgroundType background_type;
BaseTheme base_theme;
BaseTheme base_theme = BaseTheme::Classic;
vector<int32> message_colors;
bool animate_message_colors = false;

View File

@ -174,7 +174,7 @@ class UpdatesManager final : public Actor {
class PendingQtsUpdate {
public:
double receive_time;
double receive_time = 0.0;
tl_object_ptr<telegram_api::Update> update;
vector<Promise<Unit>> promises;
};

View File

@ -675,7 +675,7 @@ class CliClient final : public Actor {
}
struct SearchQuery {
int32 limit;
int32 limit = 0;
string query;
};

View File

@ -49,14 +49,14 @@ class FileLoader : public FileLoaderActor {
bool is_ready = false;
};
struct FileInfo {
int64 size;
int64 size{0};
int64 expected_size{0};
bool is_size_final;
int32 part_size;
bool is_size_final{false};
int32 part_size{0};
std::vector<int> ready_parts;
bool use_part_count_limit = true;
bool only_check = false;
bool need_delay = false;
bool use_part_count_limit{true};
bool only_check{false};
bool need_delay{false};
int64 offset{0};
int64 limit{0};
bool is_upload{false};

View File

@ -538,7 +538,7 @@ class FileManager final : public FileLoadManager::Callback {
int8 download_priority_{0};
int8 upload_priority_{0};
uint64 upload_order_;
uint64 upload_order_{0};
std::shared_ptr<DownloadCallback> download_callback_;
std::shared_ptr<UploadCallback> upload_callback_;

View File

@ -47,7 +47,7 @@ class FileUploader final : public FileLoader {
FileType file_type_ = FileType::Temp;
std::vector<UInt256> iv_map_;
UInt256 iv_;
UInt256 iv_{};
string generate_iv_;
int64 generate_offset_ = 0;
int64 next_offset_ = 0;
@ -55,8 +55,8 @@ class FileUploader final : public FileLoader {
FileFd fd_;
string fd_path_;
bool is_temp_ = false;
int64 file_id_;
bool big_flag_;
int64 file_id_ = 0;
bool big_flag_ = false;
Result<FileInfo> init() final TD_WARN_UNUSED_RESULT;
Status on_ok(int64 size) final TD_WARN_UNUSED_RESULT;

View File

@ -65,28 +65,28 @@ class PartsManager {
int64 checked_prefix_size_{0};
bool known_prefix_flag_{false};
int64 known_prefix_size_;
int64 known_prefix_size_{0};
int64 size_;
int64 expected_size_;
int64 min_size_;
int64 max_size_;
bool unknown_size_flag_;
int64 ready_size_;
int64 streaming_ready_size_;
int64 size_{0};
int64 expected_size_{0};
int64 min_size_{0};
int64 max_size_{0};
bool unknown_size_flag_{false};
int64 ready_size_{0};
int64 streaming_ready_size_{0};
size_t part_size_;
int part_count_;
int pending_count_;
int first_empty_part_;
int first_not_ready_part_;
size_t part_size_{0};
int part_count_{0};
int pending_count_{0};
int first_empty_part_{0};
int first_not_ready_part_{0};
int64 streaming_offset_{0};
int64 streaming_limit_{0};
int first_streaming_empty_part_;
int first_streaming_not_ready_part_;
int first_streaming_empty_part_{0};
int first_streaming_not_ready_part_{0};
vector<PartStatus> part_status_;
Bitmask bitmask_;
bool use_part_count_limit_;
bool use_part_count_limit_{false};
Status init_common(const vector<int> &ready_parts);
Status init_known_prefix(int64 known_prefix, size_t part_size,

View File

@ -35,7 +35,7 @@ class ResourceManager final : public Actor {
Mode mode_;
using NodeId = uint64;
struct Node final : public HeapNode {
NodeId node_id;
NodeId node_id = 0;
ResourceState resource_state_;
ActorShared<FileLoaderActor> callback_;

View File

@ -936,13 +936,13 @@ void ConnectionCreator::client_loop(ClientInfo &client) {
client.checking_connections++;
}
auto promise = PromiseCreator::lambda([actor_id = actor_id(this), check_mode, transport_type = extra.transport_type,
hash = client.hash, debug_str = extra.debug_str,
network_generation =
network_generation_](Result<ConnectionData> r_connection_data) mutable {
send_closure(std::move(actor_id), &ConnectionCreator::client_create_raw_connection, std::move(r_connection_data),
check_mode, std::move(transport_type), hash, std::move(debug_str), network_generation);
});
auto promise = PromiseCreator::lambda(
[actor_id = actor_id(this), check_mode, transport_type = extra.transport_type, hash = client.hash,
debug_str = extra.debug_str,
network_generation = network_generation_](Result<ConnectionData> r_connection_data) mutable {
send_closure(actor_id, &ConnectionCreator::client_create_raw_connection, std::move(r_connection_data),
check_mode, std::move(transport_type), hash, std::move(debug_str), network_generation);
});
auto stats_callback =
td::make_unique<detail::StatsCallback>(client.is_media ? media_net_stats_callback_ : common_net_stats_callback_,
@ -983,7 +983,7 @@ void ConnectionCreator::client_create_raw_connection(Result<ConnectionData> r_co
VLOG(connections) << "Failed connection (" << (check_mode ? "" : "un") << "checked) " << result.error() << ' '
<< debug_str;
}
send_closure(std::move(actor_id), &ConnectionCreator::client_add_connection, hash, std::move(result), check_mode,
send_closure(actor_id, &ConnectionCreator::client_add_connection, hash, std::move(result), check_mode,
auth_data_generation, session_id);
});
@ -1283,7 +1283,7 @@ void ConnectionCreator::loop() {
send_closure(
get_dns_resolver(), &GetHostByNameActor::run, proxy.server().str(), proxy.port(), prefer_ipv6,
PromiseCreator::lambda([actor_id = create_reference(resolve_proxy_query_token_)](Result<IPAddress> result) {
send_closure(std::move(actor_id), &ConnectionCreator::on_proxy_resolved, std::move(result), false);
send_closure(actor_id, &ConnectionCreator::on_proxy_resolved, std::move(result), false);
}));
}
} else {

View File

@ -161,8 +161,8 @@ class ConnectionCreator final : public NetQueryCallback {
bool inited{false};
size_t hash{0};
DcId dc_id;
bool allow_media_only;
bool is_media;
bool allow_media_only{false};
bool is_media{false};
std::set<int64> session_ids_;
unique_ptr<mtproto::AuthData> auth_data;
uint64 auth_data_generation{0};

View File

@ -39,8 +39,8 @@ class DcAuthManager final : public NetQueryCallback {
enum class State : int32 { Waiting, Export, Import, BeforeOk, Ok };
State state = State::Waiting;
uint64 wait_id;
int64 export_id;
uint64 wait_id = 0;
int64 export_id = 0;
BufferSlice export_bytes;
};

View File

@ -78,7 +78,7 @@ class DcOptionsSet {
struct DcOptionInfo {
DcOption option;
int64 stat_id;
int64 stat_id = -1;
size_t pos;
size_t order = 0;

View File

@ -16,7 +16,7 @@ namespace td {
class MtprotoHeader {
public:
struct Options {
int32 api_id;
int32 api_id = -1;
string system_language_code;
string device_model;
string system_version;

View File

@ -140,8 +140,8 @@ class Session final
ListNode sent_queries_list_;
struct ConnectionInfo {
int8 connection_id;
Mode mode;
int8 connection_id = 0;
Mode mode = Mode::Tcp;
enum class State : int8 { Empty, Connecting, Ready } state = State::Empty;
CancellationTokenSource cancellation_token_source_;
unique_ptr<mtproto::SessionConnection> connection;

View File

@ -40,7 +40,7 @@ class SessionProxy final : public Actor {
private:
unique_ptr<Callback> callback_;
std::shared_ptr<AuthDataShared> auth_data_;
AuthKeyState auth_key_state_;
AuthKeyState auth_key_state_ = AuthKeyState::Empty;
bool is_main_;
bool allow_media_only_;
bool is_media_;

View File

@ -95,7 +95,7 @@ class ConcurrentScheduler final : private Scheduler::Callback {
unique_ptr<detail::Iocp> iocp_;
td::thread iocp_thread_;
#endif
int32 extra_scheduler_;
int32 extra_scheduler_ = 0;
void on_finish() final;

View File

@ -597,7 +597,7 @@ class FutureActor final : public Actor {
private:
EventFull event_;
Result<T> result_ = Status::Error(500, "Empty FutureActor");
State state_;
State state_ = State::Waiting;
void set_value(T &&value) {
set_result(std::move(value));

View File

@ -134,7 +134,7 @@ class Binlog {
// AesCtrEncryption
BufferSlice aes_ctr_key_salt_;
UInt256 aes_ctr_key_;
UInt256 aes_ctr_key_{};
AesCtrState aes_ctr_state_;
bool byte_flow_flag_ = false;

View File

@ -62,7 +62,7 @@ class GetHostByNameActor final : public Actor {
ActorOwn<> query;
size_t pos = 0;
string real_host;
double begin_time;
double begin_time = 0.0;
std::vector<std::pair<int, Promise<IPAddress>>> promises;
};
std::unordered_map<string, Query> active_queries_[2];

View File

@ -49,8 +49,8 @@ class TsFileLog final : public LogInterface {
};
static constexpr size_t MAX_THREAD_ID = 128;
int64 rotate_threshold_;
bool redirect_stderr_;
int64 rotate_threshold_ = 0;
bool redirect_stderr_ = false;
std::string path_;
std::array<Info, MAX_THREAD_ID> logs_;
std::mutex init_mutex_;

View File

@ -186,9 +186,8 @@ class HashMapBenchmark final : public td::Benchmark {
td::unique_ptr<HashMap> hash_map;
size_t threads_n = 16;
int mod_;
static constexpr size_t MUL = 7273; //1000000000 + 7;
int n_;
int n_ = 0;
public:
explicit HashMapBenchmark(size_t threads_n) : threads_n(threads_n) {