From 18cd0dd95eceb4ea6de52ca55fba8ffcaf7da960 Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 18 May 2022 16:59:15 +0300 Subject: [PATCH] Workaround GCC 12 false positive warnings. --- CMake/TdSetUpCompiler.cmake | 3 +++ td/telegram/SecretChatActor.cpp | 7 +++---- td/telegram/logevent/SecretChatEvent.h | 18 +++++++++--------- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/CMake/TdSetUpCompiler.cmake b/CMake/TdSetUpCompiler.cmake index 67320174e..728615e27 100644 --- a/CMake/TdSetUpCompiler.cmake +++ b/CMake/TdSetUpCompiler.cmake @@ -145,6 +145,9 @@ function(td_set_up_compiler) # see http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1579 add_cxx_compiler_flag("-Wno-redundant-move") endif() + if (GCC AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 12.0)) + add_cxx_compiler_flag("-Wno-stringop-overflow") # some false positives + endif() if (CLANG AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)) # https://stackoverflow.com/questions/26744556/warning-returning-a-captured-reference-from-a-lambda add_cxx_compiler_flag("-Wno-return-stack-address") diff --git a/td/telegram/SecretChatActor.cpp b/td/telegram/SecretChatActor.cpp index 181c3eb3c..2d70b3195 100644 --- a/td/telegram/SecretChatActor.cpp +++ b/td/telegram/SecretChatActor.cpp @@ -1516,7 +1516,7 @@ Status SecretChatActor::outbound_rewrite_with_empty(uint64 state_id) { state->message->is_external = false; state->message->need_notify_user = false; state->message->is_silent = true; - state->message->file = log_event::EncryptedInputFile::from_input_encrypted_file(nullptr); + state->message->file = log_event::EncryptedInputFile(); binlog_rewrite(context_->binlog(), state->message->log_event_id(), LogEvent::HandlerType::SecretChats, create_storer(*state->message)); return Status::OK(); @@ -1606,15 +1606,14 @@ void SecretChatActor::on_outbound_send_message_result(NetQueryPtr query, Promise auto sent = move_tl_object_as(result); auto file = EncryptedFile::get_encrypted_file(std::move(sent->file_)); if (file == nullptr) { - state->message->file = log_event::EncryptedInputFile::from_input_encrypted_file(nullptr); + state->message->file = log_event::EncryptedInputFile(); state->send_result_ = [this, random_id = state->message->random_id, message_id = MessageId(ServerMessageId(state->message->message_id)), date = sent->date_](Promise<> promise) { context_->on_send_message_ok(random_id, message_id, date, nullptr, std::move(promise)); }; } else { - state->message->file = log_event::EncryptedInputFile::from_input_encrypted_file( - make_tl_object(file->id_, file->access_hash_)); + state->message->file = {log_event::EncryptedInputFile::Location, file->id_, file->access_hash_, 0, 0}; state->send_result_ = [this, random_id = state->message->random_id, message_id = MessageId(ServerMessageId(state->message->message_id)), date = sent->date_, file = *file](Promise<> promise) { diff --git a/td/telegram/logevent/SecretChatEvent.h b/td/telegram/logevent/SecretChatEvent.h index 6186c7d68..f5951d039 100644 --- a/td/telegram/logevent/SecretChatEvent.h +++ b/td/telegram/logevent/SecretChatEvent.h @@ -175,31 +175,30 @@ struct EncryptedInputFile { } } static EncryptedInputFile from_input_encrypted_file(const tl_object_ptr &from) { - if (!from) { - return EncryptedInputFile{Empty, 0, 0, 0, 0}; + if (from == nullptr) { + return EncryptedInputFile(); } - return from_input_encrypted_file(*from); - } - static EncryptedInputFile from_input_encrypted_file(const telegram_api::InputEncryptedFile &from) { - switch (from.get_id()) { + switch (from->get_id()) { case telegram_api::inputEncryptedFileEmpty::ID: return EncryptedInputFile{Empty, 0, 0, 0, 0}; case telegram_api::inputEncryptedFileUploaded::ID: { - auto &uploaded = static_cast(from); + auto &uploaded = static_cast(*from); return EncryptedInputFile{Uploaded, uploaded.id_, 0, uploaded.parts_, uploaded.key_fingerprint_}; } case telegram_api::inputEncryptedFileBigUploaded::ID: { - auto &uploaded = static_cast(from); + auto &uploaded = static_cast(*from); return EncryptedInputFile{BigUploaded, uploaded.id_, 0, uploaded.parts_, uploaded.key_fingerprint_}; } case telegram_api::inputEncryptedFile::ID: { - auto &uploaded = static_cast(from); + auto &uploaded = static_cast(*from); return EncryptedInputFile{Location, uploaded.id_, uploaded.access_hash_, 0, 0}; } default: UNREACHABLE(); + return EncryptedInputFile(); } } + tl_object_ptr as_input_encrypted_file() const { switch (type) { case Empty: @@ -212,6 +211,7 @@ struct EncryptedInputFile { return make_tl_object(id, access_hash); } UNREACHABLE(); + return nullptr; } };