Add static_assert that flag in STORE_FLAG/PARSE_FLAG is bool.

This commit is contained in:
levlam 2022-03-01 21:39:24 +03:00
parent 17d38edc19
commit a59e6b8ffe
2 changed files with 8 additions and 6 deletions

View File

@ -5468,7 +5468,7 @@ void MessagesManager::Dialog::store(StorerT &storer) const {
STORE_FLAG(need_drop_default_send_message_as_dialog_id);
STORE_FLAG(has_available_reactions);
STORE_FLAG(is_available_reactions_inited);
STORE_FLAG(available_reactions_generation);
STORE_FLAG(has_available_reactions_generation);
END_STORE_FLAGS();
}
@ -23700,7 +23700,7 @@ unique_ptr<MessagesManager::Message> MessagesManager::parse_message(Dialog *d, M
LOG(ERROR) << "Fix available_reactions_generation in " << dialog_id << " from "
<< d->available_reactions_generation << " to " << m->available_reactions_generation;
hide_dialog_message_reactions(d);
set_dialog_available_reactions_generation(d, m->available_reactions_generation);
set_dialog_available_reactions_generation(d, m->available_reactions_generation + 1);
on_dialog_updated(dialog_id, "parse_message");
break;
case DialogType::User:

View File

@ -26,8 +26,9 @@
::td::uint32 flags_store = 0; \
::td::uint32 bit_offset_store = 0
#define STORE_FLAG(flag) \
flags_store |= (flag) << bit_offset_store; \
#define STORE_FLAG(flag) \
static_assert(std::is_same<decltype(flag), bool>::value, "flag must be bool"); \
flags_store |= (flag) << bit_offset_store; \
bit_offset_store++
#define END_STORE_FLAGS() \
@ -42,8 +43,9 @@
::td::uint32 bit_offset_parse = 0; \
::td::parse(flags_parse, parser)
#define PARSE_FLAG(flag) \
flag = ((flags_parse >> bit_offset_parse) & 1) != 0; \
#define PARSE_FLAG(flag) \
static_assert(std::is_same<decltype(flag), bool>::value, "flag must be bool"); \
flag = ((flags_parse >> bit_offset_parse) & 1) != 0; \
bit_offset_parse++
#define END_PARSE_FLAGS() \