src/worker.cc
// Calculate the CRC of a region.
// Result check if the CRC mismatches.
Calculate the CRC of a region.
Result check if the CRC mismatches.
Calculate the CRC of a region . Result check if the CRC mismatches .
int WorkerThread::CrcCheckPage(struct page_entry *srcpe) {
  const int blocksize = 4096;
  const int blockwords = blocksize / wordsize_;
  int errors = 0;
  const AdlerChecksum *expectedcrc = srcpe->pattern->crc();
  uint64 *memblock = static_cast<uint64*>(srcpe->addr);
  int blocks = sat_->page_length() / blocksize;
  for (int currentblock = 0; currentblock < blocks; currentblock++) {
    uint64 *memslice = memblock + currentblock * blockwords;
    AdlerChecksum crc;
    if (tag_mode_) {
      AdlerAddrCrcC(memslice, blocksize, &crc, srcpe);
    } else {
      CalculateAdlerChecksum(memslice, blocksize, &crc);
    }
    if (!crc.Equals(*expectedcrc)) {
      logprintf(11, "Log: CrcCheckPage Falling through to slow compare, "
                "CRC mismatch %s != %s\n",
                crc.ToHexString().c_str(),
                expectedcrc->ToHexString().c_str());
      int errorcount = CheckRegion(memslice,
                                   srcpe->pattern,
                                   blocksize,
                                   currentblock * blocksize, 0);
      if (errorcount == 0) {
        logprintf(0, "Log: CrcCheckPage CRC mismatch %s != %s, "
                     "but no miscompares found.\n",
                  crc.ToHexString().c_str(),
                  expectedcrc->ToHexString().c_str());
      }
      errors += errorcount;
    }
  }
  int leftovers = sat_->page_length() % blocksize;
  if (leftovers) {
    uint64 *memslice = memblock + blocks * blockwords;
    errors += CheckRegion(memslice,
                          srcpe->pattern,
                          leftovers,
                          blocks * blocksize, 0);
  }
  return errors;
}
int WorkerThread :: CrcCheckPage ( struct page_entry * srcpe ) { const int blocksize = 4096 ; const int blockwords = blocksize / wordsize_ ; int errors = 0 ; const AdlerChecksum * expectedcrc = srcpe -> pattern -> crc ( ) ; uint64 * memblock = static_cast < uint64 * > ( srcpe -> addr ) ; int blocks = sat_ -> page_length ( ) / blocksize ; for ( int currentblock = 0 ; currentblock < blocks ; currentblock ++ ) { uint64 * memslice = memblock + currentblock * blockwords ; AdlerChecksum crc ; if ( tag_mode_ ) { AdlerAddrCrcC ( memslice , blocksize , & crc , srcpe ) ; } else { CalculateAdlerChecksum ( memslice , blocksize , & crc ) ; } if ( ! crc . Equals ( * expectedcrc ) ) { logprintf ( 11 , " " " \n " , crc . ToHexString ( ) . c_str ( ) , expectedcrc -> ToHexString ( ) . c_str ( ) ) ; int errorcount = CheckRegion ( memslice , srcpe -> pattern , blocksize , currentblock * blocksize , 0 ) ; if ( errorcount == 0 ) { logprintf ( 0 , " " " \n " , crc . ToHexString ( ) . c_str ( ) , expectedcrc -> ToHexString ( ) . c_str ( ) ) ; } errors += errorcount ; } } int leftovers = sat_ -> page_length ( ) % blocksize ; if ( leftovers ) { uint64 * memslice = memblock + blocks * blockwords ; errors += CheckRegion ( memslice , srcpe -> pattern , leftovers , blocks * blocksize , 0 ) ; } return errors ; }
Calculate the CRC of a region.
Calculate the CRC of a region .
// If the CRC does not match, we'd better look closer. // For odd length transfers, we should never hit this.