Remove END_PARSE_FLAGS_GENERIC.

GitOrigin-RevId: c9a47a56158829aca0572bab1497e3aebcc7216d
This commit is contained in:
levlam 2019-08-01 03:40:28 +03:00
parent df0d6c7f5e
commit 108dc0d4f8
6 changed files with 18 additions and 24 deletions

View File

@ -69,7 +69,7 @@ void DeviceTokenManager::TokenInfo::parse(ParserT &parser) {
PARSE_FLAG(is_register); PARSE_FLAG(is_register);
PARSE_FLAG(is_app_sandbox); PARSE_FLAG(is_app_sandbox);
PARSE_FLAG(encrypt); PARSE_FLAG(encrypt);
END_PARSE_FLAGS_GENERIC(); END_PARSE_FLAGS();
CHECK(is_sync + is_unregister + is_register == 1); CHECK(is_sync + is_unregister + is_register == 1);
if (is_sync) { if (is_sync) {
state = State::Sync; state = State::Sync;

View File

@ -209,7 +209,7 @@ class SecretChatActor : public NetQueryCallback {
my_layer = parser.fetch_int(); my_layer = parser.fetch_int();
// for future usage // for future usage
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC(); END_PARSE_FLAGS();
} }
} }

View File

@ -66,6 +66,7 @@ void FileData::store(StorerT &storer) const {
} }
} }
} }
template <class ParserT> template <class ParserT>
void FileData::parse(ParserT &parser, bool register_file_sources) { void FileData::parse(ParserT &parser, bool register_file_sources) {
using ::td::parse; using ::td::parse;
@ -80,7 +81,10 @@ void FileData::parse(ParserT &parser, bool register_file_sources) {
PARSE_FLAG(encryption_key_is_secure); PARSE_FLAG(encryption_key_is_secure);
PARSE_FLAG(has_sources); PARSE_FLAG(has_sources);
PARSE_FLAG(has_version); PARSE_FLAG(has_version);
TRY_END_PARSE_FLAGS_GENERIC(); END_PARSE_FLAGS();
if (parser.get_error()) {
return;
}
int32 version = 0; int32 version = 0;
if (has_version) { if (has_version) {
@ -115,6 +119,9 @@ void FileData::parse(ParserT &parser, bool register_file_sources) {
parse(size, parser); parse(size, parser);
if (0 < size && size < 5) { if (0 < size && size < 5) {
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
if (parser.get_error()) {
return;
}
file_source_ids_.push_back(td->file_reference_manager_->parse_file_source(td, parser)); file_source_ids_.push_back(td->file_reference_manager_->parse_file_source(td, parser));
} }
} else { } else {

View File

@ -83,7 +83,7 @@ struct AesCtrEncryptionEvent {
void parse(ParserT &&parser) { void parse(ParserT &&parser) {
using td::parse; using td::parse;
BEGIN_PARSE_FLAGS(); BEGIN_PARSE_FLAGS();
END_PARSE_FLAGS_GENERIC(); END_PARSE_FLAGS();
parse(key_salt_, parser); parse(key_salt_, parser);
parse(iv_, parser); parse(iv_, parser);
parse(key_hash_, parser); parse(key_hash_, parser);

View File

@ -185,4 +185,5 @@ class Parser {
char *end_; char *end_;
Status status_; Status status_;
}; };
} // namespace td } // namespace td

View File

@ -44,26 +44,12 @@
flag = ((flags_parse >> bit_offset_parse) & 1) != 0; \ flag = ((flags_parse >> bit_offset_parse) & 1) != 0; \
bit_offset_parse++ bit_offset_parse++
#define END_PARSE_FLAGS() \ #define END_PARSE_FLAGS() \
CHECK(bit_offset_parse < 31); \ CHECK(bit_offset_parse < 31); \
LOG_CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) \ if ((flags_parse & ~((1 << bit_offset_parse) - 1)) != 0) { \
<< flags_parse << " " << bit_offset_parse << " " << parser.version(); \ parser.set_error(PSTRING() << "Invalid flags " << flags_parse << " left, current bit is " << bit_offset_parse); \
} \ } \
while (false) } \
#define END_PARSE_FLAGS_GENERIC() \
CHECK(bit_offset_parse < 31); \
LOG_CHECK((flags_parse & ~((1 << bit_offset_parse) - 1)) == 0) << flags_parse << " " << bit_offset_parse; \
} \
while (false)
#define TRY_END_PARSE_FLAGS_GENERIC() \
CHECK(bit_offset_parse < 31); \
if ((flags_parse & ~((1 << bit_offset_parse) - 1)) != 0) { \
parser.set_error("invalid flags"); \
return; \
} \
} \
while (false) while (false)
namespace td { namespace td {