From f9cbe247cd1a6a61ec26240826284d5c3163e43b Mon Sep 17 00:00:00 2001 From: levlam Date: Tue, 28 Aug 2018 01:08:51 +0300 Subject: [PATCH] Add Wdeprecated flag. GitOrigin-RevId: 8aa900d7103efd0207f7f0fcb09e3bd2b7387564 --- CMakeLists.txt | 1 + td/telegram/MessagesManager.h | 6 ++++++ td/telegram/SecureStorage.cpp | 14 +++++++------- td/telegram/SecureStorage.h | 6 ++++++ td/telegram/net/DcId.h | 1 - test/secure_storage.cpp | 6 +++--- 6 files changed, 23 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 177972a3f..2ca334571 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -202,6 +202,7 @@ if (NOT MSVC) add_cxx_compiler_flag("-Wconversion") add_cxx_compiler_flag("-Wno-sign-conversion") add_cxx_compiler_flag("-Wc++14-compat-pedantic") + add_cxx_compiler_flag("-Wdeprecated") add_cxx_compiler_flag("-Qunused-arguments") add_cxx_compiler_flag("-Wodr") add_cxx_compiler_flag("-flto-odr-type-merging") diff --git a/td/telegram/MessagesManager.h b/td/telegram/MessagesManager.h index 6ebe0992d..ddfceb87f 100644 --- a/td/telegram/MessagesManager.h +++ b/td/telegram/MessagesManager.h @@ -72,6 +72,12 @@ class MultiSequenceDispatcher; // Do not forget to update MessagesManager::update_message_content when one of the inheritors of this class changes class MessageContent { public: + MessageContent() = default; + MessageContent(const MessageContent &) = default; + MessageContent &operator=(const MessageContent &) = default; + MessageContent(MessageContent &&) = default; + MessageContent &operator=(MessageContent &&) = default; + virtual int32 get_id() const = 0; virtual ~MessageContent() = default; }; diff --git a/td/telegram/SecureStorage.cpp b/td/telegram/SecureStorage.cpp index e20cbb16b..0f9b4e163 100644 --- a/td/telegram/SecureStorage.cpp +++ b/td/telegram/SecureStorage.cpp @@ -324,9 +324,9 @@ Result Encryptor::pread(int64 offset, int64 size) { } Result encrypt_value(const Secret &secret, Slice data) { - auto random_prefix_view = BufferSliceDataView(gen_random_prefix(data.size())); - auto data_view = BufferSliceDataView(BufferSlice(data)); - auto full_view = ConcatDataView(random_prefix_view, data_view); + BufferSliceDataView random_prefix_view{gen_random_prefix(data.size())}; + BufferSliceDataView data_view{BufferSlice(data)}; + ConcatDataView full_view{random_prefix_view, data_view}; TRY_RESULT(hash, calc_value_hash(full_view)); @@ -353,9 +353,9 @@ Result encrypt_file(const Secret &secret, std::string src, std::strin TRY_RESULT(dest_file, FileFd::open(dest, FileFd::Flags::Truncate | FileFd::Flags::Write | FileFd::Create)); auto src_file_size = src_file.get_size(); - auto random_prefix_view = BufferSliceDataView(gen_random_prefix(src_file_size)); - auto data_view = FileDataView(src_file, src_file_size); - auto full_view = ConcatDataView(random_prefix_view, data_view); + BufferSliceDataView random_prefix_view(gen_random_prefix(src_file_size)); + FileDataView data_view(src_file, src_file_size); + ConcatDataView full_view(random_prefix_view, data_view); TRY_RESULT(hash, calc_value_hash(full_view)); @@ -371,7 +371,7 @@ Status decrypt_file(const Secret &secret, const ValueHash &hash, std::string src TRY_RESULT(dest_file, FileFd::open(dest, FileFd::Flags::Truncate | FileFd::Flags::Write | FileFd::Create)); auto src_file_size = src_file.get_size(); - auto src_file_view = FileDataView(src_file, src_file_size); + FileDataView src_file_view(src_file, src_file_size); auto aes_cbc_state = calc_aes_cbc_state_sha512(PSLICE() << secret.as_slice() << hash.as_slice()); Decryptor decryptor(aes_cbc_state); diff --git a/td/telegram/SecureStorage.h b/td/telegram/SecureStorage.h index b6afa97a2..46b30bc3f 100644 --- a/td/telegram/SecureStorage.h +++ b/td/telegram/SecureStorage.h @@ -63,6 +63,12 @@ class ValueHash { class DataView { public: + DataView() = default; + DataView(const DataView &) = delete; + DataView &operator=(const DataView &) = delete; + DataView(DataView &&) = delete; + DataView &operator=(DataView &&) = delete; + virtual int64 size() const = 0; virtual Result pread(int64 offset, int64 size) = 0; virtual ~DataView() = default; diff --git a/td/telegram/net/DcId.h b/td/telegram/net/DcId.h index 74346672e..8ce115e10 100644 --- a/td/telegram/net/DcId.h +++ b/td/telegram/net/DcId.h @@ -16,7 +16,6 @@ namespace td { class DcId { public: DcId() = default; - DcId(const DcId &other) = default; static bool is_valid(int32 dc_id) { return 1 <= dc_id && dc_id <= 1000; diff --git a/test/secure_storage.cpp b/test/secure_storage.cpp index 5dcd6f439..1b1b122d4 100644 --- a/test/secure_storage.cpp +++ b/test/secure_storage.cpp @@ -32,10 +32,10 @@ TEST(SecureStorage, simple) { auto value_secret = Secret::create_new(); { - auto value_view = BufferSliceDataView(value.copy()); + BufferSliceDataView value_view(value.copy()); BufferSlice prefix = gen_random_prefix(value_view.size()); - auto prefix_view = BufferSliceDataView(std::move(prefix)); - auto full_value_view = ConcatDataView(prefix_view, value_view); + BufferSliceDataView prefix_view(std::move(prefix)); + ConcatDataView full_value_view(prefix_view, value_view); auto hash = calc_value_hash(full_value_view).move_as_ok(); Encryptor encryptor(calc_aes_cbc_state_sha512(PSLICE() << value_secret.as_slice() << hash.as_slice()),