From a1d6be72ffed94f5c65c821c5fc859aacc5290ab Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 16 Apr 2018 18:02:42 +0300 Subject: [PATCH] Better fix for END_PARSE_FLAGS. GitOrigin-RevId: 8838c020bb677df926fce87c0e2343600089345d --- td/telegram/DeviceTokenManager.cpp | 2 +- td/telegram/SecretChatActor.h | 7 ++++--- td/telegram/files/FileLocation.h | 2 +- tddb/td/db/binlog/Binlog.cpp | 9 ++++----- tdutils/td/utils/tl_helpers.h | 4 ++++ 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/td/telegram/DeviceTokenManager.cpp b/td/telegram/DeviceTokenManager.cpp index dd6fee1e..a9d23c82 100644 --- a/td/telegram/DeviceTokenManager.cpp +++ b/td/telegram/DeviceTokenManager.cpp @@ -59,7 +59,7 @@ void DeviceTokenManager::TokenInfo::parse(ParserT &parser) { PARSE_FLAG(is_unregister); PARSE_FLAG(is_register); PARSE_FLAG(is_app_sandbox); - // END_PARSE_FLAGS(); + END_PARSE_FLAGS_GENERIC(); CHECK(is_sync + is_unregister + is_register == 1); if (is_sync) { state = State::Sync; diff --git a/td/telegram/SecretChatActor.h b/td/telegram/SecretChatActor.h index cf098cac..7c8e04cc 100644 --- a/td/telegram/SecretChatActor.h +++ b/td/telegram/SecretChatActor.h @@ -188,7 +188,8 @@ class SecretChatActor : public NetQueryCallback { storer.store_int(ttl); storer.store_int(my_layer); //for future usage - storer.store_int(0); + BEGIN_STORE_FLAGS(); + END_STORE_FLAGS(); } template @@ -200,8 +201,8 @@ class SecretChatActor : public NetQueryCallback { his_layer &= ~HAS_FLAGS; my_layer = parser.fetch_int(); // for future usage - int32 flags = parser.fetch_int(); - CHECK(flags == 0); + BEGIN_PARSE_FLAGS(); + END_PARSE_FLAGS_GENERIC(); } } diff --git a/td/telegram/files/FileLocation.h b/td/telegram/files/FileLocation.h index f0f3a677..bd78637b 100644 --- a/td/telegram/files/FileLocation.h +++ b/td/telegram/files/FileLocation.h @@ -1222,7 +1222,7 @@ class FileData { PARSE_FLAG(has_owner_dialog_id); PARSE_FLAG(has_expected_size); PARSE_FLAG(encryption_key_is_secure); - // END_PARSE_FLAGS(); + END_PARSE_FLAGS_GENERIC(); if (has_owner_dialog_id) { parse(owner_dialog_id_, parser); diff --git a/tddb/td/db/binlog/Binlog.cpp b/tddb/td/db/binlog/Binlog.cpp index aa3104cd..68b15010 100644 --- a/tddb/td/db/binlog/Binlog.cpp +++ b/tddb/td/db/binlog/Binlog.cpp @@ -72,8 +72,8 @@ struct AesCtrEncryptionEvent { template void store(StorerT &storer) const { using td::store; - int32 flags = 0; - store(flags, storer); + BEGIN_STORE_FLAGS(); + END_STORE_FLAGS(); store(key_salt_, storer); store(iv_, storer); store(key_hash_, storer); @@ -81,9 +81,8 @@ struct AesCtrEncryptionEvent { template void parse(ParserT &&parser) { using td::parse; - int32 flags; - parse(flags, parser); - CHECK(flags == 0); + BEGIN_PARSE_FLAGS(); + END_PARSE_FLAGS_GENERIC(); parse(key_salt_, parser); parse(iv_, parser); parse(key_hash_, parser); diff --git a/tdutils/td/utils/tl_helpers.h b/tdutils/td/utils/tl_helpers.h index d98a5742..1334b128 100644 --- a/tdutils/td/utils/tl_helpers.h +++ b/tdutils/td/utils/tl_helpers.h @@ -44,6 +44,10 @@ CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) \ << flags_parse << " " << bit_offset_parse << " " << parser.version(); +#define END_PARSE_FLAGS_GENERIC() \ + CHECK(bit_offset_parse < 31); \ + CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) << flags_parse << " " << bit_offset_parse; + namespace td { template void store(bool x, StorerT &storer) {