mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Fixes for harmless static-analyzer warnings. This also makes the code easier
for humans to understand. FossilOrigin-Name: 36177a62feeb4fa93ab6e3c6f4dbe1ddcf63bb02f93284abab979da0261b218e
This commit is contained in:
@ -562,6 +562,7 @@ int sqlite3Fts5ConfigParse(
|
||||
z = fts5ConfigSkipWhitespace(z);
|
||||
if( z && *z=='=' ){
|
||||
bOption = 1;
|
||||
assert( zOne!=0 );
|
||||
z++;
|
||||
if( bMustBeCol ) z = 0;
|
||||
}
|
||||
@ -578,7 +579,11 @@ int sqlite3Fts5ConfigParse(
|
||||
rc = SQLITE_ERROR;
|
||||
}else{
|
||||
if( bOption ){
|
||||
rc = fts5ConfigParseSpecial(pGlobal, pRet, zOne, zTwo?zTwo:"", pzErr);
|
||||
rc = fts5ConfigParseSpecial(pGlobal, pRet,
|
||||
ALWAYS(zOne)?zOne:"",
|
||||
zTwo?zTwo:"",
|
||||
pzErr
|
||||
);
|
||||
}else{
|
||||
rc = fts5ConfigParseColumn(pRet, zOne, zTwo, pzErr);
|
||||
zOne = 0;
|
||||
|
@ -1875,7 +1875,7 @@ int sqlite3Fts5ExprClonePhrase(
|
||||
sCtx.pPhrase = sqlite3Fts5MallocZero(&rc, sizeof(Fts5ExprPhrase));
|
||||
}
|
||||
|
||||
if( rc==SQLITE_OK ){
|
||||
if( rc==SQLITE_OK && ALWAYS(sCtx.pPhrase) ){
|
||||
/* All the allocations succeeded. Put the expression object together. */
|
||||
pNew->pIndex = pExpr->pIndex;
|
||||
pNew->pConfig = pExpr->pConfig;
|
||||
|
@ -3390,6 +3390,7 @@ static void fts5IterSetOutputs_Full(Fts5Iter *pIter, Fts5SegIter *pSeg){
|
||||
}
|
||||
|
||||
static void fts5IterSetOutputCb(int *pRc, Fts5Iter *pIter){
|
||||
assert( pIter!=0 || (*pRc)!=SQLITE_OK );
|
||||
if( *pRc==SQLITE_OK ){
|
||||
Fts5Config *pConfig = pIter->pIndex->pConfig;
|
||||
if( pConfig->eDetail==FTS5_DETAIL_NONE ){
|
||||
@ -3461,7 +3462,10 @@ static void fts5MultiIterNew(
|
||||
}
|
||||
}
|
||||
*ppOut = pNew = fts5MultiIterAlloc(p, nSeg);
|
||||
if( pNew==0 ) return;
|
||||
if( pNew==0 ){
|
||||
assert( p->rc!=SQLITE_OK );
|
||||
goto fts5MultiIterNew_post_check;
|
||||
}
|
||||
pNew->bRev = (0!=(flags & FTS5INDEX_QUERY_DESC));
|
||||
pNew->bSkipEmpty = (0!=(flags & FTS5INDEX_QUERY_SKIPEMPTY));
|
||||
pNew->pColset = pColset;
|
||||
@ -3525,6 +3529,10 @@ static void fts5MultiIterNew(
|
||||
fts5MultiIterFree(pNew);
|
||||
*ppOut = 0;
|
||||
}
|
||||
|
||||
fts5MultiIterNew_post_check:
|
||||
assert( (*ppOut)!=0 || p->rc!=SQLITE_OK );
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -6203,6 +6211,7 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum){
|
||||
Fts5Buffer poslist = {0,0,0}; /* Buffer used to hold a poslist */
|
||||
Fts5Iter *pIter; /* Used to iterate through entire index */
|
||||
Fts5Structure *pStruct; /* Index structure */
|
||||
int iLvl, iSeg;
|
||||
|
||||
#ifdef SQLITE_DEBUG
|
||||
/* Used by extra internal tests only run if NDEBUG is not defined */
|
||||
@ -6213,15 +6222,16 @@ int sqlite3Fts5IndexIntegrityCheck(Fts5Index *p, u64 cksum, int bUseCksum){
|
||||
|
||||
/* Load the FTS index structure */
|
||||
pStruct = fts5StructureRead(p);
|
||||
if( pStruct==0 ){
|
||||
assert( p->rc!=SQLITE_OK );
|
||||
return fts5IndexReturn(p);
|
||||
}
|
||||
|
||||
/* Check that the internal nodes of each segment match the leaves */
|
||||
if( pStruct ){
|
||||
int iLvl, iSeg;
|
||||
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
|
||||
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
|
||||
Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
|
||||
fts5IndexIntegrityCheckSegment(p, pSeg);
|
||||
}
|
||||
for(iLvl=0; iLvl<pStruct->nLevel; iLvl++){
|
||||
for(iSeg=0; iSeg<pStruct->aLevel[iLvl].nSeg; iSeg++){
|
||||
Fts5StructureSegment *pSeg = &pStruct->aLevel[iLvl].aSeg[iSeg];
|
||||
fts5IndexIntegrityCheckSegment(p, pSeg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1058,8 +1058,9 @@ int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){
|
||||
|
||||
assert( p->pConfig->bColumnsize );
|
||||
rc = fts5StorageGetStmt(p, FTS5_STMT_LOOKUP_DOCSIZE, &pLookup, 0);
|
||||
if( rc==SQLITE_OK ){
|
||||
if( pLookup ){
|
||||
int bCorrupt = 1;
|
||||
assert( rc==SQLITE_OK );
|
||||
sqlite3_bind_int64(pLookup, 1, iRowid);
|
||||
if( SQLITE_ROW==sqlite3_step(pLookup) ){
|
||||
const u8 *aBlob = sqlite3_column_blob(pLookup, 0);
|
||||
@ -1072,6 +1073,8 @@ int sqlite3Fts5StorageDocsize(Fts5Storage *p, i64 iRowid, int *aCol){
|
||||
if( bCorrupt && rc==SQLITE_OK ){
|
||||
rc = FTS5_CORRUPT;
|
||||
}
|
||||
}else{
|
||||
assert( rc!=SQLITE_OK );
|
||||
}
|
||||
|
||||
return rc;
|
||||
|
@ -1387,6 +1387,7 @@ static int geopolyFilter(
|
||||
RtreeCoord bbox[4];
|
||||
RtreeConstraint *p;
|
||||
assert( argc==1 );
|
||||
assert( argv[0]!=0 );
|
||||
geopolyBBox(0, argv[0], bbox, &rc);
|
||||
if( rc ){
|
||||
goto geopoly_filter_end;
|
||||
@ -1614,6 +1615,7 @@ static int geopolyUpdate(
|
||||
|| !sqlite3_value_nochange(aData[2]) /* UPDATE _shape */
|
||||
|| oldRowid!=newRowid) /* Rowid change */
|
||||
){
|
||||
assert( aData[2]!=0 );
|
||||
geopolyBBox(0, aData[2], cell.aCoord, &rc);
|
||||
if( rc ){
|
||||
if( rc==SQLITE_ERROR ){
|
||||
|
@ -1025,16 +1025,32 @@ static int sessionTableInfo(
|
||||
}else if( rc==SQLITE_ERROR ){
|
||||
zPragma = sqlite3_mprintf("");
|
||||
}else{
|
||||
*pazCol = 0;
|
||||
*pabPK = 0;
|
||||
*pnCol = 0;
|
||||
if( pzTab ) *pzTab = 0;
|
||||
return rc;
|
||||
}
|
||||
}else{
|
||||
zPragma = sqlite3_mprintf("PRAGMA '%q'.table_info('%q')", zDb, zThis);
|
||||
}
|
||||
if( !zPragma ) return SQLITE_NOMEM;
|
||||
if( !zPragma ){
|
||||
*pazCol = 0;
|
||||
*pabPK = 0;
|
||||
*pnCol = 0;
|
||||
if( pzTab ) *pzTab = 0;
|
||||
return SQLITE_NOMEM;
|
||||
}
|
||||
|
||||
rc = sqlite3_prepare_v2(db, zPragma, -1, &pStmt, 0);
|
||||
sqlite3_free(zPragma);
|
||||
if( rc!=SQLITE_OK ) return rc;
|
||||
if( rc!=SQLITE_OK ){
|
||||
*pazCol = 0;
|
||||
*pabPK = 0;
|
||||
*pnCol = 0;
|
||||
if( pzTab ) *pzTab = 0;
|
||||
return rc;
|
||||
}
|
||||
|
||||
nByte = nThis + 1;
|
||||
while( SQLITE_ROW==sqlite3_step(pStmt) ){
|
||||
@ -1452,7 +1468,11 @@ static int sessionFindTable(
|
||||
){
|
||||
rc = sqlite3session_attach(pSession, zName);
|
||||
if( rc==SQLITE_OK ){
|
||||
for(pRet=pSession->pTable; pRet->pNext; pRet=pRet->pNext);
|
||||
pRet = pSession->pTable;
|
||||
while( ALWAYS(pRet) && pRet->pNext ){
|
||||
pRet = pRet->pNext;
|
||||
}
|
||||
assert( pRet!=0 );
|
||||
assert( 0==sqlite3_strnicmp(pRet->zName, zName, nName+1) );
|
||||
}
|
||||
}
|
||||
@ -2225,6 +2245,7 @@ static int sessionAppendUpdate(
|
||||
int i; /* Used to iterate through columns */
|
||||
u8 *pCsr = p->aRecord; /* Used to iterate through old.* values */
|
||||
|
||||
assert( abPK!=0 );
|
||||
sessionAppendByte(pBuf, SQLITE_UPDATE, &rc);
|
||||
sessionAppendByte(pBuf, p->bIndirect, &rc);
|
||||
for(i=0; i<sqlite3_column_count(pStmt); i++){
|
||||
@ -2529,12 +2550,14 @@ static int sessionGenerateChangeset(
|
||||
SessionBuffer buf = {0,0,0}; /* Buffer in which to accumlate changeset */
|
||||
int rc; /* Return code */
|
||||
|
||||
assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0 ) );
|
||||
assert( xOutput==0 || (pnChangeset==0 && ppChangeset==0) );
|
||||
assert( xOutput!=0 || (pnChangeset!=0 && ppChangeset!=0) );
|
||||
|
||||
/* Zero the output variables in case an error occurs. If this session
|
||||
** object is already in the error state (sqlite3_session.rc != SQLITE_OK),
|
||||
** this call will be a no-op. */
|
||||
if( xOutput==0 ){
|
||||
assert( pnChangeset!=0 && ppChangeset!=0 );
|
||||
*pnChangeset = 0;
|
||||
*ppChangeset = 0;
|
||||
}
|
||||
@ -2548,8 +2571,8 @@ static int sessionGenerateChangeset(
|
||||
for(pTab=pSession->pTable; rc==SQLITE_OK && pTab; pTab=pTab->pNext){
|
||||
if( pTab->nEntry ){
|
||||
const char *zName = pTab->zName;
|
||||
int nCol; /* Number of columns in table */
|
||||
u8 *abPK; /* Primary key array */
|
||||
int nCol = 0; /* Number of columns in table */
|
||||
u8 *abPK = 0; /* Primary key array */
|
||||
const char **azCol = 0; /* Table columns */
|
||||
int i; /* Used to iterate through hash buckets */
|
||||
sqlite3_stmt *pSel = 0; /* SELECT statement to query table pTab */
|
||||
@ -2587,6 +2610,7 @@ static int sessionGenerateChangeset(
|
||||
sessionAppendCol(&buf, pSel, iCol, &rc);
|
||||
}
|
||||
}else{
|
||||
assert( abPK!=0 ); /* Because sessionSelectStmt() returned ok */
|
||||
rc = sessionAppendUpdate(&buf, bPatchset, pSel, p, abPK);
|
||||
}
|
||||
}else if( p->op!=SQLITE_INSERT ){
|
||||
@ -2647,7 +2671,10 @@ int sqlite3session_changeset(
|
||||
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
||||
void **ppChangeset /* OUT: Buffer containing changeset */
|
||||
){
|
||||
int rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
|
||||
int rc;
|
||||
|
||||
if( pnChangeset==0 || ppChangeset==0 ) return SQLITE_MISUSE;
|
||||
rc = sessionGenerateChangeset(pSession, 0, 0, 0, pnChangeset,ppChangeset);
|
||||
assert( rc || pnChangeset==0
|
||||
|| pSession->bEnableSize==0 || *pnChangeset<=pSession->nMaxChangesetSize
|
||||
);
|
||||
@ -2662,6 +2689,7 @@ int sqlite3session_changeset_strm(
|
||||
int (*xOutput)(void *pOut, const void *pData, int nData),
|
||||
void *pOut
|
||||
){
|
||||
if( xOutput==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 0, xOutput, pOut, 0, 0);
|
||||
}
|
||||
|
||||
@ -2673,6 +2701,7 @@ int sqlite3session_patchset_strm(
|
||||
int (*xOutput)(void *pOut, const void *pData, int nData),
|
||||
void *pOut
|
||||
){
|
||||
if( xOutput==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 1, xOutput, pOut, 0, 0);
|
||||
}
|
||||
|
||||
@ -2688,6 +2717,7 @@ int sqlite3session_patchset(
|
||||
int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
|
||||
void **ppPatchset /* OUT: Buffer containing changeset */
|
||||
){
|
||||
if( pnPatchset==0 || ppPatchset==0 ) return SQLITE_MISUSE;
|
||||
return sessionGenerateChangeset(pSession, 1, 0, 0, pnPatchset, ppPatchset);
|
||||
}
|
||||
|
||||
@ -5254,9 +5284,9 @@ static int sessionChangegroupOutput(
|
||||
if( rc==SQLITE_OK ){
|
||||
if( xOutput ){
|
||||
if( buf.nBuf>0 ) rc = xOutput(pOut, buf.aBuf, buf.nBuf);
|
||||
}else{
|
||||
}else if( ppOut ){
|
||||
*ppOut = buf.aBuf;
|
||||
*pnOut = buf.nBuf;
|
||||
if( pnOut ) *pnOut = buf.nBuf;
|
||||
buf.aBuf = 0;
|
||||
}
|
||||
}
|
||||
@ -5656,7 +5686,7 @@ static int sessionRebase(
|
||||
if( sOut.nBuf>0 ){
|
||||
rc = xOutput(pOut, sOut.aBuf, sOut.nBuf);
|
||||
}
|
||||
}else{
|
||||
}else if( ppOut ){
|
||||
*ppOut = (void*)sOut.aBuf;
|
||||
*pnOut = sOut.nBuf;
|
||||
sOut.aBuf = 0;
|
||||
|
Reference in New Issue
Block a user