[commit: ghc] master: base: fdReady(): Ensure and doc that return values are always -1/0/1 (03009aa)
git at git.haskell.org
git at git.haskell.org
Wed Sep 27 21:38:37 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/03009aa70a099867331afb9876333c687454c5d5/ghc
>---------------------------------------------------------------
commit 03009aa70a099867331afb9876333c687454c5d5
Author: Niklas Hambüchen <mail at nh2.me>
Date: Wed Sep 27 15:29:06 2017 -0400
base: fdReady(): Ensure and doc that return values are always -1/0/1
Reviewers: bgamari, austin, hvr, Phyx
Reviewed By: Phyx
Subscribers: Phyx, rwbarton, thomie
Differential Revision: https://phabricator.haskell.org/D4010
>---------------------------------------------------------------
03009aa70a099867331afb9876333c687454c5d5
libraries/base/cbits/inputReady.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/libraries/base/cbits/inputReady.c b/libraries/base/cbits/inputReady.c
index 21ad36d..30327ba 100644
--- a/libraries/base/cbits/inputReady.c
+++ b/libraries/base/cbits/inputReady.c
@@ -40,6 +40,10 @@
*
* This function blocks until either `msecs` have passed, or input is
* available.
+ *
+ * Returns:
+ * 1 => Input ready, 0 => not ready, -1 => error
+ * On error, sets `errno`.
*/
int
fdReady(int fd, int write, int msecs, int isSock)
@@ -117,8 +121,7 @@ fdReady(int fd, int write, int msecs, int isSock)
}
}
- /* 1 => Input ready, 0 => not ready, -1 => error */
- return (ready);
+ return (ready > 0);
} else {
DWORD rc;
HANDLE hFile = (HANDLE)_get_osfhandle(fd);
More information about the ghc-commits
mailing list