[ox/mc] Fix FieldPresenceIndicator to return correct value when overflow occurs

This commit is contained in:
Gary Talent 2019-07-29 22:55:17 -05:00
parent 142387aa04
commit ff4adaebf1
2 changed files with 3 additions and 3 deletions

View File

@ -17,11 +17,11 @@ FieldPresenceIndicator::FieldPresenceIndicator(uint8_t *mask, std::size_t maxLen
m_maskLen = maxLen;
}
bool FieldPresenceIndicator::get(int i) const {
ValErr<bool> FieldPresenceIndicator::get(int i) const {
if (i / 8 < m_maskLen) {
return (m_mask[i / 8] >> (i % 8)) & 1;
} else {
return MC_PRESENCEMASKOUTBOUNDS;
return {false, OxError(MC_PRESENCEMASKOUTBOUNDS)};
}
}

View File

@ -22,7 +22,7 @@ class FieldPresenceIndicator {
public:
FieldPresenceIndicator(uint8_t *mask, std::size_t maxLen);
bool get(int i) const;
ValErr<bool> get(int i) const;
Error set(int i, bool on);