/ Check-in [47aa7eb0]
Login

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

Overview
Comment:It is OK for a unix file descriptor to be zero. It just can't be negative. Adjust an assert accordingly. Ticket #3781. (CVS 6457)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 47aa7eb0e047e30bbf09cb08c1e48c61f8d9861c
User & Date: drh 2009-04-07 00:35:20
Context
2009-04-07
00:43
Always enable WHERE-tracing on a test build. Oops - accidentally included a debugging change to pragma.c in this check-in. The real fix for the pragma problem is in the following checking. (CVS 6458) check-in: 567cf90b user: drh tags: trunk
00:35
It is OK for a unix file descriptor to be zero. It just can't be negative. Adjust an assert accordingly. Ticket #3781. (CVS 6457) check-in: 47aa7eb0 user: drh tags: trunk
2009-04-06
17:50
Test cases and minor code changes to increase coverage of btree.c. (CVS 6456) check-in: def3a016 user: danielk1977 tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to src/os_unix.c.

    39     39   **   *  Definitions of sqlite3_io_methods objects for all locking
    40     40   **      methods plus "finder" functions for each locking method.
    41     41   **   *  sqlite3_vfs method implementations.
    42     42   **   *  Locking primitives for the proxy uber-locking-method. (MacOSX only)
    43     43   **   *  Definitions of sqlite3_vfs objects for all locking methods
    44     44   **      plus implementations of sqlite3_os_init() and sqlite3_os_end().
    45     45   **
    46         -** $Id: os_unix.c,v 1.248 2009/03/30 07:39:35 danielk1977 Exp $
           46  +** $Id: os_unix.c,v 1.249 2009/04/07 00:35:20 drh Exp $
    47     47   */
    48     48   #include "sqliteInt.h"
    49     49   #if SQLITE_OS_UNIX              /* This file is used on unix only */
    50     50   
    51     51   /*
    52     52   ** There are various methods for file locking used for concurrency
    53     53   ** control:
................................................................................
  3609   3609   static int unixOpen(
  3610   3610     sqlite3_vfs *pVfs,           /* The VFS for which this is the xOpen method */
  3611   3611     const char *zPath,           /* Pathname of file to be opened */
  3612   3612     sqlite3_file *pFile,         /* The file descriptor to be filled in */
  3613   3613     int flags,                   /* Input flags to control the opening */
  3614   3614     int *pOutFlags               /* Output flags returned to SQLite core */
  3615   3615   ){
  3616         -  int fd = 0;                    /* File descriptor returned by open() */
         3616  +  int fd = -1;                    /* File descriptor returned by open() */
  3617   3617     int dirfd = -1;                /* Directory file descriptor */
  3618   3618     int openFlags = 0;             /* Flags to pass to open() */
  3619   3619     int eType = flags&0xFFFFFF00;  /* Type of file to open */
  3620   3620     int noLock;                    /* True to omit locking primitives */
  3621   3621     int rc = SQLITE_OK;
  3622   3622   
  3623   3623     int isExclusive  = (flags & SQLITE_OPEN_EXCLUSIVE);
................................................................................
  3712   3712   
  3713   3713   #ifndef NDEBUG
  3714   3714     if( (flags & SQLITE_OPEN_MAIN_DB)!=0 ){
  3715   3715       ((unixFile*)pFile)->isLockable = 1;
  3716   3716     }
  3717   3717   #endif
  3718   3718   
  3719         -  assert(fd!=0);
         3719  +  assert( fd>=0 );
  3720   3720     if( isOpenDirectory ){
  3721   3721       rc = openDirectory(zPath, &dirfd);
  3722   3722       if( rc!=SQLITE_OK ){
  3723   3723         close(fd); /* silently leak if fail, already in error */
  3724   3724         return rc;
  3725   3725       }
  3726   3726     }