Search code examples
csqlitesyntax-errorcppcheck

For-loop Syntax Error in Sqlite3.c


cppcheck has determined that the following statement produces a syntax error in sqlite3.c:

for(i=0; i<db->nDb; i++){

Full function:

SQLITE_PRIVATE void sqlite3BtreeLeaveAll(sqlite3 *db){
  int i;
  Btree *p;
  assert( sqlite3_mutex_held(db->mutex) );
  for(i=0; i<db->nDb; i++){
    p = db->aDb[i].pBt;
    if( p && p->sharable ){
      assert( p->wantToLock>0 );
      p->wantToLock--;
      if( p->wantToLock==0 ){
        unlockBtreeMutex(p);
      }
    }
  }
 }

I do not see how it is a syntax error. Please explain. Is this a false positive?


Solution

  • Looks like a false positive, however I can't reproduce it using Cppcheck 1.48 and C source code for SQLite 3.7.6.3.

    If you're using different source or a different version, please log it as a bug.