Piotr Caban : msvcrt: Get rid of msvcrt_fdtoh helper.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jun 3 09:43:09 CDT 2015
Module: wine
Branch: master
Commit: 86baccc9ae9f79cc542c53e31edfdc9bf8f99a8e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=86baccc9ae9f79cc542c53e31edfdc9bf8f99a8e
Author: Piotr Caban <piotr at codeweavers.com>
Date: Wed Jun 3 13:25:47 2015 +0200
msvcrt: Get rid of msvcrt_fdtoh helper.
---
dlls/msvcrt/file.c | 24 +++---------------------
dlls/msvcrt/tests/file.c | 5 +++++
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/dlls/msvcrt/file.c b/dlls/msvcrt/file.c
index 7bdb468..d7a8f3a 100644
--- a/dlls/msvcrt/file.c
+++ b/dlls/msvcrt/file.c
@@ -309,26 +309,6 @@ static inline BOOL msvcrt_is_valid_fd(int fd)
return fd >= 0 && fd < MSVCRT_fdend && (get_ioinfo_nolock(fd)->wxflag & WX_OPEN);
}
-/* INTERNAL: Get the HANDLE for a fd
- * This doesn't lock the table, because a failure will result in
- * INVALID_HANDLE_VALUE being returned, which should be handled correctly. If
- * it returns a valid handle which is about to be closed, a subsequent call
- * will fail, most likely in a sane way.
- */
-static HANDLE msvcrt_fdtoh(int fd)
-{
- if (!msvcrt_is_valid_fd(fd))
- {
- WARN(":fd (%d) - no handle!\n",fd);
- *MSVCRT___doserrno() = 0;
- *MSVCRT__errno() = MSVCRT_EBADF;
- return INVALID_HANDLE_VALUE;
- }
- if (get_ioinfo_nolock(fd)->handle == INVALID_HANDLE_VALUE)
- WARN("returning INVALID_HANDLE_VALUE for %d\n", fd);
- return get_ioinfo_nolock(fd)->handle;
-}
-
/* INTERNAL: free a file entry fd */
static void msvcrt_free_fd(int fd)
{
@@ -1848,9 +1828,11 @@ int CDECL _futime(int fd, struct MSVCRT___utimbuf32 *t)
*/
MSVCRT_intptr_t CDECL MSVCRT__get_osfhandle(int fd)
{
- HANDLE hand = msvcrt_fdtoh(fd);
+ HANDLE hand = get_ioinfo_nolock(fd)->handle;
TRACE(":fd (%d) handle (%p)\n",fd,hand);
+ if(hand == INVALID_HANDLE_VALUE)
+ *MSVCRT__errno() = MSVCRT_EBADF;
return (MSVCRT_intptr_t)hand;
}
diff --git a/dlls/msvcrt/tests/file.c b/dlls/msvcrt/tests/file.c
index 860db6a..c4d8fa1 100644
--- a/dlls/msvcrt/tests/file.c
+++ b/dlls/msvcrt/tests/file.c
@@ -1850,6 +1850,11 @@ static void test_get_osfhandle(void)
_close(fd);
_unlink(fname);
+
+ errno = 0xdeadbeef;
+ handle = (HANDLE)_get_osfhandle(fd);
+ ok(handle == INVALID_HANDLE_VALUE, "_get_osfhandle returned %p\n", handle);
+ ok(errno == EBADF, "errno = %d\n", errno);
}
static void test_setmaxstdio(void)
More information about the wine-cvs
mailing list