rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)mxPg);
rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(OFF_T)mxPg);
static int pager_playback(Pager *pPager, int useJournalSize){  off_t szJ;               /* Size of the journal file in bytes */  int nRec;                /* Number of Records in the journal */  int i;                   /* Loop counter */  Pgno mxPg = 0;           /* Size of the original file in pages */  int format;              /* Format of the journal file. */  unsigned char aMagic[sizeof(aJournalMagic1)];  int rc;  /* Figure out how many records are in the journal.  Abort early if  ** the journal is empty.  */  assert( pPager->journalOpen );  sqliteOsSeek(&pPager->jfd, 0);  rc = sqliteOsFileSize(&pPager->jfd, &szJ);  if( rc!=SQLITE_OK ){    goto end_playback;  }  /* If the journal file is too small to contain a complete header,  ** it must mean that the process that created the journal was just  ** beginning to write the journal file when it died.  In that case,  ** the database file should have still been completely unchanged.  ** Nothing needs to be rolled back.  We can safely ignore this journal.  */  if( szJ < sizeof(aMagic)+sizeof(Pgno) ){    goto end_playback;  }  /* Read the beginning of the journal and truncate the  ** database file back to its original size.  */  rc = sqliteOsRead(&pPager->jfd, aMagic, sizeof(aMagic));  if( rc!=SQLITE_OK ){    rc = SQLITE_PROTOCOL;    goto end_playback;  }  if( memcmp(aMagic, aJournalMagic3, sizeof(aMagic))==0 ){    format = JOURNAL_FORMAT_3;  }else if( memcmp(aMagic, aJournalMagic2, sizeof(aMagic))==0 ){    format = JOURNAL_FORMAT_2;  }else if( memcmp(aMagic, aJournalMagic1, sizeof(aMagic))==0 ){    format = JOURNAL_FORMAT_1;  }else{    rc = SQLITE_PROTOCOL;    goto end_playback;  }  if( format>=JOURNAL_FORMAT_3 ){    if( szJ < sizeof(aMagic) + 3*sizeof(u32) ){      /* Ignore the journal if it is too small to contain a complete      ** header.  We already did this test once above, but at the prior      ** test, we did not know the journal format and so we had to assume      ** the smallest possible header.  Now we know the header is bigger      ** than the minimum so we test again.      */      goto end_playback;    }    rc = read32bits(format, &pPager->jfd, (u32*)&nRec);    if( rc ) goto end_playback;    rc = read32bits(format, &pPager->jfd, &pPager->cksumInit);    if( rc ) goto end_playback;    if( nRec==0xffffffff || useJournalSize ){      nRec = (szJ - JOURNAL_HDR_SZ(3))/JOURNAL_PG_SZ(3);    }  }else{    nRec = (szJ - JOURNAL_HDR_SZ(2))/JOURNAL_PG_SZ(2);    assert( nRec*JOURNAL_PG_SZ(2)+JOURNAL_HDR_SZ(2)==szJ );  }  rc = read32bits(format, &pPager->jfd, &mxPg);  if( rc!=SQLITE_OK ){    goto end_playback;  }  assert( pPager->origDbSize==0 || pPager->origDbSize==mxPg );  rc = sqliteOsTruncate(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)mxPg);  if( rc!=SQLITE_OK ){    goto end_playback;  }  pPager->dbSize = mxPg;    /* Copy original pages out of the journal and back into the database file.  */  for(i=0; i<nRec; i++){    rc = pager_playback_one_page(pPager, &pPager->jfd, format);    if( rc!=SQLITE_OK ){      if( rc==SQLITE_DONE ){        rc = SQLITE_OK;      }      break;    }  }  /* Pages that have been written to the journal but never synced  ** where not restored by the loop above.  We have to restore those  ** pages by reading them back from the original database.  */  if( rc==SQLITE_OK ){    PgHdr *pPg;    for(pPg=pPager->pAll; pPg; pPg=pPg->pNextAll){      char zBuf[SQLITE_PAGE_SIZE];      if( !pPg->dirty ) continue;      if( (int)pPg->pgno <= pPager->origDbSize ){        sqliteOsSeek(&pPager->fd, SQLITE_PAGE_SIZE*(off_t)(pPg->pgno-1));        rc = sqliteOsRead(&pPager->fd, zBuf, SQLITE_PAGE_SIZE);        TRACE2("REFETCH %d\n", pPg->pgno);        CODEC(pPager, zBuf, pPg->pgno, 2);        if( rc ) break;      }else{        memset(zBuf, 0, SQLITE_PAGE_SIZE);      }      if( pPg->nRef==0 || memcmp(zBuf, PGHDR_TO_DATA(pPg), SQLITE_PAGE_SIZE) ){        memcpy(PGHDR_TO_DATA(pPg), zBuf, SQLITE_PAGE_SIZE);        memset(PGHDR_TO_EXTRA(pPg), 0, pPager->nExtra);      }      pPg->needSync = 0;      pPg->dirty = 0;    }  }end_playback:  if( rc!=SQLITE_OK ){    pager_unwritelock(pPager);    pPager->errMask |= PAGER_ERR_CORRUPT;    rc = SQLITE_CORRUPT;  }else{    rc = pager_unwritelock(pPager);  }  return rc;}