off_t hdrSz, pgSz, jSz;
OFF_T hdrSz, pgSz, jSz;
static int syncJournal(Pager *pPager){  PgHdr *pPg;  int rc = SQLITE_OK;  /* Sync the journal before modifying the main database  ** (assuming there is a journal and it needs to be synced.)  */  if( pPager->needSync ){    if( !pPager->tempFile ){      assert( pPager->journalOpen );      /* assert( !pPager->noSync ); // noSync might be set if synchronous      ** was turned off after the transaction was started.  Ticket #615 */#ifndef NDEBUG      {        /* Make sure the pPager->nRec counter we are keeping agrees        ** with the nRec computed from the size of the journal file.        */        off_t hdrSz, pgSz, jSz;        hdrSz = JOURNAL_HDR_SZ(journal_format);        pgSz = JOURNAL_PG_SZ(journal_format);        rc = sqliteOsFileSize(&pPager->jfd, &jSz);        if( rc!=0 ) return rc;        assert( pPager->nRec*pgSz+hdrSz==jSz );      }#endif      if( journal_format>=3 ){        /* Write the nRec value into the journal file header */        off_t szJ;        if( pPager->fullSync ){          TRACE1("SYNC\n");          rc = sqliteOsSync(&pPager->jfd);          if( rc!=0 ) return rc;        }        sqliteOsSeek(&pPager->jfd, sizeof(aJournalMagic1));        rc = write32bits(&pPager->jfd, pPager->nRec);        if( rc ) return rc;        szJ = JOURNAL_HDR_SZ(journal_format) +                 pPager->nRec*JOURNAL_PG_SZ(journal_format);        sqliteOsSeek(&pPager->jfd, szJ);      }      TRACE1("SYNC\n");      rc = sqliteOsSync(&pPager->jfd);      if( rc!=0 ) return rc;      pPager->journalStarted = 1;    }    pPager->needSync = 0;    /* Erase the needSync flag from every page.    */    for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){      pPg->needSync = 0;    }    pPager->pFirstSynced = pPager->pFirst;  }#ifndef NDEBUG  /* If the Pager.needSync flag is clear then the PgHdr.needSync  ** flag must also be clear for all pages.  Verify that this  ** invariant is true.  */  else{    for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){      assert( pPg->needSync==0 );    }    assert( pPager->pFirstSynced==pPager->pFirst );  }#endif  return rc;}