Fix stringification of bitfields with duplicate values

* We'd previously subtract the bitfield value twice, leading to underflow and
  then lots of unknown bits appear to be set. Instead we should clear the bit so
  that it's safe to apply multiple times.
This commit is contained in:
baldurk
2019-01-09 10:02:18 +00:00
parent 7ad3197982
commit 21e056e5b8
+4 -4
View File
@@ -110,28 +110,28 @@ std::string ToStr(const T &el)
#define STRINGISE_BITFIELD_BIT(b) \
if(el & b) \
{ \
local -= (uint32_t)b; \
local &= ~uint32_t(b); \
ret += " | " #b; \
}
#define STRINGISE_BITFIELD_CLASS_BIT(b) \
if(el & enumType::b) \
{ \
local -= (uint32_t)enumType::b; \
local &= ~uint32_t(enumType::b); \
ret += " | " #b; \
}
#define STRINGISE_BITFIELD_BIT_NAMED(b, str) \
if(el & b) \
{ \
local -= (uint32_t)b; \
local &= ~uint32_t(b); \
ret += " | " str; \
}
#define STRINGISE_BITFIELD_CLASS_BIT_NAMED(b, str) \
if(el & enumType::b) \
{ \
local -= (uint32_t)enumType::b; \
local &= ~uint32_t(enumType::b); \
ret += " | " str; \
}