From 03009aa70a099867331afb9876333c687454c5d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20Hamb=C3=BCchen?= Date: Wed, 27 Sep 2017 15:29:06 -0400 Subject: 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 --- libraries/base/cbits/inputReady.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libraries/base/cbits/inputReady.c') diff --git a/libraries/base/cbits/inputReady.c b/libraries/base/cbits/inputReady.c index 21ad36db3a..30327ba811 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); -- cgit v1.2.1