Skip to content

Commit

Permalink
Fix some MSVC Analyzer warnings.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: f62e8173ae9a5b78818f6575548ce22d4aa5c51d
  • Loading branch information
levlam committed Oct 26, 2018
1 parent 1f216df commit 28bfa4c
Show file tree
Hide file tree
Showing 47 changed files with 202 additions and 216 deletions.
12 changes: 6 additions & 6 deletions benchmark/bench_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class RingBench : public td::Benchmark {
struct PassActor;

private:
int actor_n_;
int thread_n_;
int actor_n_ = -1;
int thread_n_ = -1;
std::vector<td::ActorId<PassActor>> actor_array_;
td::ConcurrentScheduler *scheduler_;
td::ConcurrentScheduler *scheduler_ = nullptr;

public:
std::string get_description() const override {
Expand All @@ -36,7 +36,7 @@ class RingBench : public td::Benchmark {
}

struct PassActor : public td::Actor {
int id;
int id = -1;
td::ActorId<PassActor> next_actor;
int start_n = 0;

Expand Down Expand Up @@ -232,7 +232,7 @@ class QueryBench : public td::Benchmark {

private:
td::ActorId<ClientActor> client_;
int n_;
int n_ = 0;
td::FutureActor<int> future_;
};

Expand Down Expand Up @@ -262,7 +262,7 @@ class QueryBench : public td::Benchmark {
}

private:
td::ConcurrentScheduler *scheduler_;
td::ConcurrentScheduler *scheduler_ = nullptr;
td::ActorOwn<ServerActor> server_;
};

Expand Down
4 changes: 2 additions & 2 deletions benchmark/bench_http_reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class BufferBench : public td::Benchmark {
}
reader_.sync_with_writer();
for (int j = 0; j < cnt; j++) {
reader_.cut_head(http_query.size());
auto result = reader_.cut_head(http_query.size());
}
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ class FindBoundaryBench : public td::Benchmark {
size_t len = 0;
find_boundary(reader_.clone(), "\r\n\r\n", len);
CHECK(size_t(len) + 4 == http_query.size());
reader_.cut_head(len + 2);
auto result = reader_.cut_head(len + 2);
reader_.advance(2);
}
}
Expand Down
4 changes: 2 additions & 2 deletions td/mtproto/Handshake.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class AuthKeyHandshake {
using State = enum { Start, ResPQ, ServerDHParams, DHGenResponse, Finish };
State state_ = Start;
Mode mode_ = Mode::Unknown;
int32 dc_id_;
int32 expire_in_;
int32 dc_id_ = 0;
int32 expire_in_ = 0;
double expire_at_ = 0;

UInt128 nonce;
Expand Down
9 changes: 7 additions & 2 deletions td/mtproto/IStreamTransport.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,14 @@
namespace td {
namespace mtproto {
struct TransportType {
enum { Tcp, ObfuscatedTcp, Http } type;
enum Type { Tcp, ObfuscatedTcp, Http } type;
int16 dc_id;
std::string secret;
string secret;

TransportType() : type(Tcp), dc_id(0), secret() {
}
TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) {
}
};
class IStreamTransport {
public:
Expand Down
4 changes: 2 additions & 2 deletions td/mtproto/Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,8 @@ class Transport {
private:
Type type_ = Nop;
MutableSlice packet_;
int32 error_code_;
uint32 quick_ack_;
int32 error_code_ = 0;
uint32 quick_ack_ = 0;
};

static Result<uint64> read_auth_key_id(Slice message);
Expand Down
2 changes: 1 addition & 1 deletion td/telegram/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -817,7 +817,7 @@ class CliClient final : public Actor {
if (!data.empty() && data[data.size() - 1] == '\r') {
data.truncate(data.size() - 1);
}
buffer->cut_head(1);
buffer->advance(1);
buffer_pos_ = 0;
return std::move(data);
}
Expand Down
6 changes: 3 additions & 3 deletions td/telegram/logevent/LogEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class WithVersion : public ParentT {
}

private:
int32 version_;
int32 version_{};
};

template <class ParentT, class ContextT>
Expand All @@ -52,7 +52,7 @@ class WithContext : public ParentT {
}

private:
ContextT context_;
ContextT context_{};
};

class LogEvent {
Expand Down Expand Up @@ -109,7 +109,7 @@ class LogEvent {
}

private:
Id logevent_id_;
Id logevent_id_{};
};
inline StringBuilder &operator<<(StringBuilder &sb, const LogEvent &log_event) {
return log_event.print(sb);
Expand Down
22 changes: 11 additions & 11 deletions td/telegram/logevent/SecretChatEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,11 @@ class SecretChatEvent : public LogEventBase<SecretChatEvent> {
// inputEncryptedFileBigUploaded#2dc173c8 id:long parts:int key_fingerprint:int = InputEncryptedFile;
struct EncryptedInputFile {
static constexpr int32 magic = 0x4328d38a;
enum Type : int32 { Empty = 0, Uploaded = 1, BigUploaded = 2, Location = 3 } type;
int64 id;
int64 access_hash;
int32 parts;
int32 key_fingerprint;
enum Type : int32 { Empty = 0, Uploaded = 1, BigUploaded = 2, Location = 3 } type = Type::Empty;
int64 id = 0;
int64 access_hash = 0;
int32 parts = 0;
int32 key_fingerprint = 0;
template <class T>
void store(T &storer) const {
using td::store;
Expand Down Expand Up @@ -140,11 +140,11 @@ inline StringBuilder &operator<<(StringBuilder &sb, const EncryptedInputFile &fi
// encryptedFile#4a70994c id:long access_hash:long size:int dc_id:int key_fingerprint:int = EncryptedFile;
struct EncryptedFileLocation {
static constexpr int32 magic = 0x473d738a;
int64 id;
int64 access_hash;
int32 size;
int32 dc_id;
int32 key_fingerprint;
int64 id = 0;
int64 access_hash = 0;
int32 size = 0;
int32 dc_id = 0;
int32 key_fingerprint = 0;

tl_object_ptr<telegram_api::encryptedFile> as_encrypted_file() {
return make_tl_object<telegram_api::encryptedFile>(id, access_hash, size, dc_id, key_fingerprint);
Expand Down Expand Up @@ -213,7 +213,7 @@ class InboundSecretMessage : public LogEventHelper<InboundSecretMessage, SecretC

EncryptedFileLocation file;

bool has_encrypted_file;
bool has_encrypted_file = false;
bool is_pending = false;

template <class T>
Expand Down
18 changes: 9 additions & 9 deletions td/telegram/net/NetQuery.h
Original file line number Diff line number Diff line change
Expand Up @@ -260,16 +260,16 @@ class NetQuery : public ListNode {

private:
State state_ = State::Empty;
Type type_;
AuthFlag auth_flag_;
GzipFlag gzip_flag_;
Type type_ = Type::Common;
AuthFlag auth_flag_ = AuthFlag::Off;
GzipFlag gzip_flag_ = GzipFlag::Off;
DcId dc_id_;

Status status_;
uint64 id_;
uint64 id_ = 0;
BufferSlice query_;
BufferSlice answer_;
int32 tl_constructor_;
int32 tl_constructor_ = 0;

NetQueryRef invoke_after_;
uint32 session_rand_ = 0;
Expand All @@ -293,7 +293,7 @@ class NetQuery : public ListNode {
static int32 get_my_id();

movable_atomic<uint64> session_id_{0};
uint64 message_id_;
uint64 message_id_{};

movable_atomic<int32> cancellation_token_{-1}; // == 0 if query is canceled
ActorShared<NetQueryCallback> callback_;
Expand All @@ -313,8 +313,8 @@ class NetQuery : public ListNode {
bool need_resend_on_503 = true;
bool may_be_lost_ = false;
string debug_str_ = "empty";
string source_ = "";
double debug_timestamp_;
string source_;
double debug_timestamp_ = 0;
int32 debug_cnt_ = 0;
int32 debug_send_failed_cnt_ = 0;
int32 debug_resend_cnt_ = 0;
Expand All @@ -325,7 +325,7 @@ class NetQuery : public ListNode {
Promise<> quick_ack_promise_;
int32 file_type_ = -1;

double start_timestamp_;
double start_timestamp_ = 0;
int32 my_id_ = 0;
NetQueryCounter nq_counter_;

Expand Down
2 changes: 1 addition & 1 deletion tdactor/td/actor/PromiseFuture.h
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class PromiseActor final : public PromiseInterface<T> {
private:
ActorOwn<FutureActor<T>> future_id_;
EventFull event_;
State state_;
State state_ = State::Hangup;

void init() {
state_ = State::Waiting;
Expand Down
4 changes: 2 additions & 2 deletions tdactor/td/actor/Timeout.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ class Timeout final : public Actor {
private:
friend class Scheduler;

Callback callback_;
Data data_;
Callback callback_{};
Data data_{};

void set_timeout_at(double timeout) {
Actor::set_timeout_at(timeout);
Expand Down
36 changes: 18 additions & 18 deletions tdactor/td/actor/impl/ActorId-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ class ActorId {
explicit ActorId(ObjectPool<ActorInfo>::WeakPtr ptr) : ptr_(ptr) {
}
ActorId() = default;
ActorId(const ActorId &) = default;
ActorId &operator=(const ActorId &) = default;
ActorId(const ActorId &other) = default;
ActorId &operator=(const ActorId &other) = default;
ActorId(ActorId &&other) : ptr_(other.ptr_) {
other.ptr_.clear();
}
Expand Down Expand Up @@ -78,17 +78,17 @@ class ActorOwn {
public:
using ActorT = ActorType;
ActorOwn() = default;
explicit ActorOwn(ActorId<ActorType>);
explicit ActorOwn(ActorId<ActorType> id);
template <class OtherActorType>
explicit ActorOwn(ActorId<OtherActorType> id);
template <class OtherActorType>
explicit ActorOwn(ActorOwn<OtherActorType> &&);
explicit ActorOwn(ActorOwn<OtherActorType> &&other);
template <class OtherActorType>
ActorOwn &operator=(ActorOwn<OtherActorType> &&);
ActorOwn(ActorOwn &&);
ActorOwn &operator=(ActorOwn &&);
ActorOwn(const ActorOwn &) = delete;
ActorOwn &operator=(const ActorOwn &) = delete;
ActorOwn &operator=(ActorOwn<OtherActorType> &&other);
ActorOwn(ActorOwn &&other);
ActorOwn &operator=(ActorOwn &&other);
ActorOwn(const ActorOwn &other) = delete;
ActorOwn &operator=(const ActorOwn &other) = delete;
~ActorOwn();

bool empty() const;
Expand All @@ -114,17 +114,17 @@ class ActorShared {
using ActorT = ActorType;
ActorShared() = default;
template <class OtherActorType>
ActorShared(ActorId<OtherActorType>, uint64 token);
ActorShared(ActorId<OtherActorType> id, uint64 token);
template <class OtherActorType>
ActorShared(ActorShared<OtherActorType> &&);
ActorShared(ActorShared<OtherActorType> &&other);
template <class OtherActorType>
ActorShared(ActorOwn<OtherActorType> &&);
ActorShared(ActorOwn<OtherActorType> &&other);
template <class OtherActorType>
ActorShared &operator=(ActorShared<OtherActorType> &&);
ActorShared(ActorShared &&);
ActorShared &operator=(ActorShared &&);
ActorShared(const ActorShared &) = delete;
ActorShared &operator=(const ActorShared &) = delete;
ActorShared &operator=(ActorShared<OtherActorType> &&other);
ActorShared(ActorShared &&other);
ActorShared &operator=(ActorShared &&other);
ActorShared(const ActorShared &other) = delete;
ActorShared &operator=(const ActorShared &other) = delete;
~ActorShared();

uint64 token() const;
Expand All @@ -141,7 +141,7 @@ class ActorShared {

private:
ActorId<ActorType> id_;
uint64 token_;
uint64 token_ = 0;
};

class ActorRef {
Expand Down
6 changes: 3 additions & 3 deletions tdactor/td/actor/impl/ActorInfo-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ class ActorInfo
void always_wait_for_mailbox();

private:
Deleter deleter_;
bool is_lite_;
bool is_running_;
Deleter deleter_ = Deleter::None;
bool is_lite_ = false;
bool is_running_ = false;
bool always_wait_for_mailbox_{false};
uint32 wait_generation_{0};

Expand Down
2 changes: 1 addition & 1 deletion tdactor/td/actor/impl/ConcurrentScheduler.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ConcurrentScheduler : private Scheduler::Callback {

private:
enum class State { Start, Run };
State state_;
State state_ = State::Start;
std::vector<unique_ptr<Scheduler>> schedulers_;
std::atomic<bool> is_finished_;
std::mutex at_finish_mutex_;
Expand Down
16 changes: 8 additions & 8 deletions tdactor/td/actor/impl/Scheduler-decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ class Scheduler {
Callback *callback_ = nullptr;
unique_ptr<ObjectPool<ActorInfo>> actor_info_pool_;

int32 actor_count_;
int32 actor_count_ = 0;
ListNode pending_actors_list_;
ListNode ready_actors_list_;
KHeap<double> timeout_queue_;
Expand All @@ -215,27 +215,27 @@ class Scheduler {
ServiceActor service_actor_;
Poll poll_;

bool yield_flag_;
bool yield_flag_ = false;
bool has_guard_ = false;
bool close_flag_ = false;

uint32 wait_generation_ = 0;
int32 sched_id_;
int32 sched_n_;
int32 sched_id_ = 0;
int32 sched_n_ = 0;
std::shared_ptr<MpscPollableQueue<EventFull>> inbound_queue_;
std::vector<std::shared_ptr<MpscPollableQueue<EventFull>>> outbound_queues_;

std::shared_ptr<ActorContext> save_context_;

struct EventContext {
int32 dest_sched_id;
int32 dest_sched_id{0};
enum Flags { Stop = 1, Migrate = 2 };
int32 flags{0};
uint64 link_token;
uint64 link_token{0};

ActorInfo *actor_info;
ActorInfo *actor_info{nullptr};
};
EventContext *event_context_ptr_;
EventContext *event_context_ptr_{nullptr};

friend class GlobalScheduler;
friend class SchedulerGuard;
Expand Down
Loading

0 comments on commit 28bfa4c

Please sign in to comment.