From f35afe23c84d887e53510d91a860d7382072ae0a Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 18 Oct 2021 12:57:13 +0300 Subject: [PATCH] Minor warning fixes. --- td/generate/tl_writer_td.cpp | 5 ++--- td/mtproto/AuthData.cpp | 8 ++++---- td/telegram/ContactsManager.cpp | 5 +++-- td/telegram/SecureValue.cpp | 1 - td/telegram/cli.cpp | 13 ++++++++----- td/telegram/files/FileManager.hpp | 13 ++++--------- tdactor/td/actor/PromiseFuture.h | 4 ++-- tdnet/td/net/SslStream.cpp | 1 - tdutils/td/utils/EpochBasedMemoryReclamation.h | 2 +- tdutils/td/utils/SharedObjectPool.h | 3 +++ tdutils/td/utils/port/uname.cpp | 2 +- 11 files changed, 28 insertions(+), 29 deletions(-) diff --git a/td/generate/tl_writer_td.cpp b/td/generate/tl_writer_td.cpp index 0664678bb..08ba92185 100644 --- a/td/generate/tl_writer_td.cpp +++ b/td/generate/tl_writer_td.cpp @@ -261,9 +261,8 @@ std::string TD_TL_writer::gen_constructor_parameter(int field_num, const std::st } else if (field_type == "UInt128 " || field_type == "UInt256 " || field_type == "string " || (string_type == bytes_type && field_type == "bytes ")) { res += field_type + "const &"; - } else if (field_type.compare(0, 5, "array") == 0 || field_type == "bytes ") { - res += field_type + "&&"; - } else if (field_type.compare(0, 10, "object_ptr") == 0) { + } else if (field_type.compare(0, 5, "array") == 0 || field_type == "bytes " || + field_type.compare(0, 10, "object_ptr") == 0) { res += field_type + "&&"; } else { assert(false && "unreachable"); diff --git a/td/mtproto/AuthData.cpp b/td/mtproto/AuthData.cpp index 2dfff4bcd..aede7d3b6 100644 --- a/td/mtproto/AuthData.cpp +++ b/td/mtproto/AuthData.cpp @@ -78,7 +78,7 @@ bool AuthData::update_server_time_difference(double diff) { } else { return false; } - LOG(DEBUG) << "SERVER_TIME: " << format::as_hex(static_cast(get_server_time(Time::now_cached()))); + LOG(DEBUG) << "SERVER_TIME: " << format::as_hex(static_cast(get_server_time(Time::now_cached()))); return true; } @@ -119,13 +119,13 @@ int64 AuthData::next_message_id(double now) { bool AuthData::is_valid_outbound_msg_id(int64 id, double now) const { double server_time = get_server_time(now); - auto id_time = static_cast(id / (1ll << 32)); - return server_time - 300 / 2 < id_time && id_time < server_time + 60 / 2; + auto id_time = static_cast(id) / static_cast(1ll << 32); + return server_time - 300 / 2 < id_time && id_time < server_time + 30; } bool AuthData::is_valid_inbound_msg_id(int64 id, double now) const { double server_time = get_server_time(now); - auto id_time = static_cast(id / (1ll << 32)); + auto id_time = static_cast(id) / static_cast(1ll << 32); return server_time - 300 < id_time && id_time < server_time + 30; } diff --git a/td/telegram/ContactsManager.cpp b/td/telegram/ContactsManager.cpp index e77789fa0..914c2b195 100644 --- a/td/telegram/ContactsManager.cpp +++ b/td/telegram/ContactsManager.cpp @@ -11121,8 +11121,9 @@ void ContactsManager::on_update_user_full_common_chat_count(UserFull *user_full, void ContactsManager::on_update_user_full_commands(UserFull *user_full, UserId user_id, vector> &&bot_commands) { CHECK(user_full != nullptr); - auto commands = - transform(std::move(bot_commands), [](auto &&bot_command) { return BotCommand(std::move(bot_command)); }); + auto commands = transform(std::move(bot_commands), [](tl_object_ptr &&bot_command) { + return BotCommand(std::move(bot_command)); + }); if (user_full->commands != commands) { user_full->commands = std::move(commands); user_full->is_changed = true; diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index 55c8a97ab..df0ea3a12 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -517,7 +517,6 @@ static bool check_encrypted_secure_value(const EncryptedSecureValue &value) { case SecureValueType::TemporaryRegistration: return !has_encrypted_data && !has_plain_data && has_files && !has_front_side && !has_reverse_side && !has_selfie; case SecureValueType::PhoneNumber: - return has_plain_data && !has_files && !has_front_side && !has_reverse_side && !has_selfie && !has_translations; case SecureValueType::EmailAddress: return has_plain_data && !has_files && !has_front_side && !has_reverse_side && !has_selfie && !has_translations; case SecureValueType::None: diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 4d5208d27..cbed1c4eb 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1781,11 +1781,14 @@ class CliClient final : public Actor { } else if (op == "rreac") { send_request(td_api::make_object()); } else if (op == "spncc") { - send_request(td_api::make_object(args, nullptr)); + string hash; + string phone_number; + get_args(args, hash, phone_number); + send_request(td_api::make_object(hash, phone_number, nullptr)); } else if (op == "cpncc") { - send_request(td_api::make_object(args)); + send_request(td_api::make_object(args)); } else if (op == "rpncc") { - send_request(td_api::make_object()); + send_request(td_api::make_object()); } else if (op == "rpr") { send_request(td_api::make_object()); } else if (op == "cprc") { @@ -3020,7 +3023,7 @@ class CliClient final : public Actor { execute(td_api::make_object("\"\\u0080\"")); execute(td_api::make_object("\"\\uD800\"")); } else if (op == "gjs") { - auto test_get_json_string = [&](auto &&json_value) { + auto test_get_json_string = [&](td_api::object_ptr &&json_value) { execute(td_api::make_object(std::move(json_value))); }; @@ -4477,7 +4480,7 @@ class CliClient final : public Actor { if (slice.empty()) { return EOF; } - int res = slice[0]; + int res = static_cast(slice[0]); stdin_.input_buffer().confirm_read(1); return res; } diff --git a/td/telegram/files/FileManager.hpp b/td/telegram/files/FileManager.hpp index 23c41ed42..6971c1733 100644 --- a/td/telegram/files/FileManager.hpp +++ b/td/telegram/files/FileManager.hpp @@ -107,9 +107,7 @@ void FileManager::store_file(FileId file_id, StorerT &storer, int32 ttl) const { default: UNREACHABLE(); } - if (has_encryption_key) { - store(file_view.encryption_key(), storer); - } else if (has_secure_key) { + if (has_encryption_key || has_secure_key) { store(file_view.encryption_key(), storer); } } @@ -225,13 +223,10 @@ FileId FileManager::parse_file(ParserT &parser) { return FileId(); }(); - if (has_encryption_key) { + if (has_encryption_key || has_secure_key) { + auto key_type = has_encryption_key ? FileEncryptionKey::Type::Secret : FileEncryptionKey::Type::Secure; FileEncryptionKey encryption_key; - encryption_key.parse(FileEncryptionKey::Type::Secret, parser); - set_encryption_key(file_id, std::move(encryption_key)); - } else if (has_secure_key) { - FileEncryptionKey encryption_key; - encryption_key.parse(FileEncryptionKey::Type::Secure, parser); + encryption_key.parse(key_type, parser); set_encryption_key(file_id, std::move(encryption_key)); } diff --git a/tdactor/td/actor/PromiseFuture.h b/tdactor/td/actor/PromiseFuture.h index dde678aaf..938267eb3 100644 --- a/tdactor/td/actor/PromiseFuture.h +++ b/tdactor/td/actor/PromiseFuture.h @@ -136,7 +136,7 @@ class LambdaPromise : public PromiseInterface { , has_lambda_(true) { } template - LambdaPromise(FromOkT &&ok) : LambdaPromise(std::move(ok), Ignore(), true) { + LambdaPromise(FromOkT &&ok) : LambdaPromise(std::forward(ok), Ignore(), true) { } private: @@ -461,7 +461,7 @@ class SendClosure { template auto promise_send_closure(ArgsT &&... args) { return [t = std::make_tuple(std::forward(args)...)](auto &&res) mutable { - call_tuple(SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::move(res)))); + call_tuple(SendClosure(), std::tuple_cat(std::move(t), std::make_tuple(std::forward(res)))); }; } diff --git a/tdnet/td/net/SslStream.cpp b/tdnet/td/net/SslStream.cpp index 84d9e5573..aeac98cd3 100644 --- a/tdnet/td/net/SslStream.cpp +++ b/tdnet/td/net/SslStream.cpp @@ -96,7 +96,6 @@ long strm_ctrl(BIO *b, int cmd, long num, void *ptr) { case BIO_CTRL_FLUSH: return 1; case BIO_CTRL_PUSH: - return 0; case BIO_CTRL_POP: return 0; default: diff --git a/tdutils/td/utils/EpochBasedMemoryReclamation.h b/tdutils/td/utils/EpochBasedMemoryReclamation.h index 4ca02fe20..7639d80db 100644 --- a/tdutils/td/utils/EpochBasedMemoryReclamation.h +++ b/tdutils/td/utils/EpochBasedMemoryReclamation.h @@ -37,7 +37,7 @@ class EpochBasedMemoryReclamation { if (ebmr_) { retire_sync(); unlock(); - ebmr_.release(); + (void)ebmr_.release(); } } void lock() { diff --git a/tdutils/td/utils/SharedObjectPool.h b/tdutils/td/utils/SharedObjectPool.h index cb8c417a0..b121fccd4 100644 --- a/tdutils/td/utils/SharedObjectPool.h +++ b/tdutils/td/utils/SharedObjectPool.h @@ -106,6 +106,9 @@ class SharedPtr { SharedPtr(const SharedPtr &other) : SharedPtr(other.raw_) { } SharedPtr &operator=(const SharedPtr &other) { + if (this == &other) { + return *this; + } if (other.raw_) { other.raw_->inc(); } diff --git a/tdutils/td/utils/port/uname.cpp b/tdutils/td/utils/port/uname.cpp index 327632821..6aa8a01d0 100644 --- a/tdutils/td/utils/port/uname.cpp +++ b/tdutils/td/utils/port/uname.cpp @@ -254,7 +254,7 @@ Slice get_operating_system_version() { } return "Windows Server 2016"; } - if (os_version_info.dwBuildNumber >= 21900) { // build numbers between 21391 and 21999 aren't used + if (os_version_info.dwBuildNumber >= 21900) { // build numbers between 21391 and 21999 aren't used return "Windows 11"; } return "Windows 10";