/ Check-in [39408702]
Login

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

Overview
Comment:Added the tool/warnings-clang.sh script. Changes so that there are no warnings with either gcc or clang even including FTS4 and RTREE and both with and without SQLITE_THREADSAFE=0.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 39408702a989f907261c298bf0947f3e68bd10fe
User & Date: drh 2011-10-15 00:16:30
Context
2011-10-17
12:14
Performance improvement for ascii to floating-point conversions with very large exponents. check-in: 59bb999c user: drh tags: trunk
2011-10-15
00:16
Added the tool/warnings-clang.sh script. Changes so that there are no warnings with either gcc or clang even including FTS4 and RTREE and both with and without SQLITE_THREADSAFE=0. check-in: 39408702 user: drh tags: trunk
2011-10-14
22:57
Fix a few minor and harmless clang warnings in FTS3 and RTREE. check-in: b3324f6c user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to ext/fts3/fts3.c.

  4333   4333           res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
  4334   4334         }
  4335   4335     
  4336   4336         aPoslist = pExpr->pRight->pPhrase->doclist.pList;
  4337   4337         nToken = pExpr->pRight->pPhrase->nToken;
  4338   4338         for(p=pExpr->pLeft; p && res; p=p->pLeft){
  4339   4339           int nNear;
         4340  +        Fts3Phrase *pPhrase;
  4340   4341           assert( p->pParent && p->pParent->pLeft==p );
  4341   4342           nNear = p->pParent->nNear;
  4342         -        Fts3Phrase *pPhrase = (
         4343  +        pPhrase = (
  4343   4344               p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase
  4344   4345           );
  4345   4346           res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
  4346   4347         }
  4347   4348       }
  4348   4349   
  4349   4350       sqlite3_free(aTmp);

Changes to ext/rtree/rtree.c.

  1568   1568       int iCell;
  1569   1569       sqlite3_int64 iBest = 0;
  1570   1570   
  1571   1571       float fMinGrowth = 0.0;
  1572   1572       float fMinArea = 0.0;
  1573   1573   #if VARIANT_RSTARTREE_CHOOSESUBTREE
  1574   1574       float fMinOverlap = 0.0;
         1575  +    float overlap;
  1575   1576   #endif
  1576   1577   
  1577   1578       int nCell = NCELL(pNode);
  1578   1579       RtreeCell cell;
  1579   1580       RtreeNode *pChild;
  1580   1581   
  1581   1582       RtreeCell *aCell = 0;
................................................................................
  1600   1601       ** is inserted into it. Resolve ties by choosing the entry with
  1601   1602       ** the smallest area.
  1602   1603       */
  1603   1604       for(iCell=0; iCell<nCell; iCell++){
  1604   1605         int bBest = 0;
  1605   1606         float growth;
  1606   1607         float area;
  1607         -      float overlap = 0.0;
  1608   1608         nodeGetCell(pRtree, pNode, iCell, &cell);
  1609   1609         growth = cellGrowth(pRtree, &cell, pCell);
  1610   1610         area = cellArea(pRtree, &cell);
  1611   1611   
  1612   1612   #if VARIANT_RSTARTREE_CHOOSESUBTREE
  1613   1613         if( ii==(pRtree->iDepth-1) ){
  1614   1614           overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell);
         1615  +      }else{
         1616  +        overlap = 0.0;
  1615   1617         }
  1616   1618         if( (iCell==0) 
  1617   1619          || (overlap<fMinOverlap) 
  1618   1620          || (overlap==fMinOverlap && growth<fMinGrowth)
  1619   1621          || (overlap==fMinOverlap && growth==fMinGrowth && area<fMinArea)
  1620   1622         ){
  1621   1623           bBest = 1;

Changes to src/backup.c.

   539    539   }
   540    540   
   541    541   /*
   542    542   ** Release all resources associated with an sqlite3_backup* handle.
   543    543   */
   544    544   int sqlite3_backup_finish(sqlite3_backup *p){
   545    545     sqlite3_backup **pp;                 /* Ptr to head of pagers backup list */
   546         -  sqlite3_mutex *mutex;                /* Mutex to protect source database */
          546  +  MUTEX_LOGIC( sqlite3_mutex *mutex; ) /* Mutex to protect source database */
   547    547     int rc;                              /* Value to return */
   548    548   
   549    549     /* Enter the mutexes */
   550    550     if( p==0 ) return SQLITE_OK;
   551    551     sqlite3_mutex_enter(p->pSrcDb->mutex);
   552    552     sqlite3BtreeEnter(p->pSrc);
   553         -  mutex = p->pSrcDb->mutex;
          553  +  MUTEX_LOGIC( mutex = p->pSrcDb->mutex; )
   554    554     if( p->pDestDb ){
   555    555       sqlite3_mutex_enter(p->pDestDb->mutex);
   556    556     }
   557    557   
   558    558     /* Detach this backup from the source pager. */
   559    559     if( p->pDestDb ){
   560    560       p->pSrc->nBackup--;

Changes to src/btree.c.

  1762   1762     ** If this Btree is a candidate for shared cache, try to find an
  1763   1763     ** existing BtShared object that we can share with
  1764   1764     */
  1765   1765     if( isMemdb==0 && isTempDb==0 ){
  1766   1766       if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
  1767   1767         int nFullPathname = pVfs->mxPathname+1;
  1768   1768         char *zFullPathname = sqlite3Malloc(nFullPathname);
  1769         -      sqlite3_mutex *mutexShared;
         1769  +      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
  1770   1770         p->sharable = 1;
  1771   1771         if( !zFullPathname ){
  1772   1772           sqlite3_free(p);
  1773   1773           return SQLITE_NOMEM;
  1774   1774         }
  1775   1775         sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname);
         1776  +#if SQLITE_THREADSAFE
  1776   1777         mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN);
  1777   1778         sqlite3_mutex_enter(mutexOpen);
  1778   1779         mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
  1779   1780         sqlite3_mutex_enter(mutexShared);
         1781  +#endif
  1780   1782         for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){
  1781   1783           assert( pBt->nRef>0 );
  1782   1784           if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager))
  1783   1785                    && sqlite3PagerVfs(pBt->pPager)==pVfs ){
  1784   1786             int iDb;
  1785   1787             for(iDb=db->nDb-1; iDb>=0; iDb--){
  1786   1788               Btree *pExisting = db->aDb[iDb].pBt;
................................................................................
  1878   1880       pBt->usableSize = pBt->pageSize - nReserve;
  1879   1881       assert( (pBt->pageSize & 7)==0 );  /* 8-byte alignment of pageSize */
  1880   1882      
  1881   1883   #if !defined(SQLITE_OMIT_SHARED_CACHE) && !defined(SQLITE_OMIT_DISKIO)
  1882   1884       /* Add the new BtShared object to the linked list sharable BtShareds.
  1883   1885       */
  1884   1886       if( p->sharable ){
  1885         -      sqlite3_mutex *mutexShared;
         1887  +      MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
  1886   1888         pBt->nRef = 1;
  1887         -      mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
         1889  +      MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);)
  1888   1890         if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){
  1889   1891           pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST);
  1890   1892           if( pBt->mutex==0 ){
  1891   1893             rc = SQLITE_NOMEM;
  1892   1894             db->mallocFailed = 0;
  1893   1895             goto btree_open_out;
  1894   1896           }
................................................................................
  1962   1964   ** Decrement the BtShared.nRef counter.  When it reaches zero,
  1963   1965   ** remove the BtShared structure from the sharing list.  Return
  1964   1966   ** true if the BtShared.nRef counter reaches zero and return
  1965   1967   ** false if it is still positive.
  1966   1968   */
  1967   1969   static int removeFromSharingList(BtShared *pBt){
  1968   1970   #ifndef SQLITE_OMIT_SHARED_CACHE
  1969         -  sqlite3_mutex *pMaster;
         1971  +  MUTEX_LOGIC( sqlite3_mutex *pMaster; )
  1970   1972     BtShared *pList;
  1971   1973     int removed = 0;
  1972   1974   
  1973   1975     assert( sqlite3_mutex_notheld(pBt->mutex) );
  1974         -  pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
         1976  +  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
  1975   1977     sqlite3_mutex_enter(pMaster);
  1976   1978     pBt->nRef--;
  1977   1979     if( pBt->nRef<=0 ){
  1978   1980       if( GLOBAL(BtShared*,sqlite3SharedCacheList)==pBt ){
  1979   1981         GLOBAL(BtShared*,sqlite3SharedCacheList) = pBt->pNext;
  1980   1982       }else{
  1981   1983         pList = GLOBAL(BtShared*,sqlite3SharedCacheList);

Changes to src/lempar.c.

   712    712     void *yyp,                   /* The parser */
   713    713     int yymajor,                 /* The major token code number */
   714    714     ParseTOKENTYPE yyminor       /* The value for the token */
   715    715     ParseARG_PDECL               /* Optional %extra_argument parameter */
   716    716   ){
   717    717     YYMINORTYPE yyminorunion;
   718    718     int yyact;            /* The parser action. */
          719  +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
   719    720     int yyendofinput;     /* True if we are at the end of input */
          721  +#endif
   720    722   #ifdef YYERRORSYMBOL
   721    723     int yyerrorhit = 0;   /* True if yymajor has invoked an error */
   722    724   #endif
   723    725     yyParser *yypParser;  /* The parser */
   724    726   
   725    727     /* (re)initialize the parser, if necessary */
   726    728     yypParser = (yyParser*)yyp;
................................................................................
   735    737   #endif
   736    738       yypParser->yyidx = 0;
   737    739       yypParser->yyerrcnt = -1;
   738    740       yypParser->yystack[0].stateno = 0;
   739    741       yypParser->yystack[0].major = 0;
   740    742     }
   741    743     yyminorunion.yy0 = yyminor;
          744  +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY)
   742    745     yyendofinput = (yymajor==0);
          746  +#endif
   743    747     ParseARG_STORE;
   744    748   
   745    749   #ifndef NDEBUG
   746    750     if( yyTraceFILE ){
   747    751       fprintf(yyTraceFILE,"%sInput %s\n",yyTracePrompt,yyTokenName[yymajor]);
   748    752     }
   749    753   #endif
   750    754   
   751    755     do{
   752    756       yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor);
   753    757       if( yyact<YYNSTATE ){
   754         -      assert( !yyendofinput );  /* Impossible to shift the $ token */
   755    758         yy_shift(yypParser,yyact,yymajor,&yyminorunion);
   756    759         yypParser->yyerrcnt--;
   757    760         yymajor = YYNOCODE;
   758    761       }else if( yyact < YYNSTATE + YYNRULE ){
   759    762         yy_reduce(yypParser,yyact-YYNSTATE);
   760    763       }else{
   761    764         assert( yyact == YY_ERROR_ACTION );

Changes to src/main.c.

   102    102   **    *  Calls to this routine from Y must block until the outer-most
   103    103   **       call by X completes.
   104    104   **
   105    105   **    *  Recursive calls to this routine from thread X return immediately
   106    106   **       without blocking.
   107    107   */
   108    108   int sqlite3_initialize(void){
   109         -  sqlite3_mutex *pMaster;                      /* The main static mutex */
          109  +  MUTEX_LOGIC( sqlite3_mutex *pMaster; )       /* The main static mutex */
   110    110     int rc;                                      /* Result code */
   111    111   
   112    112   #ifdef SQLITE_OMIT_WSD
   113    113     rc = sqlite3_wsd_init(4096, 24);
   114    114     if( rc!=SQLITE_OK ){
   115    115       return rc;
   116    116     }
................................................................................
   136    136   
   137    137     /* Initialize the malloc() system and the recursive pInitMutex mutex.
   138    138     ** This operation is protected by the STATIC_MASTER mutex.  Note that
   139    139     ** MutexAlloc() is called for a static mutex prior to initializing the
   140    140     ** malloc subsystem - this implies that the allocation of a static
   141    141     ** mutex must not require support from the malloc subsystem.
   142    142     */
   143         -  pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
          143  +  MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
   144    144     sqlite3_mutex_enter(pMaster);
   145    145     sqlite3GlobalConfig.isMutexInit = 1;
   146    146     if( !sqlite3GlobalConfig.isMallocInit ){
   147    147       rc = sqlite3MallocInit();
   148    148     }
   149    149     if( rc==SQLITE_OK ){
   150    150       sqlite3GlobalConfig.isMallocInit = 1;

Changes to src/mutex.h.

    56     56   
    57     57   #ifdef SQLITE_MUTEX_OMIT
    58     58   /*
    59     59   ** If this is a no-op implementation, implement everything as macros.
    60     60   */
    61     61   #define sqlite3_mutex_alloc(X)    ((sqlite3_mutex*)8)
    62     62   #define sqlite3_mutex_free(X)
    63         -#define sqlite3_mutex_enter(X)
           63  +#define sqlite3_mutex_enter(X)    
    64     64   #define sqlite3_mutex_try(X)      SQLITE_OK
    65         -#define sqlite3_mutex_leave(X)
           65  +#define sqlite3_mutex_leave(X)    
    66     66   #define sqlite3_mutex_held(X)     ((void)(X),1)
    67     67   #define sqlite3_mutex_notheld(X)  ((void)(X),1)
    68     68   #define sqlite3MutexAlloc(X)      ((sqlite3_mutex*)8)
    69     69   #define sqlite3MutexInit()        SQLITE_OK
    70     70   #define sqlite3MutexEnd()
           71  +#define MUTEX_LOGIC(X)
           72  +#else
           73  +#define MUTEX_LOGIC(X)            X
    71     74   #endif /* defined(SQLITE_MUTEX_OMIT) */

Changes to src/os.c.

   293    293   
   294    294   /*
   295    295   ** Register a VFS with the system.  It is harmless to register the same
   296    296   ** VFS multiple times.  The new VFS becomes the default if makeDflt is
   297    297   ** true.
   298    298   */
   299    299   int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
   300         -  sqlite3_mutex *mutex = 0;
          300  +  MUTEX_LOGIC(sqlite3_mutex *mutex;)
   301    301   #ifndef SQLITE_OMIT_AUTOINIT
   302    302     int rc = sqlite3_initialize();
   303    303     if( rc ) return rc;
   304    304   #endif
   305         -  mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
          305  +  MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); )
   306    306     sqlite3_mutex_enter(mutex);
   307    307     vfsUnlink(pVfs);
   308    308     if( makeDflt || vfsList==0 ){
   309    309       pVfs->pNext = vfsList;
   310    310       vfsList = pVfs;
   311    311     }else{
   312    312       pVfs->pNext = vfsList->pNext;

Changes to src/os_unix.c.

   524    524   #ifdef SQLITE_DEBUG
   525    525   static int unixMutexHeld(void) {
   526    526     return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
   527    527   }
   528    528   #endif
   529    529   
   530    530   
   531         -#ifdef SQLITE_DEBUG
          531  +#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
   532    532   /*
   533    533   ** Helper function for printing out trace information from debugging
   534    534   ** binaries. This returns the string represetation of the supplied
   535    535   ** integer lock-type.
   536    536   */
   537    537   static const char *azFileLock(int eFileLock){
   538    538     switch( eFileLock ){

Changes to src/where.c.

  2472   2472     double r, rS;
  2473   2473   
  2474   2474     assert( roundUp==0 || roundUp==1 );
  2475   2475     assert( pIdx->nSample>0 );
  2476   2476     if( pVal==0 ) return SQLITE_ERROR;
  2477   2477     n = pIdx->aiRowEst[0];
  2478   2478     aSample = pIdx->aSample;
  2479         -  i = 0;
  2480   2479     eType = sqlite3_value_type(pVal);
  2481   2480   
  2482   2481     if( eType==SQLITE_INTEGER ){
  2483   2482       v = sqlite3_value_int64(pVal);
  2484   2483       r = (i64)v;
  2485   2484       for(i=0; i<pIdx->nSample; i++){
  2486   2485         if( aSample[i].eType==SQLITE_NULL ) continue;

Changes to test/tkt3793.test.

    96     96   # connection that called sqlite3_step()). When bug #3793 existed, sometimes
    97     97   # the [db2] busy-handler was invoked from within the call to sqlite3_step()
    98     98   # associated with [db1]. 
    99     99   #
   100    100   # Note: Before the bug was fixed, if [db2] was opened with the "-fullmutex 1"
   101    101   # option, then this test case would cause an assert() to fail.
   102    102   #
   103         -set ::busyconnection db1
   104         -db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} {
   105         -  do_test tkt3793-2.[incr x] { set ::busyconnection } db1
   106         -  set ::busyconnection db2
   107         -
   108         -  db2 eval { SELECT count(*) FROM t2 }
   109         -  do_test tkt3793-2.[incr x] { set ::busyconnection } db2
          103  +ifcapable threadsafe {
   110    104     set ::busyconnection db1
          105  +  db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} {
          106  +    do_test tkt3793-2.[incr x] { set ::busyconnection } db1
          107  +    set ::busyconnection db2
          108  +  
          109  +    db2 eval { SELECT count(*) FROM t2 }
          110  +    do_test tkt3793-2.[incr x] { set ::busyconnection } db2
          111  +    set ::busyconnection db1
          112  +  }
   111    113   }
   112         -
          114  +  
   113    115   do_test tkt3793-3 {
   114    116     db1 close
   115    117     db2 close
   116    118   } {}
   117    119   
   118    120   sqlite3_enable_shared_cache $::enable_shared_cache
   119    121   finish_test

Added tool/warnings-clang.sh.

            1  +#/bin/sh
            2  +#
            3  +# Run this script in a directory with a working makefile to check for 
            4  +# compiler warnings in SQLite.
            5  +#
            6  +rm -f sqlite3.c
            7  +make sqlite3.c
            8  +echo '************* FTS4 and RTREE ****************'
            9  +scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \
           10  +      -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:'
           11  +echo '********** ENABLE_STAT3. THREADSAFE=0 *******'
           12  +scan-build gcc -c -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \
           13  +      -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:'