diff --git a/src/mdbx.c b/src/mdbx.c index c48601c5..c1014675 100644 --- a/src/mdbx.c +++ b/src/mdbx.c @@ -3737,7 +3737,7 @@ static int __cold mdbx_setup_dxb(MDB_env *env, MDB_meta *meta, int lck_rc) { int err = mdbx_read_header(env, meta); if (unlikely(err != MDB_SUCCESS)) { if (lck_rc != /* lck exclusive */ MDBX_RESULT_TRUE || err != MDBX_ENODATA || - (env->me_flags & MDB_RDONLY)) + (env->me_flags & MDB_RDONLY) != 0) return err; mdbx_debug("create new database"); diff --git a/src/osal.c b/src/osal.c index efa17ba1..0315056c 100644 --- a/src/osal.c +++ b/src/osal.c @@ -337,19 +337,16 @@ int mdbx_pread(mdbx_filehandle_t fd, void *buf, size_t bytes, off_t offset) { DWORD read = 0; if (unlikely(!ReadFile(fd, buf, (DWORD)bytes, &read, &ov))) { int rc = GetLastError(); - if (rc == ERROR_HANDLE_EOF) - return (read == 0 && offset == 0) ? MDBX_ENODATA : ERROR_READ_FAULT; return (rc == MDB_SUCCESS) ? /* paranoia */ ERROR_READ_FAULT : rc; } - return (read == bytes) ? MDB_SUCCESS : ERROR_READ_FAULT; #else ssize_t read = pread(fd, buf, bytes, offset); - if (likely(bytes == (size_t)read)) - return MDB_SUCCESS; - if (read < 0) - return errno; - return (read == 0 && offset == 0) ? MDBX_ENODATA : EIO; + if (read < 0) { + int rc = errno; + return (rc == MDB_SUCCESS) ? /* paranoia */ EIO : rc; + } #endif + return (bytes == (size_t)read) ? MDB_SUCCESS : MDBX_ENODATA; } int mdbx_pwrite(mdbx_filehandle_t fd, const void *buf, size_t bytes,