From: drh Date: Sat, 15 Oct 2011 00:16:30 +0000 (+0000) Subject: Added the tool/warnings-clang.sh script. Changes so that there are no X-Git-Tag: version-3.7.9~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=30ddce6ff427a2757cfca3ba1204a16937a6e293;p=thirdparty%2Fsqlite.git 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. FossilOrigin-Name: 39408702a989f907261c298bf0947f3e68bd10fe --- diff --git a/ext/fts3/fts3.c b/ext/fts3/fts3.c index e66e8fe58b..c2047437f0 100644 --- a/ext/fts3/fts3.c +++ b/ext/fts3/fts3.c @@ -4337,9 +4337,10 @@ static int fts3EvalNearTest(Fts3Expr *pExpr, int *pRc){ nToken = pExpr->pRight->pPhrase->nToken; for(p=pExpr->pLeft; p && res; p=p->pLeft){ int nNear; + Fts3Phrase *pPhrase; assert( p->pParent && p->pParent->pLeft==p ); nNear = p->pParent->nNear; - Fts3Phrase *pPhrase = ( + pPhrase = ( p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase ); res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase); diff --git a/ext/rtree/rtree.c b/ext/rtree/rtree.c index 55385d7fd7..884482ea66 100644 --- a/ext/rtree/rtree.c +++ b/ext/rtree/rtree.c @@ -1572,6 +1572,7 @@ static int ChooseLeaf( float fMinArea = 0.0; #if VARIANT_RSTARTREE_CHOOSESUBTREE float fMinOverlap = 0.0; + float overlap; #endif int nCell = NCELL(pNode); @@ -1604,7 +1605,6 @@ static int ChooseLeaf( int bBest = 0; float growth; float area; - float overlap = 0.0; nodeGetCell(pRtree, pNode, iCell, &cell); growth = cellGrowth(pRtree, &cell, pCell); area = cellArea(pRtree, &cell); @@ -1612,6 +1612,8 @@ static int ChooseLeaf( #if VARIANT_RSTARTREE_CHOOSESUBTREE if( ii==(pRtree->iDepth-1) ){ overlap = cellOverlapEnlargement(pRtree,&cell,pCell,aCell,nCell,iCell); + }else{ + overlap = 0.0; } if( (iCell==0) || (overlappSrcDb->mutex); sqlite3BtreeEnter(p->pSrc); - mutex = p->pSrcDb->mutex; + MUTEX_LOGIC( mutex = p->pSrcDb->mutex; ) if( p->pDestDb ){ sqlite3_mutex_enter(p->pDestDb->mutex); } diff --git a/src/btree.c b/src/btree.c index 6c724d0fa3..d64e172f74 100644 --- a/src/btree.c +++ b/src/btree.c @@ -1766,17 +1766,19 @@ int sqlite3BtreeOpen( if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){ int nFullPathname = pVfs->mxPathname+1; char *zFullPathname = sqlite3Malloc(nFullPathname); - sqlite3_mutex *mutexShared; + MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) p->sharable = 1; if( !zFullPathname ){ sqlite3_free(p); return SQLITE_NOMEM; } sqlite3OsFullPathname(pVfs, zFilename, nFullPathname, zFullPathname); +#if SQLITE_THREADSAFE mutexOpen = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_OPEN); sqlite3_mutex_enter(mutexOpen); mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); sqlite3_mutex_enter(mutexShared); +#endif for(pBt=GLOBAL(BtShared*,sqlite3SharedCacheList); pBt; pBt=pBt->pNext){ assert( pBt->nRef>0 ); if( 0==strcmp(zFullPathname, sqlite3PagerFilename(pBt->pPager)) @@ -1882,9 +1884,9 @@ int sqlite3BtreeOpen( /* Add the new BtShared object to the linked list sharable BtShareds. */ if( p->sharable ){ - sqlite3_mutex *mutexShared; + MUTEX_LOGIC( sqlite3_mutex *mutexShared; ) pBt->nRef = 1; - mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( mutexShared = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);) if( SQLITE_THREADSAFE && sqlite3GlobalConfig.bCoreMutex ){ pBt->mutex = sqlite3MutexAlloc(SQLITE_MUTEX_FAST); if( pBt->mutex==0 ){ @@ -1966,12 +1968,12 @@ btree_open_out: */ static int removeFromSharingList(BtShared *pBt){ #ifndef SQLITE_OMIT_SHARED_CACHE - sqlite3_mutex *pMaster; + MUTEX_LOGIC( sqlite3_mutex *pMaster; ) BtShared *pList; int removed = 0; assert( sqlite3_mutex_notheld(pBt->mutex) ); - pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(pMaster); pBt->nRef--; if( pBt->nRef<=0 ){ diff --git a/src/lempar.c b/src/lempar.c index fb52490e4c..cb6025e87b 100644 --- a/src/lempar.c +++ b/src/lempar.c @@ -716,7 +716,9 @@ void Parse( ){ YYMINORTYPE yyminorunion; int yyact; /* The parser action. */ +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) int yyendofinput; /* True if we are at the end of input */ +#endif #ifdef YYERRORSYMBOL int yyerrorhit = 0; /* True if yymajor has invoked an error */ #endif @@ -739,7 +741,9 @@ void Parse( yypParser->yystack[0].major = 0; } yyminorunion.yy0 = yyminor; +#if !defined(YYERRORSYMBOL) && !defined(YYNOERRORRECOVERY) yyendofinput = (yymajor==0); +#endif ParseARG_STORE; #ifndef NDEBUG @@ -751,7 +755,6 @@ void Parse( do{ yyact = yy_find_shift_action(yypParser,(YYCODETYPE)yymajor); if( yyactyyerrcnt--; yymajor = YYNOCODE; diff --git a/src/main.c b/src/main.c index b18217d34a..42bbba5d01 100644 --- a/src/main.c +++ b/src/main.c @@ -106,7 +106,7 @@ char *sqlite3_temp_directory = 0; ** without blocking. */ int sqlite3_initialize(void){ - sqlite3_mutex *pMaster; /* The main static mutex */ + MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */ int rc; /* Result code */ #ifdef SQLITE_OMIT_WSD @@ -140,7 +140,7 @@ int sqlite3_initialize(void){ ** malloc subsystem - this implies that the allocation of a static ** mutex must not require support from the malloc subsystem. */ - pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(pMaster); sqlite3GlobalConfig.isMutexInit = 1; if( !sqlite3GlobalConfig.isMallocInit ){ diff --git a/src/mutex.h b/src/mutex.h index c24f3da4c6..b0e552c7c4 100644 --- a/src/mutex.h +++ b/src/mutex.h @@ -60,12 +60,15 @@ */ #define sqlite3_mutex_alloc(X) ((sqlite3_mutex*)8) #define sqlite3_mutex_free(X) -#define sqlite3_mutex_enter(X) +#define sqlite3_mutex_enter(X) #define sqlite3_mutex_try(X) SQLITE_OK -#define sqlite3_mutex_leave(X) +#define sqlite3_mutex_leave(X) #define sqlite3_mutex_held(X) ((void)(X),1) #define sqlite3_mutex_notheld(X) ((void)(X),1) #define sqlite3MutexAlloc(X) ((sqlite3_mutex*)8) #define sqlite3MutexInit() SQLITE_OK #define sqlite3MutexEnd() +#define MUTEX_LOGIC(X) +#else +#define MUTEX_LOGIC(X) X #endif /* defined(SQLITE_MUTEX_OMIT) */ diff --git a/src/os.c b/src/os.c index 9ca72fa31f..0b13c86e9e 100644 --- a/src/os.c +++ b/src/os.c @@ -297,12 +297,12 @@ static void vfsUnlink(sqlite3_vfs *pVfs){ ** true. */ int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){ - sqlite3_mutex *mutex = 0; + MUTEX_LOGIC(sqlite3_mutex *mutex;) #ifndef SQLITE_OMIT_AUTOINIT int rc = sqlite3_initialize(); if( rc ) return rc; #endif - mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); + MUTEX_LOGIC( mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER); ) sqlite3_mutex_enter(mutex); vfsUnlink(pVfs); if( makeDflt || vfsList==0 ){ diff --git a/src/os_unix.c b/src/os_unix.c index 0236bf7ccb..2e43eabf17 100644 --- a/src/os_unix.c +++ b/src/os_unix.c @@ -528,7 +528,7 @@ static int unixMutexHeld(void) { #endif -#ifdef SQLITE_DEBUG +#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG) /* ** Helper function for printing out trace information from debugging ** binaries. This returns the string represetation of the supplied diff --git a/src/where.c b/src/where.c index f962d6f354..4ea2b3a951 100644 --- a/src/where.c +++ b/src/where.c @@ -2476,7 +2476,6 @@ static int whereKeyStats( if( pVal==0 ) return SQLITE_ERROR; n = pIdx->aiRowEst[0]; aSample = pIdx->aSample; - i = 0; eType = sqlite3_value_type(pVal); if( eType==SQLITE_INTEGER ){ diff --git a/test/tkt3793.test b/test/tkt3793.test index 2b5f2bab39..074aab2df0 100644 --- a/test/tkt3793.test +++ b/test/tkt3793.test @@ -100,16 +100,18 @@ set x 0 # Note: Before the bug was fixed, if [db2] was opened with the "-fullmutex 1" # option, then this test case would cause an assert() to fail. # -set ::busyconnection db1 -db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} { - do_test tkt3793-2.[incr x] { set ::busyconnection } db1 - set ::busyconnection db2 - - db2 eval { SELECT count(*) FROM t2 } - do_test tkt3793-2.[incr x] { set ::busyconnection } db2 +ifcapable threadsafe { set ::busyconnection db1 + db1 eval {SELECT * FROM t2 ORDER BY a LIMIT 20} { + do_test tkt3793-2.[incr x] { set ::busyconnection } db1 + set ::busyconnection db2 + + db2 eval { SELECT count(*) FROM t2 } + do_test tkt3793-2.[incr x] { set ::busyconnection } db2 + set ::busyconnection db1 + } } - + do_test tkt3793-3 { db1 close db2 close diff --git a/tool/warnings-clang.sh b/tool/warnings-clang.sh new file mode 100644 index 0000000000..51084f31a6 --- /dev/null +++ b/tool/warnings-clang.sh @@ -0,0 +1,13 @@ +#/bin/sh +# +# Run this script in a directory with a working makefile to check for +# compiler warnings in SQLite. +# +rm -f sqlite3.c +make sqlite3.c +echo '************* FTS4 and RTREE ****************' +scan-build gcc -c -DHAVE_STDINT_H -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_RTREE \ + -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:' +echo '********** ENABLE_STAT3. THREADSAFE=0 *******' +scan-build gcc -c -DSQLITE_ENABLE_STAT3 -DSQLITE_THREADSAFE=0 \ + -DSQLITE_DEBUG sqlite3.c 2>&1 | grep -v 'ANALYZE:'