Hi,
my C skills are not the very best, but GCC reports some warnings when
compiling 3.6.10 (amalgamation) and I guess GCC is right:
if( unlink(zLockFile) )
{
int rc, tErrno = errno;
if( ENOENT != tErrno )
{
rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
}
if( IS_LOCK_ERROR(rc) ){
pFile->lastErrno = tErrno;
}
return rc;
}
The value of "rc" is undefined if unlink() returnes ENOENT (this could
happen I think). I guess removing the if() around
sqliteErrorFromPosixError is the right fix.
The other two warnings are harmless I think.
GCC complains that "pLock" may be used uninitialized in function
findLockInfo. I guess this could not happen, but coding a simple "else"
to the "if( ppLock!=0 ){" that sets pLock to NULL would not hurt.
Also, GCC complains that iKey might be used uninitialized in function
sqlite3VdbeExec (around line 52486, see "case OP_Delete:"). I would
suggest to initialize iKey always (just after "pC = p->apCsr[i];"). This
simple assignment doesn't hurt but saves the "even more complex" if
statement "if( db->xUpdateCallback && pOp->p4.z )".
I've attached little patch against the 3.6.10 amalgamation....
Bye,
Michael
--- orig/sqlite3.c 2009-01-15 11:00:44.000000000 +0100
+++ sqlite3.c 2009-01-22 11:44:49.000000000 +0100
@@ -22679,7 +22679,7 @@
struct unixLockKey lockKey; /* Lookup key for the unixLockInfo structure
*/
struct unixFileId fileId; /* Lookup key for the unixOpenCnt struct */
struct stat statbuf; /* Low-level file information */
- struct unixLockInfo *pLock; /* Candidate unixLockInfo object */
+ struct unixLockInfo *pLock ; /* Candidate unixLockInfo object */
struct unixOpenCnt *pOpen; /* Candidate unixOpenCnt object */
/* Get low-level information about the file that we can used to
@@ -22751,7 +22751,10 @@
pLock->nRef++;
}
*ppLock = pLock;
+ }else{
+ pLock = NULL;
}
+
if( ppOpen!=0 ){
pOpen = openList;
while( pOpen && memcmp(&fileId, &pOpen->fileId, sizeof(fileId)) ){
@@ -23573,11 +23576,11 @@
/* To fully unlock the database, delete the lock file */
assert( locktype==NO_LOCK );
- if( unlink(zLockFile) ){
- int rc, tErrno = errno;
- if( ENOENT != tErrno ){
- rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
- }
+ if( unlink(zLockFile) )
+ {
+ int tErrno = errno;
+ int rc = sqliteErrorFromPosixError(tErrno, SQLITE_IOERR_UNLOCK);
+
if( IS_LOCK_ERROR(rc) ){
pFile->lastErrno = tErrno;
}
@@ -52489,6 +52492,7 @@
assert( i>=0 && i<p->nCursor );
pC = p->apCsr[i];
assert( pC!=0 );
+ iKey = pC->lastRowid;
assert( pC->pCursor!=0 ); /* Only valid for real tables, no pseudotables */
/* If the update-hook will be invoked, set iKey to the rowid of the
@@ -52497,7 +52501,6 @@
if( db->xUpdateCallback && pOp->p4.z ){
assert( pC->isTable );
assert( pC->rowidIsValid ); /* lastRowid set by previous OP_NotFound */
- iKey = pC->lastRowid;
}
rc = sqlite3VdbeCursorMoveto(pC);
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users