/ Check-in [892e644d]
Login

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

Overview
Comment:Fix uninitialized variable in os_unix.c. (CVS 3006)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:892e644d20b9d132cf29242a9bca0116ebe6968f
User & Date: drh 2006-01-23 16:24:54
Context
2006-01-23
16:25
Get I/O error tests working on windows. (CVS 3007) check-in: 2ef8b85d user: drh tags: trunk
16:24
Fix uninitialized variable in os_unix.c. (CVS 3006) check-in: 892e644d user: drh tags: trunk
16:21
Add "#ifndef NDEBUG" around sqlite3pager_iswriteable() (only used in assert() expressions). Also set the internal page number of a page to zero if it fails to initialise. (CVS 3005) check-in: 77969c67 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

   689    689     int *pReadonly
   690    690   ){
   691    691     int rc;
   692    692     unixFile f;
   693    693   
   694    694     CRASH_TEST_OVERRIDE(sqlite3CrashOpenReadWrite, zFilename, pId, pReadonly);
   695    695     assert( 0==*pId );
   696         -  f.dirfd = -1;
   697         -  SET_THREADID(&f);
   698    696     f.h = open(zFilename, O_RDWR|O_CREAT|O_LARGEFILE|O_BINARY,
   699    697                             SQLITE_DEFAULT_FILE_PERMISSIONS);
   700    698     if( f.h<0 ){
   701    699   #ifdef EISDIR
   702    700       if( errno==EISDIR ){
   703    701         return SQLITE_CANTOPEN;
   704    702       }
................................................................................
   714    712     sqlite3OsEnterMutex();
   715    713     rc = findLockInfo(f.h, &f.pLock, &f.pOpen);
   716    714     sqlite3OsLeaveMutex();
   717    715     if( rc ){
   718    716       close(f.h);
   719    717       return SQLITE_NOMEM;
   720    718     }
   721         -  f.locktype = 0;
   722    719     TRACE3("OPEN    %-3d %s\n", f.h, zFilename);
   723    720     return allocateUnixFile(&f, pId);
   724    721   }
   725    722   
   726    723   
   727    724   /*
   728    725   ** Attempt to open a new file for exclusive access by this process.
................................................................................
   743    740     unixFile f;
   744    741   
   745    742     CRASH_TEST_OVERRIDE(sqlite3CrashOpenExclusive, zFilename, pId, delFlag);
   746    743     assert( 0==*pId );
   747    744     if( access(zFilename, 0)==0 ){
   748    745       return SQLITE_CANTOPEN;
   749    746     }
   750         -  SET_THREADID(&f);
   751         -  f.dirfd = -1;
   752    747     f.h = open(zFilename,
   753    748                   O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_LARGEFILE|O_BINARY,
   754    749                   SQLITE_DEFAULT_FILE_PERMISSIONS);
   755    750     if( f.h<0 ){
   756    751       return SQLITE_CANTOPEN;
   757    752     }
   758    753     sqlite3OsEnterMutex();
................................................................................
   759    754     rc = findLockInfo(f.h, &f.pLock, &f.pOpen);
   760    755     sqlite3OsLeaveMutex();
   761    756     if( rc ){
   762    757       close(f.h);
   763    758       unlink(zFilename);
   764    759       return SQLITE_NOMEM;
   765    760     }
   766         -  f.locktype = 0;
   767    761     if( delFlag ){
   768    762       unlink(zFilename);
   769    763     }
   770    764     TRACE3("OPEN-EX %-3d %s\n", f.h, zFilename);
   771    765     return allocateUnixFile(&f, pId);
   772    766   }
   773    767   
................................................................................
   780    774   */
   781    775   int sqlite3UnixOpenReadOnly(const char *zFilename, OsFile **pId){
   782    776     int rc;
   783    777     unixFile f;
   784    778   
   785    779     CRASH_TEST_OVERRIDE(sqlite3CrashOpenReadOnly, zFilename, pId, 0);
   786    780     assert( 0==*pId );
   787         -  SET_THREADID(&f);
   788         -  f.dirfd = -1;
   789    781     f.h = open(zFilename, O_RDONLY|O_LARGEFILE|O_BINARY);
   790    782     if( f.h<0 ){
   791    783       return SQLITE_CANTOPEN;
   792    784     }
   793    785     sqlite3OsEnterMutex();
   794    786     rc = findLockInfo(f.h, &f.pLock, &f.pOpen);
   795    787     sqlite3OsLeaveMutex();
   796    788     if( rc ){
   797    789       close(f.h);
   798    790       return SQLITE_NOMEM;
   799    791     }
   800         -  f.locktype = 0;
   801    792     TRACE3("OPEN-RO %-3d %s\n", f.h, zFilename);
   802         -
   803    793     return allocateUnixFile(&f, pId);
   804    794   }
   805    795   
   806    796   /*
   807    797   ** Attempt to open a file descriptor for the directory that contains a
   808    798   ** file.  This file descriptor can be used to fsync() the directory
   809    799   ** in order to make sure the creation of a new file is actually written
................................................................................
  1579   1569   /*
  1580   1570   ** Allocate memory for a unixFile.  Initialize the new unixFile
  1581   1571   ** to the value given in pInit and return a pointer to the new
  1582   1572   ** OsFile.  If we run out of memory, close the file and return NULL.
  1583   1573   */
  1584   1574   static int allocateUnixFile(unixFile *pInit, OsFile **pId){
  1585   1575     unixFile *pNew;
         1576  +  pInit->dirfd = -1;
         1577  +  pInit->fullSync = 0;
         1578  +  pInit->locktype = 0;
         1579  +  SET_THREADID(pInit);
  1586   1580     pNew = sqliteMalloc( sizeof(unixFile) );
  1587   1581     if( pNew==0 ){
  1588   1582       close(pInit->h);
  1589   1583       sqlite3OsEnterMutex();
  1590   1584       releaseLockInfo(pInit->pLock);
  1591   1585       releaseOpenCnt(pInit->pOpen);
  1592   1586       sqlite3OsLeaveMutex();