Skip to content

Commit 28bfa4c

Browse files
committed
Fix some MSVC Analyzer warnings.
GitOrigin-RevId: f62e8173ae9a5b78818f6575548ce22d4aa5c51d
1 parent 1f216df commit 28bfa4c

47 files changed

Lines changed: 202 additions & 216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎benchmark/bench_actor.cpp‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class RingBench : public td::Benchmark {
2323
struct PassActor;
2424

2525
private:
26-
int actor_n_;
27-
int thread_n_;
26+
int actor_n_ = -1;
27+
int thread_n_ = -1;
2828
std::vector<td::ActorId<PassActor>> actor_array_;
29-
td::ConcurrentScheduler *scheduler_;
29+
td::ConcurrentScheduler *scheduler_ = nullptr;
3030

3131
public:
3232
std::string get_description() const override {
@@ -36,7 +36,7 @@ class RingBench : public td::Benchmark {
3636
}
3737

3838
struct PassActor : public td::Actor {
39-
int id;
39+
int id = -1;
4040
td::ActorId<PassActor> next_actor;
4141
int start_n = 0;
4242

@@ -232,7 +232,7 @@ class QueryBench : public td::Benchmark {
232232

233233
private:
234234
td::ActorId<ClientActor> client_;
235-
int n_;
235+
int n_ = 0;
236236
td::FutureActor<int> future_;
237237
};
238238

@@ -262,7 +262,7 @@ class QueryBench : public td::Benchmark {
262262
}
263263

264264
private:
265-
td::ConcurrentScheduler *scheduler_;
265+
td::ConcurrentScheduler *scheduler_ = nullptr;
266266
td::ActorOwn<ServerActor> server_;
267267
};
268268

‎benchmark/bench_http_reader.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class BufferBench : public td::Benchmark {
6464
}
6565
reader_.sync_with_writer();
6666
for (int j = 0; j < cnt; j++) {
67-
reader_.cut_head(http_query.size());
67+
auto result = reader_.cut_head(http_query.size());
6868
}
6969
}
7070
}
@@ -93,7 +93,7 @@ class FindBoundaryBench : public td::Benchmark {
9393
size_t len = 0;
9494
find_boundary(reader_.clone(), "\r\n\r\n", len);
9595
CHECK(size_t(len) + 4 == http_query.size());
96-
reader_.cut_head(len + 2);
96+
auto result = reader_.cut_head(len + 2);
9797
reader_.advance(2);
9898
}
9999
}

‎td/mtproto/Handshake.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ class AuthKeyHandshake {
8181
using State = enum { Start, ResPQ, ServerDHParams, DHGenResponse, Finish };
8282
State state_ = Start;
8383
Mode mode_ = Mode::Unknown;
84-
int32 dc_id_;
85-
int32 expire_in_;
84+
int32 dc_id_ = 0;
85+
int32 expire_in_ = 0;
8686
double expire_at_ = 0;
8787

8888
UInt128 nonce;

‎td/mtproto/IStreamTransport.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,14 @@
1313
namespace td {
1414
namespace mtproto {
1515
struct TransportType {
16-
enum { Tcp, ObfuscatedTcp, Http } type;
16+
enum Type { Tcp, ObfuscatedTcp, Http } type;
1717
int16 dc_id;
18-
std::string secret;
18+
string secret;
19+
20+
TransportType() : type(Tcp), dc_id(0), secret() {
21+
}
22+
TransportType(Type type, int16 dc_id, string secret) : type(type), dc_id(dc_id), secret(std::move(secret)) {
23+
}
1924
};
2025
class IStreamTransport {
2126
public:

‎td/mtproto/Transport.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,8 @@ class Transport {
186186
private:
187187
Type type_ = Nop;
188188
MutableSlice packet_;
189-
int32 error_code_;
190-
uint32 quick_ack_;
189+
int32 error_code_ = 0;
190+
uint32 quick_ack_ = 0;
191191
};
192192

193193
static Result<uint64> read_auth_key_id(Slice message);

‎td/telegram/cli.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ class CliClient final : public Actor {
817817
if (!data.empty() && data[data.size() - 1] == '\r') {
818818
data.truncate(data.size() - 1);
819819
}
820-
buffer->cut_head(1);
820+
buffer->advance(1);
821821
buffer_pos_ = 0;
822822
return std::move(data);
823823
}

‎td/telegram/logevent/LogEvent.h‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class WithVersion : public ParentT {
3737
}
3838

3939
private:
40-
int32 version_;
40+
int32 version_{};
4141
};
4242

4343
template <class ParentT, class ContextT>
@@ -52,7 +52,7 @@ class WithContext : public ParentT {
5252
}
5353

5454
private:
55-
ContextT context_;
55+
ContextT context_{};
5656
};
5757

5858
class LogEvent {
@@ -109,7 +109,7 @@ class LogEvent {
109109
}
110110

111111
private:
112-
Id logevent_id_;
112+
Id logevent_id_{};
113113
};
114114
inline StringBuilder &operator<<(StringBuilder &sb, const LogEvent &log_event) {
115115
return log_event.print(sb);

‎td/telegram/logevent/SecretChatEvent.h‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,11 @@ class SecretChatEvent : public LogEventBase<SecretChatEvent> {
5555
// inputEncryptedFileBigUploaded#2dc173c8 id:long parts:int key_fingerprint:int = InputEncryptedFile;
5656
struct EncryptedInputFile {
5757
static constexpr int32 magic = 0x4328d38a;
58-
enum Type : int32 { Empty = 0, Uploaded = 1, BigUploaded = 2, Location = 3 } type;
59-
int64 id;
60-
int64 access_hash;
61-
int32 parts;
62-
int32 key_fingerprint;
58+
enum Type : int32 { Empty = 0, Uploaded = 1, BigUploaded = 2, Location = 3 } type = Type::Empty;
59+
int64 id = 0;
60+
int64 access_hash = 0;
61+
int32 parts = 0;
62+
int32 key_fingerprint = 0;
6363
template <class T>
6464
void store(T &storer) const {
6565
using td::store;
@@ -140,11 +140,11 @@ inline StringBuilder &operator<<(StringBuilder &sb, const EncryptedInputFile &fi
140140
// encryptedFile#4a70994c id:long access_hash:long size:int dc_id:int key_fingerprint:int = EncryptedFile;
141141
struct EncryptedFileLocation {
142142
static constexpr int32 magic = 0x473d738a;
143-
int64 id;
144-
int64 access_hash;
145-
int32 size;
146-
int32 dc_id;
147-
int32 key_fingerprint;
143+
int64 id = 0;
144+
int64 access_hash = 0;
145+
int32 size = 0;
146+
int32 dc_id = 0;
147+
int32 key_fingerprint = 0;
148148

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

214214
EncryptedFileLocation file;
215215

216-
bool has_encrypted_file;
216+
bool has_encrypted_file = false;
217217
bool is_pending = false;
218218

219219
template <class T>

‎td/telegram/net/NetQuery.h‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -260,16 +260,16 @@ class NetQuery : public ListNode {
260260

261261
private:
262262
State state_ = State::Empty;
263-
Type type_;
264-
AuthFlag auth_flag_;
265-
GzipFlag gzip_flag_;
263+
Type type_ = Type::Common;
264+
AuthFlag auth_flag_ = AuthFlag::Off;
265+
GzipFlag gzip_flag_ = GzipFlag::Off;
266266
DcId dc_id_;
267267

268268
Status status_;
269-
uint64 id_;
269+
uint64 id_ = 0;
270270
BufferSlice query_;
271271
BufferSlice answer_;
272-
int32 tl_constructor_;
272+
int32 tl_constructor_ = 0;
273273

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

295295
movable_atomic<uint64> session_id_{0};
296-
uint64 message_id_;
296+
uint64 message_id_{};
297297

298298
movable_atomic<int32> cancellation_token_{-1}; // == 0 if query is canceled
299299
ActorShared<NetQueryCallback> callback_;
@@ -313,8 +313,8 @@ class NetQuery : public ListNode {
313313
bool need_resend_on_503 = true;
314314
bool may_be_lost_ = false;
315315
string debug_str_ = "empty";
316-
string source_ = "";
317-
double debug_timestamp_;
316+
string source_;
317+
double debug_timestamp_ = 0;
318318
int32 debug_cnt_ = 0;
319319
int32 debug_send_failed_cnt_ = 0;
320320
int32 debug_resend_cnt_ = 0;
@@ -325,7 +325,7 @@ class NetQuery : public ListNode {
325325
Promise<> quick_ack_promise_;
326326
int32 file_type_ = -1;
327327

328-
double start_timestamp_;
328+
double start_timestamp_ = 0;
329329
int32 my_id_ = 0;
330330
NetQueryCounter nq_counter_;
331331

‎tdactor/td/actor/PromiseFuture.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ class PromiseActor final : public PromiseInterface<T> {
429429
private:
430430
ActorOwn<FutureActor<T>> future_id_;
431431
EventFull event_;
432-
State state_;
432+
State state_ = State::Hangup;
433433

434434
void init() {
435435
state_ = State::Waiting;

0 commit comments

Comments
 (0)