diff options
| author | levlam <levlam@telegram.org> | 2024-09-10 18:10:08 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2024-09-10 18:10:08 +0300 |
| commit | ac8c0ee4e7f4016cb9c91decdcaa085277d276fb (patch) | |
| tree | 3809d1019da5cfc699d8153d0471a9725a6d48e6 | |
| parent | dcfd86c70c565c9c1d2f576a9ff0a769f2ef5e49 (diff) | |
Improve variable names.
| -rw-r--r-- | td/mtproto/TlsInit.cpp | 10 | ||||
| -rw-r--r-- | td/telegram/SecureStorage.cpp | 10 | ||||
| -rw-r--r-- | td/telegram/logevent/SecretChatEvent.h | 6 | ||||
| -rw-r--r-- | tdutils/td/utils/filesystem.cpp | 4 | ||||
| -rw-r--r-- | tdutils/test/StealingQueue.cpp | 10 | ||||
| -rw-r--r-- | tdutils/test/pq.cpp | 4 | ||||
| -rw-r--r-- | test/message_entities.cpp | 18 | ||||
| -rw-r--r-- | test/mtproto.cpp | 20 |
8 files changed, 41 insertions, 41 deletions
diff --git a/td/mtproto/TlsInit.cpp b/td/mtproto/TlsInit.cpp index be33b4f43..775effb36 100644 --- a/td/mtproto/TlsInit.cpp +++ b/td/mtproto/TlsInit.cpp @@ -508,14 +508,14 @@ void TlsInit::send_hello() { Status TlsInit::wait_hello_response() { auto it = fd_.input_buffer().clone(); - for (auto first : {Slice("\x16\x03\x03"), Slice("\x14\x03\x03\x00\x01\x01\x17\x03\x03")}) { - if (it.size() < first.size() + 2) { + for (auto prefix : {Slice("\x16\x03\x03"), Slice("\x14\x03\x03\x00\x01\x01\x17\x03\x03")}) { + if (it.size() < prefix.size() + 2) { return Status::OK(); } - string got_first(first.size(), '\0'); - it.advance(first.size(), got_first); - if (first != got_first) { + string response_prefix(prefix.size(), '\0'); + it.advance(prefix.size(), response_prefix); + if (prefix != response_prefix) { return Status::Error("First part of response to hello is invalid"); } diff --git a/td/telegram/SecureStorage.cpp b/td/telegram/SecureStorage.cpp index 362e87354..44b48b2f6 100644 --- a/td/telegram/SecureStorage.cpp +++ b/td/telegram/SecureStorage.cpp @@ -354,9 +354,9 @@ Result<BufferSlice> decrypt_value(const Secret &secret, const ValueHash &hash, S auto aes_cbc_state = calc_aes_cbc_state_sha512(PSLICE() << secret.as_slice() << hash.as_slice()); Decryptor decryptor(std::move(aes_cbc_state)); TRY_RESULT(decrypted_value, decryptor.append(BufferSlice(data))); - TRY_RESULT(got_hash, decryptor.finish()); - if (got_hash.as_slice() != hash.as_slice()) { - return Status::Error(PSLICE() << "Hash mismatch " << format::as_hex_dump<4>(got_hash.as_slice()) << " " + TRY_RESULT(stored_hash, decryptor.finish()); + if (stored_hash.as_slice() != hash.as_slice()) { + return Status::Error(PSLICE() << "Hash mismatch " << format::as_hex_dump<4>(stored_hash.as_slice()) << " " << format::as_hex_dump<4>(hash.as_slice())); } return std::move(decrypted_value); @@ -395,9 +395,9 @@ Status decrypt_file(const Secret &secret, const ValueHash &hash, const string &s return Status::OK(); })); - TRY_RESULT(got_hash, decryptor.finish()); + TRY_RESULT(stored_hash, decryptor.finish()); - if (hash.as_slice() != got_hash.as_slice()) { + if (hash.as_slice() != stored_hash.as_slice()) { return Status::Error("Hash mismatch"); } diff --git a/td/telegram/logevent/SecretChatEvent.h b/td/telegram/logevent/SecretChatEvent.h index a5a20a11f..b9b6f44fa 100644 --- a/td/telegram/logevent/SecretChatEvent.h +++ b/td/telegram/logevent/SecretChatEvent.h @@ -159,16 +159,16 @@ struct EncryptedInputFile { template <class ParserT> void parse(ParserT &parser) { using td::parse; - int32 got_magic; + int32 stored_magic; - parse(got_magic, parser); + parse(stored_magic, parser); parse(type, parser); parse(id, parser); parse(access_hash, parser); parse(parts, parser); parse(key_fingerprint, parser); - if (got_magic != MAGIC) { + if (stored_magic != MAGIC) { parser.set_error("EncryptedInputFile magic mismatch"); return; } diff --git a/tdutils/td/utils/filesystem.cpp b/tdutils/td/utils/filesystem.cpp index 8a9501fb7..80d9353a2 100644 --- a/tdutils/td/utils/filesystem.cpp +++ b/tdutils/td/utils/filesystem.cpp @@ -50,8 +50,8 @@ Result<T> read_file_impl(CSlice path, int64 size, int64 offset) { size = file_size - offset; } auto content = create_empty<T>(narrow_cast<size_t>(size)); - TRY_RESULT(got_size, from_file.pread(as_mutable_slice(content), offset)); - if (got_size != static_cast<size_t>(size)) { + TRY_RESULT(read_size, from_file.pread(as_mutable_slice(content), offset)); + if (read_size != static_cast<size_t>(size)) { return Status::Error("Failed to read file"); } from_file.close(); diff --git a/tdutils/test/StealingQueue.cpp b/tdutils/test/StealingQueue.cpp index 0e48c1d33..0a2f0d083 100644 --- a/tdutils/test/StealingQueue.cpp +++ b/tdutils/test/StealingQueue.cpp @@ -108,7 +108,7 @@ TEST(AtomicRead, simple2) { TEST(StealingQueue, simple) { td::uint64 sum = 0; - std::atomic<td::uint64> got_sum{0}; + std::atomic<td::uint64> check_sum{0}; td::Stage run; td::Stage check; @@ -138,10 +138,10 @@ TEST(StealingQueue, simple) { sum += x_sum[x]; gq.push(x, id); } - got_sum = 0; + check_sum = 0; } run.wait(round * threads_n); - while (got_sum.load() != sum) { + while (check_sum.load() != sum) { auto x = [&] { int res; if (lq[id].local_pop(res)) { @@ -159,8 +159,8 @@ TEST(StealingQueue, simple) { if (x == 0) { continue; } - //LOG(ERROR) << x << " " << got_sum.load() << " " << sum; - got_sum.fetch_add(x, std::memory_order_relaxed); + //LOG(ERROR) << x << " " << check_sum.load() << " " << sum; + check_sum.fetch_add(x, std::memory_order_relaxed); lq[id].local_push(x - 1, [&](auto y) { //LOG(ERROR) << "OVERFLOW"; gq.push(y, id); diff --git a/tdutils/test/pq.cpp b/tdutils/test/pq.cpp index fbe53eefb..b499b31e0 100644 --- a/tdutils/test/pq.cpp +++ b/tdutils/test/pq.cpp @@ -112,8 +112,8 @@ static void test_pq_slow(td::uint64 first, td::uint64 second) { td::BigNum p_res = td::BigNum::from_binary(p_str); td::BigNum q_res = td::BigNum::from_binary(q_str); - LOG_CHECK(p_str == p.to_binary()) << td::tag("got", p_res.to_decimal()) << td::tag("expected", first); - LOG_CHECK(q_str == q.to_binary()) << td::tag("got", q_res.to_decimal()) << td::tag("expected", second); + LOG_CHECK(p_str == p.to_binary()) << td::tag("receive", p_res.to_decimal()) << td::tag("expected", first); + LOG_CHECK(q_str == q.to_binary()) << td::tag("receive", q_res.to_decimal()) << td::tag("expected", second); } #endif diff --git a/test/message_entities.cpp b/test/message_entities.cpp index 35150fa06..64cd7dcca 100644 --- a/test/message_entities.cpp +++ b/test/message_entities.cpp @@ -29,7 +29,7 @@ static void check_mention(const td::string &str, const td::vector<td::string> &e result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -60,7 +60,7 @@ static void check_bot_command(const td::string &str, const td::vector<td::string result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -84,7 +84,7 @@ static void check_hashtag(const td::string &str, const td::vector<td::string> &e result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -128,7 +128,7 @@ static void check_cashtag(const td::string &str, const td::vector<td::string> &e result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -190,7 +190,7 @@ static void check_media_timestamp(const td::string &str, const td::vector<std::p auto result = td::transform(td::find_media_timestamps(str), [](auto &&entity) { return std::make_pair(entity.first.str(), entity.second); }); if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -235,7 +235,7 @@ static void check_bank_card_number(const td::string &str, const td::vector<td::s result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -284,7 +284,7 @@ static void check_tg_url(const td::string &str, const td::vector<td::string> &ex result.push_back(it.str()); } if (result != expected) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result)) << td::tag("expected", td::format::as_array(expected)); } } @@ -464,11 +464,11 @@ static void check_url(const td::string &str, const td::vector<td::string> &expec } } if (result_urls != expected_urls) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result_urls)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result_urls)) << td::tag("expected", td::format::as_array(expected_urls)); } if (result_email_addresses != expected_email_addresses) { - LOG(FATAL) << td::tag("text", str) << td::tag("got", td::format::as_array(result_email_addresses)) + LOG(FATAL) << td::tag("text", str) << td::tag("receive", td::format::as_array(result_email_addresses)) << td::tag("expected", td::format::as_array(expected_email_addresses)); } } diff --git a/test/mtproto.cpp b/test/mtproto.cpp index c7bf876e5..72d1af5d7 100644 --- a/test/mtproto.cpp +++ b/test/mtproto.cpp @@ -367,11 +367,11 @@ class HandshakeTestActor final : public td::Actor { 10.0, td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> raw_connection) { - td::send_closure(actor_id, &HandshakeTestActor::got_connection, std::move(raw_connection), 1); + td::send_closure(actor_id, &HandshakeTestActor::on_connection, std::move(raw_connection), 1); }), td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> handshake) { - td::send_closure(actor_id, &HandshakeTestActor::got_handshake, std::move(handshake), 1); + td::send_closure(actor_id, &HandshakeTestActor::on_handshake, std::move(handshake), 1); })) .release(); wait_for_raw_connection_ = true; @@ -379,7 +379,7 @@ class HandshakeTestActor final : public td::Actor { } } - void got_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) { + void on_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) { CHECK(wait_for_raw_connection_); wait_for_raw_connection_ = false; if (r_raw_connection.is_ok()) { @@ -392,7 +392,7 @@ class HandshakeTestActor final : public td::Actor { loop(); } - void got_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) { + void on_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) { CHECK(wait_for_handshake_); wait_for_handshake_ = false; CHECK(r_handshake.is_ok()); @@ -555,16 +555,16 @@ class FastPingTestActor final : public td::Actor { "HandshakeActor", std::move(handshake), std::move(raw_connection), td::make_unique<HandshakeContext>(), 10.0, td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> raw_connection) { - td::send_closure(actor_id, &FastPingTestActor::got_connection, std::move(raw_connection), 1); + td::send_closure(actor_id, &FastPingTestActor::on_connection, std::move(raw_connection), 1); }), td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> handshake) { - td::send_closure(actor_id, &FastPingTestActor::got_handshake, std::move(handshake), 1); + td::send_closure(actor_id, &FastPingTestActor::on_handshake, std::move(handshake), 1); })) .release(); } - void got_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) { + void on_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection, bool dummy) { if (r_raw_connection.is_error()) { *result_ = r_raw_connection.move_as_error(); LOG(INFO) << "Receive " << *result_ << " instead of a connection"; @@ -574,7 +574,7 @@ class FastPingTestActor final : public td::Actor { loop(); } - void got_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) { + void on_handshake(td::Result<td::unique_ptr<td::mtproto::AuthKeyHandshake>> r_handshake, bool dummy) { if (r_handshake.is_error()) { *result_ = r_handshake.move_as_error(); LOG(INFO) << "Receive " << *result_ << " instead of a handshake"; @@ -584,7 +584,7 @@ class FastPingTestActor final : public td::Actor { loop(); } - void got_raw_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_connection) { + void on_raw_connection(td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_connection) { if (r_connection.is_error()) { *result_ = r_connection.move_as_error(); LOG(INFO) << "Receive " << *result_ << " instead of a handshake"; @@ -621,7 +621,7 @@ class FastPingTestActor final : public td::Actor { td::Slice(), std::move(connection_), std::move(auth_data), td::PromiseCreator::lambda( [actor_id = actor_id(this)](td::Result<td::unique_ptr<td::mtproto::RawConnection>> r_raw_connection) { - td::send_closure(actor_id, &FastPingTestActor::got_raw_connection, std::move(r_raw_connection)); + td::send_closure(actor_id, &FastPingTestActor::on_raw_connection, std::move(r_raw_connection)); }), td::ActorShared<>()); } |
