/ Check-in [01a79d5a]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Remove dead code identified by the clang static analyzer.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 01a79d5a7af48fb7e50291c0c7c6283d3fb359d0
User & Date: drh 2011-03-06 21:28:32
Context
2011-03-06
21:54
Another minor simplification brought to light by clang. check-in: 3bfbf026 user: drh tags: trunk
21:28
Remove dead code identified by the clang static analyzer. check-in: 01a79d5a user: drh tags: trunk
2011-03-05
21:41
Simplifications to the overflow-free multiplier. Also remove some commented-out code that was left in that subroutine by mistake on the previous check-in. check-in: 55fc25fd user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/btree.c.

  6175   6175       for(j=i+1; j<k; j++){
  6176   6176         if( apNew[j]->pgno<(unsigned)minV ){
  6177   6177           minI = j;
  6178   6178           minV = apNew[j]->pgno;
  6179   6179         }
  6180   6180       }
  6181   6181       if( minI>i ){
  6182         -      int t;
  6183   6182         MemPage *pT;
  6184         -      t = apNew[i]->pgno;
  6185   6183         pT = apNew[i];
  6186   6184         apNew[i] = apNew[minI];
  6187   6185         apNew[minI] = pT;
  6188   6186       }
  6189   6187     }
  6190   6188     TRACE(("new: %d(%d) %d(%d) %d(%d) %d(%d) %d(%d)\n",
  6191   6189       apNew[0]->pgno, szNew[0],

Changes to src/fkey.c.

   683    683   void sqlite3FkCheck(
   684    684     Parse *pParse,                  /* Parse context */
   685    685     Table *pTab,                    /* Row is being deleted from this table */ 
   686    686     int regOld,                     /* Previous row data is stored here */
   687    687     int regNew                      /* New row data is stored here */
   688    688   ){
   689    689     sqlite3 *db = pParse->db;       /* Database handle */
   690         -  Vdbe *v;                        /* VM to write code to */
   691    690     FKey *pFKey;                    /* Used to iterate through FKs */
   692    691     int iDb;                        /* Index of database containing pTab */
   693    692     const char *zDb;                /* Name of database containing pTab */
   694    693     int isIgnoreErrors = pParse->disableTriggers;
   695    694   
   696    695     /* Exactly one of regOld and regNew should be non-zero. */
   697    696     assert( (regOld==0)!=(regNew==0) );
   698    697   
   699    698     /* If foreign-keys are disabled, this function is a no-op. */
   700    699     if( (db->flags&SQLITE_ForeignKeys)==0 ) return;
   701    700   
   702         -  v = sqlite3GetVdbe(pParse);
   703    701     iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
   704    702     zDb = db->aDb[iDb].zName;
   705    703   
   706    704     /* Loop through all the foreign key constraints for which pTab is the
   707    705     ** child table (the table that the foreign key definition is part of).  */
   708    706     for(pFKey=pTab->pFKey; pFKey; pFKey=pFKey->pNextFrom){
   709    707       Table *pTo;                   /* Parent table of foreign key pFKey */

Changes to src/insert.c.

   461    461     /* Register allocations */
   462    462     int regFromSelect = 0;/* Base register for data coming from SELECT */
   463    463     int regAutoinc = 0;   /* Register holding the AUTOINCREMENT counter */
   464    464     int regRowCount = 0;  /* Memory cell used for the row counter */
   465    465     int regIns;           /* Block of regs holding rowid+data being inserted */
   466    466     int regRowid;         /* registers holding insert rowid */
   467    467     int regData;          /* register holding first column to insert */
   468         -  int regRecord;        /* Holds the assemblied row record */
   469    468     int regEof = 0;       /* Register recording end of SELECT data */
   470    469     int *aRegIdx = 0;     /* One register allocated to each index */
   471    470   
   472    471   #ifndef SQLITE_OMIT_TRIGGER
   473    472     int isView;                 /* True if attempting to insert into a view */
   474    473     Trigger *pTrigger;          /* List of triggers on pTab, if required */
   475    474     int tmask;                  /* Mask of trigger times */
................................................................................
   790    789       addrCont = sqlite3VdbeAddOp1(v, OP_Yield, dest.iParm);
   791    790       addrInsTop = sqlite3VdbeAddOp1(v, OP_If, regEof);
   792    791     }
   793    792   
   794    793     /* Allocate registers for holding the rowid of the new row,
   795    794     ** the content of the new row, and the assemblied row record.
   796    795     */
   797         -  regRecord = ++pParse->nMem;
   798    796     regRowid = regIns = pParse->nMem+1;
   799    797     pParse->nMem += pTab->nCol + 1;
   800    798     if( IsVirtual(pTab) ){
   801    799       regRowid++;
   802    800       pParse->nMem++;
   803    801     }
   804    802     regData = regRowid+1;
................................................................................
  1184   1182           || onError==OE_Ignore || onError==OE_Replace );
  1185   1183       switch( onError ){
  1186   1184         case OE_Abort:
  1187   1185           sqlite3MayAbort(pParse);
  1188   1186         case OE_Rollback:
  1189   1187         case OE_Fail: {
  1190   1188           char *zMsg;
  1191         -        j1 = sqlite3VdbeAddOp3(v, OP_HaltIfNull,
         1189  +        sqlite3VdbeAddOp3(v, OP_HaltIfNull,
  1192   1190                                     SQLITE_CONSTRAINT, onError, regData+i);
  1193   1191           zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
  1194   1192                                 pTab->zName, pTab->aCol[i].zName);
  1195   1193           sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
  1196   1194           break;
  1197   1195         }
  1198   1196         case OE_Ignore: {

Changes to src/prepare.c.

   137    137     int size;
   138    138     Table *pTab;
   139    139     Db *pDb;
   140    140     char const *azArg[4];
   141    141     int meta[5];
   142    142     InitData initData;
   143    143     char const *zMasterSchema;
   144         -  char const *zMasterName = SCHEMA_TABLE(iDb);
          144  +  char const *zMasterName;
   145    145     int openedTransaction = 0;
   146    146   
   147    147     /*
   148    148     ** The master database table has a structure like this
   149    149     */
   150    150     static const char master_schema[] = 
   151    151        "CREATE TABLE sqlite_master(\n"

Changes to src/trigger.c.

   258    258     Trigger *pTrig = pParse->pNewTrigger;   /* Trigger being finished */
   259    259     char *zName;                            /* Name of trigger */
   260    260     sqlite3 *db = pParse->db;               /* The database */
   261    261     DbFixer sFix;                           /* Fixer object */
   262    262     int iDb;                                /* Database containing the trigger */
   263    263     Token nameToken;                        /* Trigger name for error reporting */
   264    264   
   265         -  pTrig = pParse->pNewTrigger;
   266    265     pParse->pNewTrigger = 0;
   267    266     if( NEVER(pParse->nErr) || !pTrig ) goto triggerfinish_cleanup;
   268    267     zName = pTrig->zName;
   269    268     iDb = sqlite3SchemaToIndex(pParse->db, pTrig->pSchema);
   270    269     pTrig->step_list = pStepList;
   271    270     while( pStepList ){
   272    271       pStepList->pTrig = pTrig;

Changes to src/update.c.

   124    124     /* Register Allocations */
   125    125     int regRowCount = 0;   /* A count of rows changed */
   126    126     int regOldRowid;       /* The old rowid */
   127    127     int regNewRowid;       /* The new rowid */
   128    128     int regNew;
   129    129     int regOld = 0;
   130    130     int regRowSet = 0;     /* Rowset of rows to be updated */
   131         -  int regRec;            /* Register used for new table record to insert */
   132    131   
   133    132     memset(&sContext, 0, sizeof(sContext));
   134    133     db = pParse->db;
   135    134     if( pParse->nErr || db->mallocFailed ){
   136    135       goto update_cleanup;
   137    136     }
   138    137     assert( pTabList->nSrc==1 );
................................................................................
   282    281       pParse->nMem += pTab->nCol;
   283    282     }
   284    283     if( chngRowid || pTrigger || hasFK ){
   285    284       regNewRowid = ++pParse->nMem;
   286    285     }
   287    286     regNew = pParse->nMem + 1;
   288    287     pParse->nMem += pTab->nCol;
   289         -  regRec = ++pParse->nMem;
   290    288   
   291    289     /* Start the view context. */
   292    290     if( isView ){
   293    291       sqlite3AuthContextPush(pParse, &sContext, pTab->zName);
   294    292     }
   295    293   
   296    294     /* If we are trying to update a view, realize that view into

Changes to src/vdbe.c.

  2425   2425     ** Each type field is a varint representing the serial type of the 
  2426   2426     ** corresponding data element (see sqlite3VdbeSerialType()). The
  2427   2427     ** hdr-size field is also a varint which is the offset from the beginning
  2428   2428     ** of the record to data0.
  2429   2429     */
  2430   2430     nData = 0;         /* Number of bytes of data space */
  2431   2431     nHdr = 0;          /* Number of bytes of header space */
  2432         -  nByte = 0;         /* Data space required for this record */
  2433   2432     nZero = 0;         /* Number of zero bytes at the end of the record */
  2434   2433     nField = pOp->p1;
  2435   2434     zAffinity = pOp->p4.z;
  2436   2435     assert( nField>0 && pOp->p2>0 && pOp->p2+nField<=p->nMem+1 );
  2437   2436     pData0 = &aMem[nField];
  2438   2437     nField = pOp->p2;
  2439   2438     pLast = &pData0[nField-1];
................................................................................
  3699   3698       **
  3700   3699       ** The second algorithm is to select a rowid at random and see if
  3701   3700       ** it already exists in the table.  If it does not exist, we have
  3702   3701       ** succeeded.  If the random rowid does exist, we select a new one
  3703   3702       ** and try again, up to 100 times.
  3704   3703       */
  3705   3704       assert( pC->isTable );
  3706         -    cnt = 0;
  3707   3705   
  3708   3706   #ifdef SQLITE_32BIT_ROWID
  3709   3707   #   define MAX_ROWID 0x7fffffff
  3710   3708   #else
  3711   3709       /* Some compilers complain about constants of the form 0x7fffffffffffffff.
  3712   3710       ** Others complain about 0x7ffffffffffffffffLL.  The following macro seems
  3713   3711       ** to provide the constant while making all compilers happy.

Changes to src/vdbeapi.c.

   678    678   ** Check to see if column iCol of the given statement is valid.  If
   679    679   ** it is, return a pointer to the Mem for the value of that column.
   680    680   ** If iCol is not valid, return a pointer to a Mem which has a value
   681    681   ** of NULL.
   682    682   */
   683    683   static Mem *columnMem(sqlite3_stmt *pStmt, int i){
   684    684     Vdbe *pVm;
   685         -  int vals;
   686    685     Mem *pOut;
   687    686   
   688    687     pVm = (Vdbe *)pStmt;
   689    688     if( pVm && pVm->pResultSet!=0 && i<pVm->nResColumn && i>=0 ){
   690    689       sqlite3_mutex_enter(pVm->db->mutex);
   691         -    vals = sqlite3_data_count(pStmt);
   692    690       pOut = &pVm->pResultSet[i];
   693    691     }else{
   694    692       /* If the value passed as the second argument is out of range, return
   695    693       ** a pointer to the following static Mem object which contains the
   696    694       ** value SQL NULL. Even though the Mem structure contains an element
   697    695       ** of type i64, on certain architecture (x86) with certain compiler
   698    696       ** switches (-Os), gcc may align this Mem object on a 4-byte boundary

Changes to src/wal.c.

  1645   1645     /* Allocate the iterator */
  1646   1646     rc = walIteratorInit(pWal, &pIter);
  1647   1647     if( rc!=SQLITE_OK ){
  1648   1648       return rc;
  1649   1649     }
  1650   1650     assert( pIter );
  1651   1651   
  1652         -  mxPage = pWal->hdr.nPage;
  1653   1652     if( eMode!=SQLITE_CHECKPOINT_PASSIVE ) xBusy = xBusyCall;
  1654   1653   
  1655   1654     /* Compute in mxSafeFrame the index of the last frame of the WAL that is
  1656   1655     ** safe to write into the database.  Frames beyond mxSafeFrame might
  1657   1656     ** overwrite database pages that are in use by active readers and thus
  1658   1657     ** cannot be backfilled from the WAL.
  1659   1658     */

Changes to src/where.c.

  4043   4043       **
  4044   4044       **          Return     2                # Jump back to the Gosub
  4045   4045       **
  4046   4046       **       B: <after the loop>
  4047   4047       **
  4048   4048       */
  4049   4049       WhereClause *pOrWc;    /* The OR-clause broken out into subterms */
  4050         -    WhereTerm *pFinal;     /* Final subterm within the OR-clause. */
  4051   4050       SrcList *pOrTab;       /* Shortened table list or OR-clause generation */
  4052   4051   
  4053   4052       int regReturn = ++pParse->nMem;           /* Register used with OP_Gosub */
  4054   4053       int regRowset = 0;                        /* Register for RowSet object */
  4055   4054       int regRowid = 0;                         /* Register holding rowid */
  4056   4055       int iLoopBody = sqlite3VdbeMakeLabel(v);  /* Start of loop body */
  4057   4056       int iRetInit;                             /* Address of regReturn init */
................................................................................
  4059   4058       int ii;
  4060   4059      
  4061   4060       pTerm = pLevel->plan.u.pTerm;
  4062   4061       assert( pTerm!=0 );
  4063   4062       assert( pTerm->eOperator==WO_OR );
  4064   4063       assert( (pTerm->wtFlags & TERM_ORINFO)!=0 );
  4065   4064       pOrWc = &pTerm->u.pOrInfo->wc;
  4066         -    pFinal = &pOrWc->a[pOrWc->nTerm-1];
  4067   4065       pLevel->op = OP_Return;
  4068   4066       pLevel->p1 = regReturn;
  4069   4067   
  4070   4068       /* Set up a new SrcList ni pOrTab containing the table being scanned
  4071   4069       ** by this loop in the a[0] slot and all notReady tables in a[1..] slots.
  4072   4070       ** This becomes the SrcList in the recursive call to sqlite3WhereBegin().
  4073   4071       */
................................................................................
  4168   4166     /* Insert code to test every subexpression that can be completely
  4169   4167     ** computed using the current set of tables.
  4170   4168     **
  4171   4169     ** IMPLEMENTATION-OF: R-49525-50935 Terms that cannot be satisfied through
  4172   4170     ** the use of indices become tests that are evaluated against each row of
  4173   4171     ** the relevant input tables.
  4174   4172     */
  4175         -  k = 0;
  4176   4173     for(pTerm=pWC->a, j=pWC->nTerm; j>0; j--, pTerm++){
  4177   4174       Expr *pE;
  4178   4175       testcase( pTerm->wtFlags & TERM_VIRTUAL ); /* IMP: R-30575-11662 */
  4179   4176       testcase( pTerm->wtFlags & TERM_CODED );
  4180   4177       if( pTerm->wtFlags & (TERM_VIRTUAL|TERM_CODED) ) continue;
  4181   4178       if( (pTerm->prereqAll & notReady)!=0 ){
  4182   4179         testcase( pWInfo->untestedTerms==0
................................................................................
  4186   4183       }
  4187   4184       pE = pTerm->pExpr;
  4188   4185       assert( pE!=0 );
  4189   4186       if( pLevel->iLeftJoin && !ExprHasProperty(pE, EP_FromJoin) ){
  4190   4187         continue;
  4191   4188       }
  4192   4189       sqlite3ExprIfFalse(pParse, pE, addrCont, SQLITE_JUMPIFNULL);
  4193         -    k = 1;
  4194   4190       pTerm->wtFlags |= TERM_CODED;
  4195   4191     }
  4196   4192   
  4197   4193     /* For a LEFT OUTER JOIN, generate code that will record the fact that
  4198   4194     ** at least one row of the right table has matched the left table.  
  4199   4195     */
  4200   4196     if( pLevel->iLeftJoin ){
................................................................................
  4494   4490     **   pWInfo->a[].iIdxCur   The VDBE cursor for the index
  4495   4491     **   pWInfo->a[].pTerm     When wsFlags==WO_OR, the OR-clause term
  4496   4492     **
  4497   4493     ** This loop also figures out the nesting order of tables in the FROM
  4498   4494     ** clause.
  4499   4495     */
  4500   4496     notReady = ~(Bitmask)0;
  4501         -  pTabItem = pTabList->a;
  4502         -  pLevel = pWInfo->a;
  4503   4497     andFlags = ~0;
  4504   4498     WHERETRACE(("*** Optimizer Start ***\n"));
  4505   4499     for(i=iFrom=0, pLevel=pWInfo->a; i<nTabList; i++, pLevel++){
  4506   4500       WhereCost bestPlan;         /* Most efficient plan seen so far */
  4507   4501       Index *pIdx;                /* Index for FROM table at pTabItem */
  4508   4502       int j;                      /* For looping over FROM tables */
  4509   4503       int bestJ = -1;             /* The value of j */