mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Simplification of the error code translator in os_unix.c. Code cleanup only.
The logic is unchanged. FossilOrigin-Name: 2a20f793fdf6a2e88b679a7bd4e8ccf2935df049
This commit is contained in:
@@ -759,23 +759,12 @@ static int robust_ftruncate(int h, sqlite3_int64 sz){
|
||||
** should handle ENOLCK, ENOTSUP, EOPNOTSUPP separately.
|
||||
*/
|
||||
static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
|
||||
assert( (sqliteIOErr == SQLITE_IOERR_LOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_UNLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_RDLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) );
|
||||
switch (posixError) {
|
||||
#if 0
|
||||
/* At one point this code was not commented out. In theory, this branch
|
||||
** should never be hit, as this function should only be called after
|
||||
** a locking-related function (i.e. fcntl()) has returned non-zero with
|
||||
** the value of errno as the first argument. Since a system call has failed,
|
||||
** errno should be non-zero.
|
||||
**
|
||||
** Despite this, if errno really is zero, we still don't want to return
|
||||
** SQLITE_OK. The system call failed, and *some* SQLite error should be
|
||||
** propagated back to the caller. Commenting this branch out means errno==0
|
||||
** will be handled by the "default:" case below.
|
||||
*/
|
||||
case 0:
|
||||
return SQLITE_OK;
|
||||
#endif
|
||||
|
||||
case EACCES:
|
||||
case EAGAIN:
|
||||
case ETIMEDOUT:
|
||||
case EBUSY:
|
||||
@@ -785,41 +774,9 @@ static int sqliteErrorFromPosixError(int posixError, int sqliteIOErr) {
|
||||
* introspection, in which it actually means what it says */
|
||||
return SQLITE_BUSY;
|
||||
|
||||
case EACCES:
|
||||
/* EACCES is like EAGAIN during locking operations, but not any other time*/
|
||||
if( (sqliteIOErr == SQLITE_IOERR_LOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_UNLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_RDLOCK) ||
|
||||
(sqliteIOErr == SQLITE_IOERR_CHECKRESERVEDLOCK) ){
|
||||
return SQLITE_BUSY;
|
||||
}
|
||||
/* else fall through */
|
||||
case EPERM:
|
||||
return SQLITE_PERM;
|
||||
|
||||
#if EOPNOTSUPP!=ENOTSUP
|
||||
case EOPNOTSUPP:
|
||||
/* something went terribly awry, unless during file system support
|
||||
* introspection, in which it actually means what it says */
|
||||
#endif
|
||||
#ifdef ENOTSUP
|
||||
case ENOTSUP:
|
||||
/* invalid fd, unless during file system support introspection, in which
|
||||
* it actually means what it says */
|
||||
#endif
|
||||
case EIO:
|
||||
case EBADF:
|
||||
case EINVAL:
|
||||
case ENOTCONN:
|
||||
case ENODEV:
|
||||
case ENXIO:
|
||||
case ENOENT:
|
||||
#ifdef ESTALE /* ESTALE is not defined on Interix systems */
|
||||
case ESTALE:
|
||||
#endif
|
||||
case ENOSYS:
|
||||
/* these should force the client to close the file and reconnect */
|
||||
|
||||
default:
|
||||
return sqliteIOErr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user