Skip to content

Commit

Permalink
Fix issues found by Coverity
Browse files Browse the repository at this point in the history
  • Loading branch information
Dave Cridland committed Mar 2, 2017
1 parent 88f1d01 commit 4b79757
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
3 changes: 3 additions & 0 deletions include/spiffing/categorydata.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ namespace Spiffing {
void compile(Spif const &);
bool matches(Label const &) const;
void fixup(Label &) const;
std::set<CategoryRef> const & cats() const {
return m_cats;
}
private:
std::set<CategoryRef> m_cats;
std::string m_tagSetRef;
Expand Down
26 changes: 14 additions & 12 deletions src/categorygroup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ SOFTWARE.
#include <spiffing/categorygroup.h>
#include <spiffing/markings.h>
#include <spiffing/categorydata.h>
#include <spiffing/label.h>

using namespace Spiffing;

Expand All @@ -34,19 +35,20 @@ CategoryGroup::CategoryGroup(OperationType opType) : m_opType(opType) {}
bool CategoryGroup::matches(Label const & l) const {
bool found{false};
for (auto const & cd : m_categoryData) {
if (cd->matches(l)) {
switch (m_opType) {
case OperationType::onlyOne:
if (found) return false;
break;
case OperationType::oneOrMore:
return true;
case OperationType::all:
;
for (auto const & cat : cd->cats()) {
if (l.hasCategory(cat)) {
switch (m_opType) {
case OperationType::onlyOne:
if (found) return false;
break;
case OperationType::oneOrMore:
return true;
case OperationType::all:;
}
found = true;
} else if (m_opType == OperationType::all) {
return false;
}
found = true;
} else if (m_opType == OperationType::all) {
return false;
}
}
return found;
Expand Down
8 changes: 7 additions & 1 deletion test-data/food-policy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,13 @@
<securityCategoryTag name="Packaging Materials" tagType="tagType7" tag7Encoding="securityAttributes">
<tagCategory name="Plastic" lacv='0'/>
</securityCategoryTag>
</securityCategiryTagSet>
</securityCategoryTagSet>
<securityCategoryTagSet name="Something" id="1.2.826.0.1.6726289.0.0.5">
<securityCategoryTag name="Things" tagType="enumerated" enumType="permissive">
<tagCategory name="Thing One" lacv='23'/>
<tagCategory name="Thing Two" lacv='42'/>
</securityCategoryTag>
</securityCategoryTagSet>
</securityCategoryTagSets>
<markingQualifier code='pageBottom'>
<qualifier markingQualifier="[ " qualifierCode="prefix"/>
Expand Down

0 comments on commit 4b79757

Please sign in to comment.