aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordrh <drh@noemail.net>2020-07-30 17:14:55 +0000
committerdrh <drh@noemail.net>2020-07-30 17:14:55 +0000
commit48bf2d72b90c218f47352c8c6f68316fff86808e (patch)
treeaaffdd2b742c3743663b87541aebded9920ea818 /src
parent8deae5ade337b578599b5e3c22d9480f24e7e53e (diff)
downloadsqlite-48bf2d72b90c218f47352c8c6f68316fff86808e.tar.gz
sqlite-48bf2d72b90c218f47352c8c6f68316fff86808e.zip
Fix unreachable branches.
FossilOrigin-Name: 905752da9815ff8242b3cb9a77b1ffdc5cfc76143f47c774890f617a542457a5
Diffstat (limited to 'src')
-rw-r--r--src/btree.c7
-rw-r--r--src/build.c2
-rw-r--r--src/prepare.c2
-rw-r--r--src/util.c2
4 files changed, 6 insertions, 7 deletions
diff --git a/src/btree.c b/src/btree.c
index bfe554ff8..e61e4e605 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 97e9909e0..f52e2365b 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 c71400530..8e2186b10 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 8fbbcfd16..2371aad17 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;
}