Fix some MSVC Analyzer warnings.
GitOrigin-RevId: f62e8173ae9a5b78818f6575548ce22d4aa5c51d
This commit is contained in:
parent
1f216df1d8
commit
28bfa4c4a6
@ -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 {
|
||||
@ -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;
|
||||
|
||||
@ -232,7 +232,7 @@ class QueryBench : public td::Benchmark {
|
||||
|
||||
private:
|
||||
td::ActorId<ClientActor> client_;
|
||||
int n_;
|
||||
int n_ = 0;
|
||||
td::FutureActor<int> future_;
|
||||
};
|
||||
|
||||
@ -262,7 +262,7 @@ class QueryBench : public td::Benchmark {
|
||||
}
|
||||
|
||||
private:
|
||||
td::ConcurrentScheduler *scheduler_;
|
||||
td::ConcurrentScheduler *scheduler_ = nullptr;
|
||||
td::ActorOwn<ServerActor> server_;
|
||||
};
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ class WithVersion : public ParentT {
|
||||
}
|
||||
|
||||
private:
|
||||
int32 version_;
|
||||
int32 version_{};
|
||||
};
|
||||
|
||||
template <class ParentT, class ContextT>
|
||||
@ -52,7 +52,7 @@ class WithContext : public ParentT {
|
||||
}
|
||||
|
||||
private:
|
||||
ContextT context_;
|
||||
ContextT context_{};
|
||||
};
|
||||
|
||||
class LogEvent {
|
||||
@ -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);
|
||||
|
@ -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;
|
||||
@ -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);
|
||||
@ -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>
|
||||
|
@ -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;
|
||||
@ -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_;
|
||||
@ -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;
|
||||
@ -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_;
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
@ -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;
|
||||
@ -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;
|
||||
@ -141,7 +141,7 @@ class ActorShared {
|
||||
|
||||
private:
|
||||
ActorId<ActorType> id_;
|
||||
uint64 token_;
|
||||
uint64 token_ = 0;
|
||||
};
|
||||
|
||||
class ActorRef {
|
||||
|
@ -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};
|
||||
|
||||
|
@ -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_;
|
||||
|
@ -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_;
|
||||
@ -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;
|
||||
|
@ -49,8 +49,8 @@ static uint32 slow_pow_mod_uint32(uint32 x, uint32 p) {
|
||||
}
|
||||
|
||||
struct Query {
|
||||
uint32 query_id;
|
||||
uint32 result;
|
||||
uint32 query_id{};
|
||||
uint32 result{};
|
||||
std::vector<int> todo;
|
||||
Query() = default;
|
||||
Query(const Query &) = delete;
|
||||
@ -336,7 +336,7 @@ class SimpleActor final : public Actor {
|
||||
ActorId<Worker> worker_;
|
||||
FutureActor<uint32> future_;
|
||||
uint32 q_ = 1;
|
||||
uint32 p_;
|
||||
uint32 p_ = 0;
|
||||
};
|
||||
} // namespace
|
||||
|
||||
@ -399,7 +399,7 @@ TEST(Actors, send_to_dead) {
|
||||
int threads_n = 5;
|
||||
sched.init(threads_n);
|
||||
|
||||
sched.create_actor_unsafe<SendToDead>(0, "manager").release();
|
||||
auto actor_id = sched.create_actor_unsafe<SendToDead>(0, "SendToDead").release();
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
// empty
|
||||
@ -414,7 +414,7 @@ TEST(Actors, main_simple) {
|
||||
int threads_n = 3;
|
||||
sched.init(threads_n);
|
||||
|
||||
sched.create_actor_unsafe<SimpleActor>(threads_n > 1 ? 1 : 0, "simple", threads_n).release();
|
||||
auto actor_id = sched.create_actor_unsafe<SimpleActor>(threads_n > 1 ? 1 : 0, "simple", threads_n).release();
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
// empty
|
||||
@ -429,7 +429,7 @@ TEST(Actors, main) {
|
||||
int threads_n = 9;
|
||||
sched.init(threads_n);
|
||||
|
||||
sched.create_actor_unsafe<MainQueryActor>(threads_n > 1 ? 1 : 0, "manager", threads_n).release();
|
||||
auto actor_id = sched.create_actor_unsafe<MainQueryActor>(threads_n > 1 ? 1 : 0, "MainQuery", threads_n).release();
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
// empty
|
||||
@ -457,7 +457,7 @@ TEST(Actors, do_after_stop) {
|
||||
int threads_n = 0;
|
||||
sched.init(threads_n);
|
||||
|
||||
sched.create_actor_unsafe<DoAfterStop>(0, "manager").release();
|
||||
auto actor_id = sched.create_actor_unsafe<DoAfterStop>(0, "DoAfterStop").release();
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
// empty
|
||||
|
@ -290,7 +290,7 @@ class OpenClose final : public Actor {
|
||||
auto r_file_fd = FileFd::open("server", FileFd::Read | FileFd::Create);
|
||||
CHECK(r_file_fd.is_ok()) << r_file_fd.error();
|
||||
auto file_fd = r_file_fd.move_as_ok();
|
||||
file_fd.get_poll_info().extract_pollable_fd(observer);
|
||||
{ PollableFd pollable_fd = file_fd.get_poll_info().extract_pollable_fd(observer); }
|
||||
file_fd.close();
|
||||
cnt_--;
|
||||
yield();
|
||||
@ -396,7 +396,7 @@ class LinkTokenMasterActor : public Actor {
|
||||
}
|
||||
void loop() override {
|
||||
for (int i = 0; i < 100 && cnt_ > 0; cnt_--, i++) {
|
||||
auto token = static_cast<uint64>(cnt_ + 1);
|
||||
auto token = static_cast<uint64>(cnt_) + 1;
|
||||
switch (i % 4) {
|
||||
case 0: {
|
||||
send_closure(ActorShared<LinkTokenSlave>(child_, token), &LinkTokenSlave::add, token);
|
||||
|
@ -51,7 +51,10 @@ class PowerWorker final : public Actor {
|
||||
class Manager final : public Actor {
|
||||
public:
|
||||
Manager(int queries_n, int query_size, std::vector<ActorId<PowerWorker>> workers)
|
||||
: workers_(std::move(workers)), left_query_(queries_n), query_size_(query_size) {
|
||||
: workers_(std::move(workers))
|
||||
, ref_cnt_(static_cast<int>(workers_.size()))
|
||||
, left_query_(queries_n)
|
||||
, query_size_(query_size) {
|
||||
}
|
||||
|
||||
class Callback : public PowerWorker::Callback {
|
||||
@ -71,7 +74,6 @@ class Manager final : public Actor {
|
||||
};
|
||||
|
||||
void start_up() override {
|
||||
ref_cnt_ = static_cast<int>(workers_.size());
|
||||
int i = 0;
|
||||
for (auto &worker : workers_) {
|
||||
ref_cnt_++;
|
||||
@ -103,8 +105,8 @@ class Manager final : public Actor {
|
||||
|
||||
private:
|
||||
std::vector<ActorId<PowerWorker>> workers_;
|
||||
int left_query_;
|
||||
int ref_cnt_;
|
||||
int left_query_;
|
||||
int query_size_;
|
||||
};
|
||||
|
||||
@ -119,7 +121,7 @@ void test_workers(int threads_n, int workers_n, int queries_n, int query_size) {
|
||||
int thread_id = threads_n ? i % (threads_n - 1) + 2 : 0;
|
||||
workers.push_back(sched.create_actor_unsafe<PowerWorker>(thread_id, PSLICE() << "worker" << i).release());
|
||||
}
|
||||
sched.create_actor_unsafe<Manager>(threads_n ? 1 : 0, "manager", queries_n, query_size, std::move(workers)).release();
|
||||
sched.create_actor_unsafe<Manager>(threads_n ? 1 : 0, "Manager", queries_n, query_size, std::move(workers)).release();
|
||||
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
|
@ -50,11 +50,11 @@ class SqliteDb {
|
||||
Status exec(CSlice cmd) TD_WARN_UNUSED_RESULT;
|
||||
Result<bool> has_table(Slice table);
|
||||
Result<string> get_pragma(Slice name);
|
||||
Status begin_transaction();
|
||||
Status commit_transaction();
|
||||
Status begin_transaction() TD_WARN_UNUSED_RESULT;
|
||||
Status commit_transaction() TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Result<int32> user_version();
|
||||
Status set_user_version(int32 version);
|
||||
Status set_user_version(int32 version) TD_WARN_UNUSED_RESULT;
|
||||
void trace(bool flag);
|
||||
|
||||
static Status destroy(Slice path) TD_WARN_UNUSED_RESULT;
|
||||
|
@ -91,7 +91,6 @@ struct AesCtrEncryptionEvent {
|
||||
|
||||
class BinlogReader {
|
||||
public:
|
||||
BinlogReader() = default;
|
||||
explicit BinlogReader(ChainBufferReader *input) : input_(input) {
|
||||
}
|
||||
void set_input(ChainBufferReader *input, bool is_encrypted, int64 expected_size) {
|
||||
@ -480,7 +479,7 @@ Status Binlog::load_binlog(const Callback &callback, const Callback &debug_callb
|
||||
buffer_writer_ = ChainBufferWriter();
|
||||
buffer_reader_ = buffer_writer_.extract_reader();
|
||||
fd_.set_input_writer(&buffer_writer_);
|
||||
detail::BinlogReader reader;
|
||||
detail::BinlogReader reader{nullptr};
|
||||
binlog_reader_ptr_ = &reader;
|
||||
|
||||
update_read_encryption();
|
||||
|
@ -23,8 +23,8 @@
|
||||
|
||||
namespace td {
|
||||
struct BinlogInfo {
|
||||
bool was_created;
|
||||
uint64 last_id;
|
||||
bool was_created{false};
|
||||
uint64 last_id{0};
|
||||
bool is_encrypted{false};
|
||||
bool wrong_password{false};
|
||||
bool is_opened{false};
|
||||
@ -100,7 +100,7 @@ class Binlog {
|
||||
BufferedFdBase<FileFd> fd_;
|
||||
ChainBufferWriter buffer_writer_;
|
||||
ChainBufferReader buffer_reader_;
|
||||
detail::BinlogReader *binlog_reader_ptr_;
|
||||
detail::BinlogReader *binlog_reader_ptr_ = nullptr;
|
||||
|
||||
BinlogInfo info_;
|
||||
DbKey db_key_;
|
||||
|
@ -62,7 +62,7 @@ void HttpChunkedByteFlow::loop() {
|
||||
need_size = 2;
|
||||
break;
|
||||
}
|
||||
input_->cut_head(2);
|
||||
input_->advance(2);
|
||||
total_size_ += 2;
|
||||
if (save_len_ == 0) {
|
||||
return finish(Status::OK());
|
||||
|
@ -20,7 +20,7 @@ class HttpChunkedByteFlow final : public ByteFlowBase {
|
||||
static constexpr size_t MIN_UPDATE_SIZE = 1 << 14;
|
||||
enum { ReadChunkLength, ReadChunkContent, OK } state_ = ReadChunkLength;
|
||||
size_t len_ = 0;
|
||||
size_t save_len_;
|
||||
size_t save_len_ = 0;
|
||||
size_t total_size_ = 0;
|
||||
size_t uncommited_size_ = 0;
|
||||
};
|
||||
|
@ -22,13 +22,13 @@ class HttpQuery {
|
||||
enum class Type : int8 { EMPTY, GET, POST, RESPONSE };
|
||||
|
||||
std::vector<BufferSlice> container_;
|
||||
Type type_;
|
||||
Type type_ = Type::EMPTY;
|
||||
MutableSlice url_path_;
|
||||
std::vector<std::pair<MutableSlice, MutableSlice>> args_;
|
||||
int code_;
|
||||
int code_ = 0;
|
||||
MutableSlice reason_;
|
||||
|
||||
bool keep_alive_;
|
||||
bool keep_alive_ = true;
|
||||
std::vector<std::pair<MutableSlice, MutableSlice>> headers_;
|
||||
std::vector<HttpFile> files_;
|
||||
MutableSlice content_;
|
||||
|
@ -43,31 +43,31 @@ class HttpReader {
|
||||
static void delete_temp_file(CSlice file_name);
|
||||
|
||||
private:
|
||||
size_t max_post_size_;
|
||||
size_t max_files_;
|
||||
size_t max_post_size_ = 0;
|
||||
size_t max_files_ = 0;
|
||||
|
||||
enum { ReadHeaders, ReadContent, ReadContentToFile, ReadArgs, ReadMultipartFormData } state_;
|
||||
size_t headers_read_length_;
|
||||
size_t content_length_;
|
||||
ChainBufferReader *input_;
|
||||
size_t headers_read_length_ = 0;
|
||||
size_t content_length_ = 0;
|
||||
ChainBufferReader *input_ = nullptr;
|
||||
ByteFlowSource flow_source_;
|
||||
HttpChunkedByteFlow chunked_flow_;
|
||||
GzipByteFlow gzip_flow_;
|
||||
HttpContentLengthByteFlow content_length_flow_;
|
||||
ByteFlowSink flow_sink_;
|
||||
ChainBufferReader *content_;
|
||||
ChainBufferReader *content_ = nullptr;
|
||||
|
||||
HttpQuery *query_;
|
||||
HttpQuery *query_ = nullptr;
|
||||
Slice transfer_encoding_;
|
||||
Slice content_encoding_;
|
||||
Slice content_type_;
|
||||
string content_type_lowercased_;
|
||||
size_t total_parameters_length_;
|
||||
size_t total_headers_length_;
|
||||
size_t total_parameters_length_ = 0;
|
||||
size_t total_headers_length_ = 0;
|
||||
|
||||
string boundary_;
|
||||
size_t form_data_read_length_;
|
||||
size_t form_data_skipped_length_;
|
||||
size_t form_data_read_length_ = 0;
|
||||
size_t form_data_skipped_length_ = 0;
|
||||
enum {
|
||||
SkipPrologue,
|
||||
ReadPartHeaders,
|
||||
@ -83,7 +83,7 @@ class HttpReader {
|
||||
bool has_file_name_ = false;
|
||||
FileFd temp_file_;
|
||||
string temp_file_name_;
|
||||
int64 file_size_;
|
||||
int64 file_size_ = 0;
|
||||
|
||||
Result<size_t> split_header() TD_WARN_UNUSED_RESULT;
|
||||
void process_header(MutableSlice header_name, MutableSlice header_value);
|
||||
|
@ -77,7 +77,7 @@ class tl_config_parser {
|
||||
std::string try_parse_string();
|
||||
|
||||
public:
|
||||
tl_config_parser(const char *s, std::size_t len) : p(s, len) {
|
||||
tl_config_parser(const char *s, std::size_t len) : p(s, len), schema_version(-1) {
|
||||
}
|
||||
|
||||
tl_config parse_config();
|
||||
|
@ -106,17 +106,15 @@ static void write_function_fetch(tl_outputer &out, const std::string &parser_nam
|
||||
out.append(w.gen_fetch_function_end(false, field_num, vars, parser_type));
|
||||
}
|
||||
|
||||
static std::vector<var_description> write_function_store(tl_outputer &out, const std::string &storer_name,
|
||||
const tl_combinator *t, const std::string &class_name,
|
||||
std::vector<var_description> &vars,
|
||||
const std::set<std::string> &request_types,
|
||||
const std::set<std::string> &result_types,
|
||||
const TL_writer &w) {
|
||||
static void write_function_store(tl_outputer &out, const std::string &storer_name, const tl_combinator *t,
|
||||
const std::string &class_name, std::vector<var_description> &vars,
|
||||
const std::set<std::string> &request_types, const std::set<std::string> &result_types,
|
||||
const TL_writer &w) {
|
||||
// std::fprintf(stderr, "Write function store %s\n", class_name.c_str());
|
||||
int storer_type = w.get_storer_type(t, storer_name);
|
||||
|
||||
if (!is_reachable_for_storer(storer_type, t->name, request_types, result_types, w)) {
|
||||
return vars;
|
||||
return;
|
||||
}
|
||||
|
||||
out.append(w.gen_store_function_begin(storer_name, class_name, 0, vars, storer_type));
|
||||
@ -126,8 +124,6 @@ static std::vector<var_description> write_function_store(tl_outputer &out, const
|
||||
}
|
||||
|
||||
out.append(w.gen_store_function_end(vars, storer_type));
|
||||
|
||||
return vars;
|
||||
}
|
||||
|
||||
static void write_function_result_fetch(tl_outputer &out, const std::string &parser_name, const tl_combinator *t,
|
||||
|
@ -69,7 +69,7 @@ class ByteFlowBaseCommon : public ByteFlowInterface {
|
||||
|
||||
protected:
|
||||
bool waiting_flag_ = false;
|
||||
ChainBufferReader *input_;
|
||||
ChainBufferReader *input_ = nullptr;
|
||||
bool is_input_active_ = true;
|
||||
size_t need_size_ = 0;
|
||||
void finish(Status status) {
|
||||
|
@ -33,8 +33,8 @@ class FileLog : public LogInterface {
|
||||
private:
|
||||
FileFd fd_;
|
||||
string path_;
|
||||
int64 size_;
|
||||
int64 rotate_threshold_;
|
||||
int64 size_ = 0;
|
||||
int64 rotate_threshold_ = 0;
|
||||
|
||||
void do_rotate();
|
||||
};
|
||||
|
@ -15,12 +15,12 @@ namespace td {
|
||||
|
||||
class HttpUrl {
|
||||
public:
|
||||
enum class Protocol { HTTP, HTTPS } protocol_;
|
||||
enum class Protocol { HTTP, HTTPS } protocol_ = Protocol::HTTP;
|
||||
string userinfo_;
|
||||
string host_;
|
||||
bool is_ipv6_;
|
||||
int specified_port_;
|
||||
int port_;
|
||||
bool is_ipv6_ = false;
|
||||
int specified_port_ = 0;
|
||||
int port_ = 0;
|
||||
string query_;
|
||||
|
||||
string get_url() const;
|
||||
|
@ -200,8 +200,7 @@ class Jsonable {};
|
||||
|
||||
class JsonScope {
|
||||
public:
|
||||
explicit JsonScope(JsonBuilder *jb) : sb_(&jb->sb_), jb_(jb) {
|
||||
save_scope_ = jb_->scope_;
|
||||
explicit JsonScope(JsonBuilder *jb) : sb_(&jb->sb_), jb_(jb), save_scope_(jb->scope_) {
|
||||
jb_->scope_ = this;
|
||||
CHECK(is_active());
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ class OneValue {
|
||||
private:
|
||||
enum Type : int { Empty = 0, Taken, Value };
|
||||
std::atomic<int> state_{Empty};
|
||||
T value_;
|
||||
T value_{};
|
||||
};
|
||||
|
||||
template <class T>
|
||||
|
@ -22,7 +22,6 @@
|
||||
namespace td {
|
||||
|
||||
class OptionsParser {
|
||||
public:
|
||||
class Option {
|
||||
public:
|
||||
enum Type { NoArg, Arg, OptionalArg };
|
||||
@ -33,6 +32,7 @@ class OptionsParser {
|
||||
std::function<Status(Slice)> arg_callback;
|
||||
};
|
||||
|
||||
public:
|
||||
void set_description(std::string description) {
|
||||
description_ = std::move(description);
|
||||
}
|
||||
|
@ -116,7 +116,7 @@ StringBuilder &StringBuilder::operator<<(FixedDouble x) {
|
||||
|
||||
static TD_THREAD_LOCAL std::stringstream *ss;
|
||||
if (init_thread_local<std::stringstream>(ss)) {
|
||||
ss->imbue(std::locale::classic());
|
||||
auto previous_locale = ss->imbue(std::locale::classic());
|
||||
ss->setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||
} else {
|
||||
ss->str(std::string());
|
||||
|
@ -593,13 +593,13 @@ class ChainBufferReader {
|
||||
|
||||
// Return [begin_, tail.begin_)
|
||||
// *this = tail
|
||||
ChainBufferReader cut_head(ChainBufferIterator pos) {
|
||||
ChainBufferReader cut_head(ChainBufferIterator pos) TD_WARN_UNUSED_RESULT {
|
||||
auto tmp = begin_.clone();
|
||||
begin_ = pos.clone();
|
||||
return ChainBufferReader(std::move(tmp), std::move(pos), false);
|
||||
}
|
||||
|
||||
ChainBufferReader cut_head(size_t offset) {
|
||||
ChainBufferReader cut_head(size_t offset) TD_WARN_UNUSED_RESULT {
|
||||
CHECK(offset <= size()) << offset << " " << size();
|
||||
auto it = begin_.clone();
|
||||
it.advance(offset);
|
||||
|
@ -14,9 +14,9 @@ namespace td {
|
||||
|
||||
Result<BufferSlice> read_file(CSlice path, int64 size = -1);
|
||||
|
||||
Status copy_file(CSlice from, CSlice to, int64 size = -1);
|
||||
Status copy_file(CSlice from, CSlice to, int64 size = -1) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
Status write_file(CSlice to, Slice data);
|
||||
Status write_file(CSlice to, Slice data) TD_WARN_UNUSED_RESULT;
|
||||
|
||||
std::string clean_filename(CSlice name);
|
||||
} // namespace td
|
||||
|
@ -63,7 +63,7 @@ string oneline(Slice str) {
|
||||
double to_double(Slice str) {
|
||||
static TD_THREAD_LOCAL std::stringstream *ss;
|
||||
if (init_thread_local<std::stringstream>(ss)) {
|
||||
ss->imbue(std::locale::classic());
|
||||
auto previous_locale = ss->imbue(std::locale::classic());
|
||||
} else {
|
||||
ss->str(std::string());
|
||||
ss->clear();
|
||||
|
@ -26,7 +26,7 @@ void WineventPoll::subscribe(PollableFd fd, PollFlags flags) {
|
||||
}
|
||||
|
||||
void WineventPoll::unsubscribe(PollableFdRef fd) {
|
||||
fd.lock();
|
||||
auto pollable_fd = fd.lock(); // unlocked in destructor
|
||||
}
|
||||
|
||||
void WineventPoll::unsubscribe_before_close(PollableFdRef fd) {
|
||||
|
@ -99,7 +99,7 @@ class Test : private ListNode {
|
||||
struct State {
|
||||
ListNode *it = nullptr;
|
||||
bool is_running = false;
|
||||
double start;
|
||||
double start = 0;
|
||||
ListNode *end = nullptr;
|
||||
};
|
||||
static State *get_state() {
|
||||
|
@ -86,7 +86,7 @@ TEST(OneValue, stress) {
|
||||
|
||||
TEST(MpmcQueueBlock, simple) {
|
||||
// Test doesn't work now and it is ok, try_pop, logic changed
|
||||
return;
|
||||
/*
|
||||
td::MpmcQueueBlock<std::string> block(2);
|
||||
std::string x = "hello";
|
||||
using PushStatus = td::MpmcQueueBlock<std::string>::PushStatus;
|
||||
@ -111,6 +111,7 @@ TEST(MpmcQueueBlock, simple) {
|
||||
CHECK(pop_status == PopStatus::Ok);
|
||||
pop_status = block.try_pop(x);
|
||||
CHECK(pop_status == PopStatus::Closed);
|
||||
*/
|
||||
}
|
||||
|
||||
TEST(MpmcQueue, simple) {
|
||||
|
@ -80,15 +80,15 @@ TEST(SharedObjectPool, simple) {
|
||||
};
|
||||
{
|
||||
td::SharedObjectPool<Node> pool;
|
||||
pool.alloc();
|
||||
pool.alloc();
|
||||
pool.alloc();
|
||||
pool.alloc();
|
||||
pool.alloc();
|
||||
{ auto ptr1 = pool.alloc(); }
|
||||
{ auto ptr2 = pool.alloc(); }
|
||||
{ auto ptr3 = pool.alloc(); }
|
||||
{ auto ptr4 = pool.alloc(); }
|
||||
{ auto ptr5 = pool.alloc(); }
|
||||
CHECK(Node::cnt() == 0);
|
||||
CHECK(pool.total_size() == 1);
|
||||
CHECK(pool.calc_free_size() == 1);
|
||||
pool.alloc(), pool.alloc(), pool.alloc();
|
||||
{ auto ptr6 = pool.alloc(), ptr7 = pool.alloc(), ptr8 = pool.alloc(); }
|
||||
CHECK(pool.total_size() == 3);
|
||||
CHECK(pool.calc_free_size() == 3);
|
||||
}
|
||||
|
@ -259,9 +259,11 @@ TEST(Misc, to_double) {
|
||||
test_to_double();
|
||||
const char *locale_name = (std::setlocale(LC_ALL, "fr-FR") == nullptr ? "" : "fr-FR");
|
||||
std::locale new_locale(locale_name);
|
||||
std::locale::global(new_locale);
|
||||
auto host_locale = std::locale::global(new_locale);
|
||||
test_to_double();
|
||||
std::locale::global(std::locale::classic());
|
||||
new_locale = std::locale::global(std::locale::classic());
|
||||
test_to_double();
|
||||
auto classic_locale = std::locale::global(host_locale);
|
||||
test_to_double();
|
||||
}
|
||||
|
||||
|
35
test/db.cpp
35
test/db.cpp
@ -134,7 +134,7 @@ TEST(DB, sqlite_encryption) {
|
||||
|
||||
{
|
||||
auto db = SqliteDb::open_with_key(path, empty).move_as_ok();
|
||||
db.set_user_version(123);
|
||||
db.set_user_version(123).ensure();
|
||||
auto kv = SqliteKeyValue();
|
||||
kv.init_with_connection(db.clone(), "kv").ensure();
|
||||
kv.set("a", "b");
|
||||
@ -179,7 +179,7 @@ TEST(DB, sqlite_encryption) {
|
||||
|
||||
using SeqNo = uint64;
|
||||
struct DbQuery {
|
||||
enum Type { Get, Set, Erase } type;
|
||||
enum class Type { Get, Set, Erase } type = Type::Get;
|
||||
SeqNo tid = 0;
|
||||
int32 id = 0;
|
||||
string key;
|
||||
@ -194,13 +194,13 @@ class QueryHandler {
|
||||
}
|
||||
void do_query(DbQuery &query) {
|
||||
switch (query.type) {
|
||||
case DbQuery::Get:
|
||||
case DbQuery::Type::Get:
|
||||
query.value = impl_.get(query.key);
|
||||
return;
|
||||
case DbQuery::Set:
|
||||
case DbQuery::Type::Set:
|
||||
query.tid = impl_.set(query.key, query.value);
|
||||
return;
|
||||
case DbQuery::Erase:
|
||||
case DbQuery::Type::Erase:
|
||||
query.tid = impl_.erase(query.key);
|
||||
return;
|
||||
}
|
||||
@ -274,13 +274,13 @@ TEST(DB, key_value) {
|
||||
const auto &key = rand_elem(keys);
|
||||
const auto &value = rand_elem(values);
|
||||
if (op == 0) {
|
||||
q.type = DbQuery::Get;
|
||||
q.type = DbQuery::Type::Get;
|
||||
q.key = key;
|
||||
} else if (op == 1) {
|
||||
q.type = DbQuery::Erase;
|
||||
q.type = DbQuery::Type::Erase;
|
||||
q.key = key;
|
||||
} else if (op == 2) {
|
||||
q.type = DbQuery::Set;
|
||||
q.type = DbQuery::Type::Set;
|
||||
q.key = key;
|
||||
q.value = value;
|
||||
}
|
||||
@ -344,13 +344,13 @@ TEST(DB, thread_key_value) {
|
||||
const auto &key = rand_elem(keys);
|
||||
const auto &value = rand_elem(values);
|
||||
if (op > 1) {
|
||||
q.type = DbQuery::Get;
|
||||
q.type = DbQuery::Type::Get;
|
||||
q.key = key;
|
||||
} else if (op == 0) {
|
||||
q.type = DbQuery::Erase;
|
||||
q.type = DbQuery::Type::Erase;
|
||||
q.key = key;
|
||||
} else if (op == 1) {
|
||||
q.type = DbQuery::Set;
|
||||
q.type = DbQuery::Type::Set;
|
||||
q.key = key;
|
||||
q.value = value;
|
||||
}
|
||||
@ -384,7 +384,7 @@ TEST(DB, thread_key_value) {
|
||||
}
|
||||
auto &q = res[i][p];
|
||||
if (q.tid == 0) {
|
||||
if (q.type == DbQuery::Get) {
|
||||
if (q.type == DbQuery::Type::Get) {
|
||||
auto nq = q;
|
||||
baseline.do_query(nq);
|
||||
if (nq.value == q.value) {
|
||||
@ -458,13 +458,13 @@ TEST(DB, persistent_key_value) {
|
||||
const auto &key = rand_elem(keys);
|
||||
const auto &value = rand_elem(values);
|
||||
if (op > 1) {
|
||||
q.type = DbQuery::Get;
|
||||
q.type = DbQuery::Type::Get;
|
||||
q.key = key;
|
||||
} else if (op == 0) {
|
||||
q.type = DbQuery::Erase;
|
||||
q.type = DbQuery::Type::Erase;
|
||||
q.key = key;
|
||||
} else if (op == 1) {
|
||||
q.type = DbQuery::Set;
|
||||
q.type = DbQuery::Type::Set;
|
||||
q.key = key;
|
||||
q.value = value;
|
||||
}
|
||||
@ -495,13 +495,12 @@ TEST(DB, persistent_key_value) {
|
||||
class Main : public Actor {
|
||||
public:
|
||||
Main(int threads_n, const std::vector<std::vector<DbQuery>> *queries, std::vector<std::vector<DbQuery>> *res)
|
||||
: threads_n_(threads_n), queries_(queries), res_(res) {
|
||||
: threads_n_(threads_n), queries_(queries), res_(res), ref_cnt_(threads_n) {
|
||||
}
|
||||
|
||||
void start_up() override {
|
||||
LOG(INFO) << "start_up";
|
||||
kv_->impl().init("test_pmc").ensure();
|
||||
ref_cnt_ = threads_n_;
|
||||
for (int i = 0; i < threads_n_; i++) {
|
||||
create_actor_on_scheduler<Worker>("Worker", i + 1, actor_shared(this, 2), kv_, &queries_->at(i), &res_->at(i))
|
||||
.release();
|
||||
@ -553,7 +552,7 @@ TEST(DB, persistent_key_value) {
|
||||
}
|
||||
auto &q = res[i][p];
|
||||
if (q.tid == 0) {
|
||||
if (q.type == DbQuery::Get) {
|
||||
if (q.type == DbQuery::Type::Get) {
|
||||
auto nq = q;
|
||||
baseline.do_query(nq);
|
||||
if (nq.value == q.value) {
|
||||
|
@ -342,7 +342,7 @@ TEST(Mtproto, socks5) {
|
||||
int threads_n = 0;
|
||||
sched.init(threads_n);
|
||||
|
||||
sched.create_actor_unsafe<Socks5TestActor>(0, "Socks5TestActor").release();
|
||||
auto actor_id = sched.create_actor_unsafe<Socks5TestActor>(0, "Socks5TestActor").release();
|
||||
sched.start();
|
||||
while (sched.run_main(10)) {
|
||||
// empty;
|
||||
|
@ -50,11 +50,10 @@ namespace my_api {
|
||||
|
||||
using namespace td;
|
||||
|
||||
//messages_getDhConfig
|
||||
class messages_getDhConfig {
|
||||
public:
|
||||
int32 version_;
|
||||
int32 random_length_;
|
||||
int32 version_{};
|
||||
int32 random_length_{};
|
||||
|
||||
messages_getDhConfig() = default;
|
||||
|
||||
@ -71,7 +70,6 @@ class messages_getDhConfig {
|
||||
}
|
||||
};
|
||||
|
||||
//InputUser
|
||||
class InputUser {
|
||||
public:
|
||||
static tl_object_ptr<InputUser> fetch(TlBufferParser &p);
|
||||
@ -79,8 +77,8 @@ class InputUser {
|
||||
|
||||
class inputUser final : public InputUser {
|
||||
public:
|
||||
int32 user_id_;
|
||||
int64 access_hash_;
|
||||
int32 user_id_{};
|
||||
int64 access_hash_{};
|
||||
|
||||
static const int32 ID = -668391402;
|
||||
inputUser() = default;
|
||||
@ -93,6 +91,7 @@ class inputUser final : public InputUser {
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
tl_object_ptr<InputUser> InputUser::fetch(TlBufferParser &p) {
|
||||
#define FAIL(error) \
|
||||
p.set_error(error); \
|
||||
@ -110,36 +109,28 @@ tl_object_ptr<InputUser> InputUser::fetch(TlBufferParser &p) {
|
||||
class messages_requestEncryption final {
|
||||
public:
|
||||
tl_object_ptr<InputUser> user_id_;
|
||||
int32 random_id_;
|
||||
int32 random_id_{};
|
||||
BufferSlice g_a_;
|
||||
|
||||
static const int32 ID = -162681021;
|
||||
messages_requestEncryption();
|
||||
|
||||
explicit messages_requestEncryption(TlBufferParser &p)
|
||||
#define FAIL(error) p.set_error(error)
|
||||
: user_id_(TlFetchObject<InputUser>::parse(p))
|
||||
, random_id_(TlFetchInt::parse(p))
|
||||
, g_a_(TlFetchBytes<BufferSlice>::parse(p))
|
||||
#undef FAIL
|
||||
{
|
||||
, g_a_(TlFetchBytes<BufferSlice>::parse(p)) {
|
||||
}
|
||||
};
|
||||
|
||||
class inputEncryptedChat final {
|
||||
public:
|
||||
int32 chat_id_;
|
||||
int64 access_hash_;
|
||||
int32 chat_id_{};
|
||||
int64 access_hash_{};
|
||||
|
||||
inputEncryptedChat() = default;
|
||||
|
||||
static const int32 ID = -247351839;
|
||||
explicit inputEncryptedChat(TlBufferParser &p)
|
||||
#define FAIL(error) p.set_error(error)
|
||||
: chat_id_(TlFetchInt::parse(p))
|
||||
, access_hash_(TlFetchLong::parse(p))
|
||||
#undef FAIL
|
||||
{
|
||||
explicit inputEncryptedChat(TlBufferParser &p) : chat_id_(TlFetchInt::parse(p)), access_hash_(TlFetchLong::parse(p)) {
|
||||
}
|
||||
static tl_object_ptr<inputEncryptedChat> fetch(TlBufferParser &p) {
|
||||
return make_tl_object<inputEncryptedChat>(p);
|
||||
@ -150,56 +141,47 @@ class messages_acceptEncryption final {
|
||||
public:
|
||||
tl_object_ptr<inputEncryptedChat> peer_;
|
||||
BufferSlice g_b_;
|
||||
int64 key_fingerprint_;
|
||||
int64 key_fingerprint_{};
|
||||
|
||||
messages_acceptEncryption() = default;
|
||||
|
||||
static const int32 ID = 1035731989;
|
||||
|
||||
explicit messages_acceptEncryption(TlBufferParser &p)
|
||||
#define FAIL(error) p.set_error(error)
|
||||
: peer_(TlFetchBoxed<TlFetchObject<inputEncryptedChat>, -247351839>::parse(p))
|
||||
, g_b_(TlFetchBytes<BufferSlice>::parse(p))
|
||||
, key_fingerprint_(TlFetchLong::parse(p))
|
||||
#undef FAIL
|
||||
{
|
||||
, key_fingerprint_(TlFetchLong::parse(p)) {
|
||||
}
|
||||
};
|
||||
|
||||
class messages_sendEncryptedService final {
|
||||
public:
|
||||
tl_object_ptr<inputEncryptedChat> peer_;
|
||||
int64 random_id_;
|
||||
int64 random_id_{};
|
||||
BufferSlice data_;
|
||||
|
||||
messages_sendEncryptedService() = default;
|
||||
static const int32 ID = 852769188;
|
||||
explicit messages_sendEncryptedService(TlBufferParser &p)
|
||||
#define FAIL(error) p.set_error(error)
|
||||
: peer_(TlFetchBoxed<TlFetchObject<inputEncryptedChat>, -247351839>::parse(p))
|
||||
, random_id_(TlFetchLong::parse(p))
|
||||
, data_(TlFetchBytes<BufferSlice>::parse(p))
|
||||
#undef FAIL
|
||||
{
|
||||
, data_(TlFetchBytes<BufferSlice>::parse(p)) {
|
||||
}
|
||||
};
|
||||
|
||||
class messages_sendEncrypted final {
|
||||
public:
|
||||
tl_object_ptr<inputEncryptedChat> peer_;
|
||||
int64 random_id_;
|
||||
int64 random_id_{};
|
||||
BufferSlice data_;
|
||||
|
||||
messages_sendEncrypted() = default;
|
||||
static const int32 ID = -1451792525;
|
||||
|
||||
explicit messages_sendEncrypted(TlBufferParser &p)
|
||||
#define FAIL(error) p.set_error(error)
|
||||
: peer_(TlFetchBoxed<TlFetchObject<inputEncryptedChat>, -247351839>::parse(p))
|
||||
, random_id_(TlFetchLong::parse(p))
|
||||
, data_(TlFetchBytes<BufferSlice>::parse(p))
|
||||
#undef FAIL
|
||||
{
|
||||
, data_(TlFetchBytes<BufferSlice>::parse(p)) {
|
||||
}
|
||||
};
|
||||
|
||||
@ -225,9 +207,9 @@ static void downcast_call(TlBufferParser &p, F &&f) {
|
||||
|
||||
class messages_dhConfig final {
|
||||
public:
|
||||
int32 g_;
|
||||
int32 g_{};
|
||||
BufferSlice p_;
|
||||
int32 version_;
|
||||
int32 version_{};
|
||||
BufferSlice random_;
|
||||
|
||||
messages_dhConfig() = default;
|
||||
@ -259,13 +241,13 @@ class messages_dhConfig final {
|
||||
|
||||
class encryptedChat final {
|
||||
public:
|
||||
int32 id_;
|
||||
int64 access_hash_;
|
||||
int32 date_;
|
||||
int32 admin_id_;
|
||||
int32 participant_id_;
|
||||
int32 id_{};
|
||||
int64 access_hash_{};
|
||||
int32 date_{};
|
||||
int32 admin_id_{};
|
||||
int32 participant_id_{};
|
||||
BufferSlice g_a_or_b_;
|
||||
int64 key_fingerprint_;
|
||||
int64 key_fingerprint_{};
|
||||
|
||||
encryptedChat() = default;
|
||||
|
||||
@ -310,7 +292,7 @@ class encryptedChat final {
|
||||
|
||||
class messages_sentEncryptedMessage final {
|
||||
public:
|
||||
int32 date_;
|
||||
int32 date_{};
|
||||
|
||||
messages_sentEncryptedMessage() = default;
|
||||
|
||||
|
@ -64,7 +64,7 @@ TEST(SecureStorage, simple) {
|
||||
td::unlink(encrypted_path).ignore();
|
||||
td::unlink(decrypted_path).ignore();
|
||||
std::string file_value(100000, 'a');
|
||||
td::write_file(value_path, file_value);
|
||||
td::write_file(value_path, file_value).ensure();
|
||||
auto hash = encrypt_file(value_secret, value_path, encrypted_path).move_as_ok();
|
||||
decrypt_file(value_secret, hash, encrypted_path, decrypted_path).ensure();
|
||||
ASSERT_TRUE(td::read_file(decrypted_path).move_as_ok().as_slice() == file_value);
|
||||
|
@ -182,7 +182,7 @@ class Task : public TestClient::Listener {
|
||||
|
||||
protected:
|
||||
std::map<uint64, std::function<void(tl_object_ptr<td_api::Object>)>> sent_queries_;
|
||||
TestClient *client_;
|
||||
TestClient *client_ = nullptr;
|
||||
uint64 current_query_id_ = 1;
|
||||
|
||||
virtual void start_up() {
|
||||
@ -272,7 +272,7 @@ class SetUsername : public Task {
|
||||
private:
|
||||
string username_;
|
||||
Promise<> promise_;
|
||||
int32 self_id_;
|
||||
int32 self_id_ = 0;
|
||||
string tag_;
|
||||
|
||||
void start_up() override {
|
||||
@ -588,7 +588,7 @@ class CheckTestC : public Task {
|
||||
string username_;
|
||||
string tag_;
|
||||
Promise<> promise_;
|
||||
int64 chat_id_;
|
||||
int64 chat_id_ = 0;
|
||||
|
||||
void one_file() {
|
||||
this->send_query(
|
||||
@ -701,9 +701,10 @@ class LoginTestActor : public Actor {
|
||||
double timeout_;
|
||||
Promise<> promise_;
|
||||
};
|
||||
create_actor<WaitActor>("WaitActor", 2,
|
||||
PromiseCreator::event(self_closure(this, &LoginTestActor::start_up_fence_dec)))
|
||||
.release();
|
||||
auto actor_id =
|
||||
create_actor<WaitActor>("WaitActor", 2,
|
||||
PromiseCreator::event(self_closure(this, &LoginTestActor::start_up_fence_dec)))
|
||||
.release();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user