From 48bf2d72b90c218f47352c8c6f68316fff86808e Mon Sep 17 00:00:00 2001 From: drh Date: Thu, 30 Jul 2020 17:14:55 +0000 Subject: [PATCH] Fix unreachable branches. FossilOrigin-Name: 905752da9815ff8242b3cb9a77b1ffdc5cfc76143f47c774890f617a542457a5 --- manifest | 18 +++++++++--------- manifest.uuid | 2 +- src/btree.c | 7 +++---- src/build.c | 2 +- src/prepare.c | 2 +- src/util.c | 2 +- 6 files changed, 16 insertions(+), 17 deletions(-) diff --git a/manifest b/manifest index ed5431dc02..9e4c34e9a5 100644 --- a/manifest +++ b/manifest @@ -1,5 +1,5 @@ -C Fix\ssigned/unsigned\scompiler\swarnings. -D 2020-07-29T12:23:20.348 +C Fix\sunreachable\sbranches. +D 2020-07-30T17:14:55.498 F .fossil-settings/empty-dirs dbb81e8fc0401ac46a1491ab34a7f2c7c0452f2f06b54ebb845d024ca8283ef1 F .fossil-settings/ignore-glob 35175cdfcf539b2318cb04a9901442804be81cd677d8b889fcc9149c21f239ea F LICENSE.md df5091916dbb40e6e9686186587125e1b2ff51f022cc334e886c19a0e9982724 @@ -476,10 +476,10 @@ F src/auth.c a3d5bfdba83d25abed1013a8c7a5f204e2e29b0c25242a56bc02bb0c07bf1e06 F src/backup.c b1c90cd4110248c8e1273ff4578d3a84c0c34725e1b96dacd4a6294a908702de F src/bitvec.c 17ea48eff8ba979f1f5b04cc484c7bb2be632f33 F src/btmutex.c 8acc2f464ee76324bf13310df5692a262b801808984c1b79defb2503bbafadb6 -F src/btree.c e047029ffa66e96c054906e61cbc78d840eca8c0f4fe0022862911c2d742921a +F src/btree.c 56ec47e80dbde686efb4079b6a8efda8ffd22795267b640dbdeb6c70d91dcacf F src/btree.h 7af72bbb4863c331c8f6753277ab40ee67d2a2125a63256d5c25489722ec162b F src/btreeInt.h 83166f6daeb91062b6ae9ee6247b3ad07e40eba58f3c05ba9e8dedad4ab1ea38 -F src/build.c e3e29c7791a408f7f616f4ea1b2808596014d688094cc048c7c7a93d588a603f +F src/build.c c2e1390b8bff21daf9da03d097e4f824cdf4c15cd823ba072a7820694c8728eb F src/callback.c d0b853dd413255d2e337b34545e54d888ea02f20da5ad0e63585b389624c4a6c F src/complete.c a3634ab1e687055cd002e11b8f43eb75c17da23e F src/ctime.c e98518d2d3d4029a13c805e07313fb60c877be56db76e90dd5f3af73085d0ce6 @@ -530,7 +530,7 @@ F src/pcache.h 4f87acd914cef5016fae3030343540d75f5b85a1877eed1a2a19b9f284248586 F src/pcache1.c 6596e10baf3d8f84cc1585d226cf1ab26564a5f5caf85a15757a281ff977d51a F src/pragma.c bdb600be936f66b9fe69d26dfbba4528beaaf4f95c479c85b328a92484e0bf71 F src/pragma.h 8dc78ab7e9ec6ce3ded8332810a2066f1ef6267e2e03cd7356ee00276125c6cf -F src/prepare.c e1c684b945cd8333a5d85c03ea0376f9fee56d1c73a7111e3aaad2c0959e0b31 +F src/prepare.c 3d5a761d026052bc888d1b803a06dd2bfe245e8e836d4689f927003549148b0f F src/printf.c 94b5419ad0a17269f76a9e968ca19cf9fa37617abed2e246fc48844e511b6bc6 F src/random.c 80f5d666f23feb3e6665a6ce04c7197212a88384 F src/resolve.c 2dd6821aac2cd27de9fcf6aa6d1f8c41b4b5841c9bc58bf1c9109008009a3a2e @@ -605,7 +605,7 @@ F src/trigger.c ef67bde309a831515dc3c2173d792574309f2f42d45f8c078743fae9f7f98c75 F src/update.c fb15bec5b54fd098f4b84f6abc83c7103b45ba8484011fff8edf5ae31656eab6 F src/upsert.c 2920de71b20f04fe25eb00b655d086f0ba60ea133c59d7fa3325c49838818e78 F src/utf.c ee39565f0843775cc2c81135751ddd93eceb91a673ea2c57f61c76f288b041a0 -F src/util.c 7aa93048926824e96043906ed54fa59176c64aa9d674ff097b00f6d5843990e3 +F src/util.c c8bf30c4356b091bcc3b624d0e24b2b4d11b8be4d6c90d8e0705971e15cc819b F src/vacuum.c 1c4f8e2f39d950037f4cf946b6858c993d3a54c3101f78e05c76460a073afcf0 F src/vdbe.c aeb19f086eb507ac6ba347028fea8265bf8fb66dd9cc2509338693a767612f99 F src/vdbe.h 83603854bfa5851af601fc0947671eb260f4363e62e960e8a994fb9bbcd2aaa1 @@ -1879,7 +1879,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93 F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0 -P 805bb67a82be51dc6077480691ed815c63a37bd8fc00cf7e67e020349c6e322e -R 04d29aa0ebddb0a89a6241304b40c2fa +P 1d69eee8b085d514f442840346f001b4785f8ec64f5ba66943e9577b26e2e29c +R e750109cf0648accd12ecb5530f24e6e U drh -Z d770f10134cafeb266d89cfa6d12ba0d +Z 4d1ff6cf3b2902d2c83733f58d9b4355 diff --git a/manifest.uuid b/manifest.uuid index 367542ce06..b778ecf54c 100644 --- a/manifest.uuid +++ b/manifest.uuid @@ -1 +1 @@ -1d69eee8b085d514f442840346f001b4785f8ec64f5ba66943e9577b26e2e29c \ No newline at end of file +905752da9815ff8242b3cb9a77b1ffdc5cfc76143f47c774890f617a542457a5 \ No newline at end of file diff --git a/src/btree.c b/src/btree.c index bfe554ff86..e61e4e605b 100644 --- a/src/btree.c +++ b/src/btree.c @@ -5947,7 +5947,7 @@ static int allocateBtreePage( */ #ifndef SQLITE_OMIT_AUTOVACUUM if( eMode==BTALLOC_EXACT ){ - if( nearby<=mxPage ){ + if( ALWAYS(nearby<=mxPage) ){ u8 eType; assert( nearby>0 ); assert( pBt->autoVacuum ); @@ -6243,7 +6243,7 @@ static int freePage2(BtShared *pBt, MemPage *pMemPage, Pgno iPage){ assert( CORRUPT_DB || iPage>1 ); assert( !pMemPage || pMemPage->pgno==iPage ); - if( iPage<2 || iPage>pBt->nPage ){ + if( iPage<2 || NEVER(iPage>pBt->nPage) ){ return SQLITE_CORRUPT_BKPT; } if( pMemPage ){ @@ -9143,8 +9143,7 @@ static int btreeCreateTable(Btree *p, Pgno *piTable, int createTabFlags){ pgnoRoot==PENDING_BYTE_PAGE(pBt) ){ pgnoRoot++; } - assert( pgnoRoot>=3 || CORRUPT_DB ); - testcase( pgnoRoot<3 ); + assert( pgnoRoot>=3 ); /* Allocate a page. The page that currently resides at pgnoRoot will ** be moved to the allocated page (unless the allocated page happens diff --git a/src/build.c b/src/build.c index 97e9909e03..f52e2365bb 100644 --- a/src/build.c +++ b/src/build.c @@ -2844,7 +2844,7 @@ void sqlite3RootPageMoved(sqlite3 *db, int iDb, Pgno iFrom, Pgno iTo){ static void destroyRootPage(Parse *pParse, int iTable, int iDb){ Vdbe *v = sqlite3GetVdbe(pParse); int r1 = sqlite3GetTempReg(pParse); - if( iTable<2 ) sqlite3ErrorMsg(pParse, "corrupt schema"); + if( NEVER(iTable<2) ) return; sqlite3VdbeAddOp3(v, OP_Destroy, iTable, r1, iDb); sqlite3MayAbort(pParse); #ifndef SQLITE_OMIT_AUTOVACUUM diff --git a/src/prepare.c b/src/prepare.c index c714005308..8e2186b102 100644 --- a/src/prepare.c +++ b/src/prepare.c @@ -159,7 +159,7 @@ int sqlite3InitCallback(void *pInit, int argc, char **argv, char **NotUsed){ }else if( sqlite3GetUInt32(argv[3],&pIndex->tnum)==0 || pIndex->tnum<2 - || (pIndex->tnum>pData->mxPage && pData->mxPage!=0) + || pIndex->tnum>pData->mxPage || sqlite3IndexHasDuplicateRootPage(pIndex) ){ if( sqlite3Config.bExtraSchemaChecks ){ diff --git a/src/util.c b/src/util.c index 8fbbcfd16d..2371aad17c 100644 --- a/src/util.c +++ b/src/util.c @@ -859,7 +859,7 @@ int sqlite3GetInt32(const char *zNum, int *pValue){ */ int sqlite3Atoi(const char *z){ int x = 0; - if( z ) sqlite3GetInt32(z, &x); + sqlite3GetInt32(z, &x); return x; }