Navigation Menu

Skip to content

Commit

Permalink
Changed FluxDecoder to allow zero flux reversals
Browse files Browse the repository at this point in the history
Previously we'd assert in the debug version and crash in the
release version due to invalid use of the flux iterator.

Thanks to Philippe for reporting an image revealing this.
  • Loading branch information
simonowen committed Jul 7, 2018
1 parent d146ac2 commit 2e877ca
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/FluxDecoder.cpp
Expand Up @@ -13,7 +13,6 @@ FluxDecoder::FluxDecoder (const FluxData &flux_revs, int bitcell_ns, int flux_sc
m_pll_adjust(pll_adjust)
{
assert(flux_revs.size());
assert(flux_revs[0].size());

m_rev_it = m_flux_revs.cbegin();
m_flux_it = (*m_rev_it).cbegin();
Expand Down Expand Up @@ -111,6 +110,8 @@ int FluxDecoder::next_flux ()

m_index = true;
m_flux_it = (*m_rev_it).cbegin();
if (m_flux_it == (*m_rev_it).cend())
return -1;
}

auto time_ns = *m_flux_it++;
Expand Down
2 changes: 1 addition & 1 deletion src/Sector.cpp
Expand Up @@ -82,7 +82,7 @@ Sector::Merge Sector::add (Data &&new_data, bool bad_crc, uint8_t new_dam)
CRC16 crc;
if (encoding == Encoding::MFM) crc.init(CRC16::A1A1A1);
crc.add(new_dam);
auto bad_data_crc = crc.add(new_data.new_data(), size() + 2) != 0;
auto bad_data_crc = crc.add(new_data.data(), size() + 2) != 0;
assert(bad_crc == bad_data_crc);
}
#endif
Expand Down

0 comments on commit 2e877ca

Please sign in to comment.