From: José Fonseca Date: Mon, 23 Apr 2012 09:13:48 +0000 (+0100) Subject: Handle zero valued bitmask flags. X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=fc9939fc84a006ccddfad84b137b6915b1a55771;hp=f6b0dfe46e320daa8f59b935372223ba0308b2ce;p=apitrace Handle zero valued bitmask flags. --- diff --git a/common/trace_dump.cpp b/common/trace_dump.cpp index 0f7ee36..06c0079 100644 --- a/common/trace_dump.cpp +++ b/common/trace_dump.cpp @@ -142,6 +142,7 @@ public: const BitmaskSig *sig = bitmask->sig; bool first = true; for (const BitmaskFlag *it = sig->flags; it != sig->flags + sig->num_flags; ++it) { + assert(it->value || first); if ((it->value && (value & it->value) == it->value) || (!it->value && value == 0)) { if (!first) { diff --git a/gui/apitracecall.cpp b/gui/apitracecall.cpp index dfaaeef..25b035d 100644 --- a/gui/apitracecall.cpp +++ b/gui/apitracecall.cpp @@ -336,7 +336,6 @@ void ApiBitmask::init(const trace::Bitmask *bitmask) m_value = bitmask->value; for (const trace::BitmaskFlag *it = bitmask->sig->flags; it != bitmask->sig->flags + bitmask->sig->num_flags; ++it) { - assert(it->value); QPair pair; pair.first = QString::fromStdString(it->name); @@ -351,10 +350,10 @@ QString ApiBitmask::toString() const QString str; unsigned long long value = m_value; bool first = true; - for (Signature::const_iterator it = m_sig.begin(); - value != 0 && it != m_sig.end(); ++it) { - Q_ASSERT(it->second); - if ((value & it->second) == it->second) { + for (Signature::const_iterator it = m_sig.begin(); it != m_sig.end(); ++it) { + Q_ASSERT(it->second || first); + if ((it->second && (value & it->second) == it->second) || + (!it->second && value == 0)) { if (!first) { str += QLatin1String(" | "); } @@ -362,6 +361,9 @@ QString ApiBitmask::toString() const value &= ~it->second; first = false; } + if (value == 0) { + break; + } } if (value || first) { if (!first) {