Fix some compiler warnings in the MSVC build.

FossilOrigin-Name: 1f5662b7db5d623c8d99c45a8d97a0aa4427593f
diff --git a/src/btree.c b/src/btree.c
index b9987a2..e64aaa1 100644
--- a/src/btree.c
+++ b/src/btree.c
@@ -1382,7 +1382,7 @@
     u8 *data;          /* Equal to pPage->aData */
     BtShared *pBt;        /* The main btree structure */
     int usableSize;    /* Amount of usable space on each page */
-    int cellOffset;    /* Offset from start of page to first cell pointer */
+    u16 cellOffset;    /* Offset from start of page to first cell pointer */
     int nFree;         /* Number of unused bytes on the page */
     int top;           /* First byte of the cell content area */
     int iCellFirst;    /* First allowable cell or freeblock offset */
@@ -1497,7 +1497,7 @@
   memset(&data[hdr+1], 0, 4);
   data[hdr+7] = 0;
   put2byte(&data[hdr+5], pBt->usableSize);
-  pPage->nFree = pBt->usableSize - first;
+  pPage->nFree = (u16)(pBt->usableSize - first);
   decodeFlags(pPage, flags);
   pPage->hdrOffset = hdr;
   pPage->cellOffset = first;
@@ -2326,7 +2326,7 @@
     }
     assert( (pageSize & 7)==0 );
     usableSize = pageSize - page1[20];
-    if( pageSize!=pBt->pageSize ){
+    if( (u32)pageSize!=pBt->pageSize ){
       /* After reading the first page of the database assuming a page size
       ** of BtShared.pageSize, we have discovered that the page-size is
       ** actually pageSize. Unlock the database, leave pBt->pPage1 at
@@ -2369,10 +2369,10 @@
   ** 17 bytes long, 0 to N bytes of payload, and an optional 4 byte overflow
   ** page pointer.
   */
-  pBt->maxLocal = (pBt->usableSize-12)*64/255 - 23;
-  pBt->minLocal = (pBt->usableSize-12)*32/255 - 23;
-  pBt->maxLeaf = pBt->usableSize - 35;
-  pBt->minLeaf = (pBt->usableSize-12)*32/255 - 23;
+  pBt->maxLocal = (u16)((pBt->usableSize-12)*64/255 - 23);
+  pBt->minLocal = (u16)((pBt->usableSize-12)*32/255 - 23);
+  pBt->maxLeaf = (u16)(pBt->usableSize - 35);
+  pBt->minLeaf = (u16)((pBt->usableSize-12)*32/255 - 23);
   assert( pBt->maxLeaf + 23 <= MX_CELL_SIZE(pBt) );
   pBt->pPage1 = pPage1;
   pBt->nPage = nPage;
@@ -2425,8 +2425,8 @@
   if( rc ) return rc;
   memcpy(data, zMagicHeader, sizeof(zMagicHeader));
   assert( sizeof(zMagicHeader)==16 );
-  data[16] = (pBt->pageSize>>8)&0xff;
-  data[17] = (pBt->pageSize>>16)&0xff;
+  data[16] = (u8)((pBt->pageSize>>8)&0xff);
+  data[17] = (u8)((pBt->pageSize>>16)&0xff);
   data[18] = 1;
   data[19] = 1;
   assert( pBt->usableSize<=pBt->pageSize && pBt->usableSize+255>=pBt->pageSize);
@@ -5108,7 +5108,7 @@
   Pgno ovflPgno;
   int rc;
   int nOvfl;
-  u16 ovflPageSize;
+  u32 ovflPageSize;
 
   assert( sqlite3_mutex_held(pPage->pBt->mutex) );
   btreeParseCellPtr(pPage, pCell, &info);
diff --git a/src/expr.c b/src/expr.c
index fd21eb5..33864b2 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -566,7 +566,7 @@
           db->aLimit[SQLITE_LIMIT_VARIABLE_NUMBER]);
     }
     if( i>pParse->nVar ){
-      pParse->nVar = i;
+      pParse->nVar = (int)i;
     }
   }else{
     /* Wildcards like ":aaa", "$aaa" or "@aaa".  Reuse the same variable
diff --git a/src/pager.c b/src/pager.c
index e39ca90..04b7c82 100644
--- a/src/pager.c
+++ b/src/pager.c
@@ -1057,7 +1057,7 @@
     assert( pPager->eLock>=eLock );
     rc = sqlite3OsUnlock(pPager->fd, eLock);
     if( pPager->eLock!=UNKNOWN_LOCK ){
-      pPager->eLock = eLock;
+      pPager->eLock = (u8)eLock;
     }
     IOTRACE(("UNLOCK %p %d\n", pPager, eLock))
   }
@@ -1081,7 +1081,7 @@
   if( pPager->eLock<eLock || pPager->eLock==UNKNOWN_LOCK ){
     rc = sqlite3OsLock(pPager->fd, eLock);
     if( rc==SQLITE_OK && (pPager->eLock!=UNKNOWN_LOCK||eLock==EXCLUSIVE_LOCK) ){
-      pPager->eLock = eLock;
+      pPager->eLock = (u8)eLock;
       IOTRACE(("LOCK %p %d\n", pPager, eLock))
     }
   }
@@ -3366,7 +3366,7 @@
    && sqlite3PcacheRefCount(pPager->pPCache)==0 
    && pageSize && pageSize!=(u32)pPager->pageSize 
   ){
-    char *pNew;                 /* New temp space */
+    char *pNew = NULL;             /* New temp space */
     i64 nByte = 0;
 
     if( pPager->eState>PAGER_OPEN && isOpen(pPager->fd) ){
@@ -3379,7 +3379,7 @@
 
     if( rc==SQLITE_OK ){
       pager_reset(pPager);
-      pPager->dbSize = nByte/pageSize;
+      pPager->dbSize = (Pgno)(nByte/pageSize);
       pPager->pageSize = pageSize;
       sqlite3PageFree(pPager->pTmpSpace);
       pPager->pTmpSpace = pNew;
diff --git a/src/wal.c b/src/wal.c
index 94c6925..22ce1fa 100644
--- a/src/wal.c
+++ b/src/wal.c
@@ -1135,7 +1135,7 @@
       if( nTruncate ){
         pWal->hdr.mxFrame = iFrame;
         pWal->hdr.nPage = nTruncate;
-        pWal->hdr.szPage = (szPage&0xff00) | (szPage>>16);
+        pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));
         testcase( szPage<=32768 );
         testcase( szPage>=65536 );
         aFrameCksum[0] = pWal->hdr.aFrameCksum[0];
@@ -2562,7 +2562,7 @@
 
   if( rc==SQLITE_OK ){
     /* Update the private copy of the header. */
-    pWal->hdr.szPage = (szPage&0xff00) | (szPage>>16);
+    pWal->hdr.szPage = (u16)((szPage&0xff00) | (szPage>>16));
     testcase( szPage<=32768 );
     testcase( szPage>=65536 );
     pWal->hdr.mxFrame = iFrame;