From 50ab1fd175018fb73f5435650bbb31f6072666ce Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 9 Apr 2018 21:28:50 +0300 Subject: [PATCH] Fix g++ CEs, warnings and Internal Compiler Errors. GitOrigin-RevId: 0d7213b04cbbe67157f93fcdcf76f11373b47470 --- td/telegram/AuthManager.cpp | 82 ++++++++++++++------------------- td/telegram/MessagesManager.cpp | 1 + td/telegram/SecureValue.cpp | 30 ++++++------ 3 files changed, 51 insertions(+), 62 deletions(-) diff --git a/td/telegram/AuthManager.cpp b/td/telegram/AuthManager.cpp index 23cb6d07..cf5167fe 100644 --- a/td/telegram/AuthManager.cpp +++ b/td/telegram/AuthManager.cpp @@ -197,19 +197,6 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, if (phone_number.empty()) { return on_query_error(query_id, Status::Error(8, "Phone number can't be empty")); } - auto with_send_code = [&](auto c) { - switch (this->type_) { - case Type::ChangePhone: - return c(send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number)); - case Type::VerifyPhone: - return c(send_code_helper_.send_verify_phone_code(phone_number, allow_flash_call, is_current_phone_number)); - case Type::ConfirmPhone: - return c(send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number)); - default: - UNREACHABLE(); - return c(send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number)); - } - }; auto process_send_code = [&](auto r_send_code) { if (r_send_code.is_error()) { @@ -221,7 +208,19 @@ void PhoneNumberManager::set_phone_number(uint64 query_id, string phone_number, start_net_query(NetQueryType::SendCode, G()->net_query_creator().create(create_storer(r_send_code.move_as_ok()))); }; - with_send_code(process_send_code); + switch (type_) { + case Type::ChangePhone: + return process_send_code( + send_code_helper_.send_change_phone_code(phone_number, allow_flash_call, is_current_phone_number)); + case Type::VerifyPhone: + return process_send_code( + send_code_helper_.send_verify_phone_code(phone_number, allow_flash_call, is_current_phone_number)); + case Type::ConfirmPhone: + return process_send_code( + send_code_helper_.send_confirm_phone_code(phone_number, allow_flash_call, is_current_phone_number)); + default: + UNREACHABLE(); + } } void PhoneNumberManager::resend_authentication_code(uint64 query_id) { @@ -246,29 +245,23 @@ void PhoneNumberManager::check_code(uint64 query_id, string code) { return on_query_error(query_id, Status::Error(8, "checkAuthenticationCode unexpected")); } - auto with_api_object = [&](auto c) { - switch (type_) { - case Type::ChangePhone: - return c(telegram_api::account_changePhone(send_code_helper_.phone_number().str(), - send_code_helper_.phone_code_hash().str(), code)); - case Type::ConfirmPhone: - return c(telegram_api::account_confirmPhone(send_code_helper_.phone_code_hash().str(), code)); - case Type::VerifyPhone: - return c(telegram_api::account_verifyPhone(send_code_helper_.phone_number().str(), - send_code_helper_.phone_code_hash().str(), code)); - default: - UNREACHABLE(); - return c(telegram_api::account_changePhone(send_code_helper_.phone_number().str(), - send_code_helper_.phone_code_hash().str(), code)); - } - }; - on_new_query(query_id); auto send_new_query = [&](auto q) { start_net_query(NetQueryType::CheckCode, G()->net_query_creator().create(create_storer(q))); }; - with_api_object(send_new_query); + switch (type_) { + case Type::ChangePhone: + return send_new_query(telegram_api::account_changePhone(send_code_helper_.phone_number().str(), + send_code_helper_.phone_code_hash().str(), code)); + case Type::ConfirmPhone: + return send_new_query(telegram_api::account_confirmPhone(send_code_helper_.phone_code_hash().str(), code)); + case Type::VerifyPhone: + return send_new_query(telegram_api::account_verifyPhone(send_code_helper_.phone_number().str(), + send_code_helper_.phone_code_hash().str(), code)); + default: + UNREACHABLE(); + } } void PhoneNumberManager::on_new_query(uint64 query_id) { @@ -311,20 +304,6 @@ void PhoneNumberManager::start_net_query(NetQueryType net_query_type, NetQueryPt } void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) { - auto with_result = [&](auto c) { - switch (type_) { - case Type::ChangePhone: - return c(fetch_result(result->ok())); - case Type::VerifyPhone: - return c(fetch_result(result->ok())); - case Type::ConfirmPhone: - return c(fetch_result(result->ok())); - default: - UNREACHABLE(); - return c(fetch_result(result->ok())); - } - }; - auto process_result = [&](auto result) { if (result.is_error()) { return on_query_error(result.move_as_error()); @@ -333,7 +312,16 @@ void PhoneNumberManager::on_check_code_result(NetQueryPtr &result) { on_query_ok(); }; - with_result(process_result); + switch (type_) { + case Type::ChangePhone: + return process_result(fetch_result(result->ok())); + case Type::VerifyPhone: + return process_result(fetch_result(result->ok())); + case Type::ConfirmPhone: + return process_result(fetch_result(result->ok())); + default: + UNREACHABLE(); + } } void PhoneNumberManager::on_send_code_result(NetQueryPtr &result) { diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 699b0669..ff2319f0 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -4336,6 +4336,7 @@ void parse(ScopeNotificationSettings ¬ification_settings, ParserT &parser) { PARSE_FLAG(silent_send_message_ignored); PARSE_FLAG(notification_settings.is_synchronized); END_PARSE_FLAGS(); + (void)silent_send_message_ignored; if (is_muted) { parse(notification_settings.mute_until, parser); } diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index 38f88716..66695831 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -436,7 +436,7 @@ Result> decrypt_secure_file(FileManager const secure_storage::Secret &master_secret, const EncryptedSecureFile &secure_file) { if (!secure_file.file_id.is_valid()) { - return std::make_pair(secure_file.file_id, SecureFileCredentials{}); + return std::make_pair(secure_file.file_id, SecureFileCredentials()); } TRY_RESULT(hash, secure_storage::ValueHash::create(secure_file.file_hash)); TRY_RESULT(encrypted_secret, secure_storage::EncryptedSecret::create(secure_file.encrypted_secret)); @@ -520,15 +520,15 @@ EncryptedSecureFile encrypt_secure_file(FileManager *file_manager, const secure_ FileId file, string &to_hash) { auto file_view = file_manager->get_file_view(file); if (file_view.empty()) { - return {}; + return EncryptedSecureFile(); } if (!file_view.encryption_key().is_secure()) { LOG(ERROR) << "File has no encryption key"; - return {}; + return EncryptedSecureFile(); } if (!file_view.encryption_key().has_value_hash()) { LOG(ERROR) << "File has no hash"; - return {}; + return EncryptedSecureFile(); } auto value_hash = file_view.encryption_key().value_hash(); auto secret = file_view.encryption_key().secret(); @@ -641,29 +641,29 @@ JsonScope &operator+(JsonValueScope &scope, const SecureValueCredentials &creden Slice secure_value_type_as_slice(SecureValueType type) { switch (type) { case SecureValueType::PersonalDetails: - return "personal_details"; + return Slice("personal_details"); case SecureValueType::Passport: - return "passport"; + return Slice("passport"); case SecureValueType::DriverLicense: - return "driver_license"; + return Slice("driver_license"); case SecureValueType::IdentityCard: - return "identity_card"; + return Slice("identity_card"); case SecureValueType::Address: - return "address"; + return Slice("address"); case SecureValueType::UtilityBill: - return "utility_bill"; + return Slice("utility_bill"); case SecureValueType::BankStatement: - return "bank_statement"; + return Slice("bank_statement"); case SecureValueType::RentalAgreement: - return "rental_agreement"; + return Slice("rental_agreement"); case SecureValueType::PhoneNumber: - return "phone"; + return Slice("phone"); case SecureValueType::EmailAddress: - return "email"; + return Slice("email"); default: case SecureValueType::None: UNREACHABLE(); - return "none"; + return Slice("none"); } }