Skip to content

Commit

Permalink
Add Wdeprecated flag.
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 8aa900d7103efd0207f7f0fcb09e3bd2b7387564
  • Loading branch information
levlam committed Aug 27, 2018
1 parent 692bc1f commit f9cbe24
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 11 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
6 changes: 6 additions & 0 deletions td/telegram/MessagesManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down
14 changes: 7 additions & 7 deletions td/telegram/SecureStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,9 @@ Result<BufferSlice> Encryptor::pread(int64 offset, int64 size) {
}

Result<EncryptedValue> 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));

Expand All @@ -353,9 +353,9 @@ Result<ValueHash> 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));

Expand All @@ -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);
Expand Down
6 changes: 6 additions & 0 deletions td/telegram/SecureStorage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<BufferSlice> pread(int64 offset, int64 size) = 0;
virtual ~DataView() = default;
Expand Down
1 change: 0 additions & 1 deletion td/telegram/net/DcId.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
6 changes: 3 additions & 3 deletions test/secure_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit f9cbe24

Please sign in to comment.