diff options
author | Bruce Momjian <bruce@momjian.us> | 2006-10-03 20:44:18 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2006-10-03 20:44:18 +0000 |
commit | e15ce612b567db05dc345f8fa40e3477f13149df (patch) | |
tree | ad4a401f55c40ec2f1dd6d62bc00977f8a4cb5ec /src/port/open.c | |
parent | 0184c6835cb99057f3d99f4b5a62965221e2bf13 (diff) | |
download | postgresql-e15ce612b567db05dc345f8fa40e3477f13149df.tar.gz postgresql-e15ce612b567db05dc345f8fa40e3477f13149df.zip |
Cleanup pgwin32_open() 'if' test, and avoid possible error.
Diffstat (limited to 'src/port/open.c')
-rw-r--r-- | src/port/open.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/port/open.c b/src/port/open.c index dd1901bd3d8..125cad05503 100644 --- a/src/port/open.c +++ b/src/port/open.c @@ -6,7 +6,7 @@ * * Portions Copyright (c) 1996-2006, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/port/open.c,v 1.15 2006/09/24 17:19:53 tgl Exp $ + * $PostgreSQL: pgsql/src/port/open.c,v 1.16 2006/10/03 20:44:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -105,9 +105,15 @@ pgwin32_open(const char *fileName, int fileFlags,...) } /* _open_osfhandle will, on error, set errno accordingly */ - if ((fd = _open_osfhandle((long) h, fileFlags & O_APPEND)) < 0 || - (fileFlags & (O_TEXT | O_BINARY) && (_setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0))) + if ((fd = _open_osfhandle((long) h, fileFlags & O_APPEND)) < 0) CloseHandle(h); /* will not affect errno */ + else if (fileFlags & (O_TEXT | O_BINARY) && + _setmode(fd, fileFlags & (O_TEXT | O_BINARY)) < 0) + { + _close(fd); + return -1; + } + return fd; } |