Skip to content

Commit

Permalink
Init some fields just in case.
Browse files Browse the repository at this point in the history
  • Loading branch information
levlam committed Nov 11, 2021
1 parent 712197a commit b731414
Show file tree
Hide file tree
Showing 46 changed files with 120 additions and 116 deletions.
2 changes: 1 addition & 1 deletion benchmark/bench_http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class HttpClient final : public td::HttpOutboundConnection::Callback {
}

td::ActorOwn<td::HttpOutboundConnection> connection_;
int cnt_;
int cnt_ = 0;
};

int main() {
Expand Down
2 changes: 1 addition & 1 deletion td/mtproto/HttpTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
16 changes: 8 additions & 8 deletions td/mtproto/PacketInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
6 changes: 3 additions & 3 deletions td/mtproto/SessionConnection.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 {
Expand Down
8 changes: 4 additions & 4 deletions td/mtproto/TcpTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions td/mtproto/TlsInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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;
}();
Expand All @@ -180,7 +178,7 @@ class TlsHello {

private:
std::vector<Op> ops_;
size_t grease_size_;
size_t grease_size_ = 7;
};

class TlsHelloContext {
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/AuthManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
13 changes: 7 additions & 6 deletions td/telegram/BackgroundManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);

Expand All @@ -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);

Expand Down
10 changes: 7 additions & 3 deletions td/telegram/BackgroundManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/ContactsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/DialogAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/DraftMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ContactsManager;

class DraftMessage {
public:
int32 date;
int32 date = 0;
MessageId reply_to_message_id;
InputMessageText input_message_text;
};
Expand Down
4 changes: 2 additions & 2 deletions td/telegram/FileReferenceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions td/telegram/Global.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down
7 changes: 1 addition & 6 deletions td/telegram/Location.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions td/telegram/Location.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/MessagesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions td/telegram/PasswordManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/PhoneNumberManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_;

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/PhotoSizeSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};

Expand Down
6 changes: 3 additions & 3 deletions td/telegram/SecretChatActor.h
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,7 @@ class SecretChatActor final : public NetQueryCallback {
return sb;
}

int32 message_id;
int32 message_id = 0;

private:
std::string data;
Expand All @@ -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;
Expand All @@ -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_;

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/SecureValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ struct SecureFileCredentials {
};

struct SecureValueCredentials {
SecureValueType type;
SecureValueType type = SecureValueType::None;
string hash;
optional<SecureDataCredentials> data;
std::vector<SecureFileCredentials> files;
Expand Down
6 changes: 3 additions & 3 deletions td/telegram/StickersManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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_;
Expand Down
4 changes: 2 additions & 2 deletions td/telegram/Td.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
}
};

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/ThemeManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion td/telegram/UpdatesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
Loading

0 comments on commit b731414

Please sign in to comment.