summaryrefslogtreecommitdiff
path: root/libraries/base/cbits/inputReady.c
diff options
context:
space:
mode:
authorNiklas Hambüchen <mail@nh2.me>2017-09-27 15:26:37 -0400
committerBen Gamari <ben@smart-cactus.org>2017-09-27 17:37:29 -0400
commitdddef3114246fcd79bf0993d685454802983111b (patch)
tree88a1fea419002f2a2a408ff2a45d884d6bd1d22f /libraries/base/cbits/inputReady.c
parent9bf6310d2002ef57dc726a4d9240bd520925114d (diff)
downloadhaskell-dddef3114246fcd79bf0993d685454802983111b.tar.gz
fdReady(): Fix some C -Wconversion warnings.
Btw, -Wconversion is off by default and not included in -Wall, -Wextra or -pedantic, so I used it temporarily with -optc-Wconversion. Reviewers: bgamari, austin, hvr Reviewed By: bgamari Subscribers: rwbarton, thomie Differential Revision: https://phabricator.haskell.org/D3965
Diffstat (limited to 'libraries/base/cbits/inputReady.c')
-rw-r--r--libraries/base/cbits/inputReady.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/libraries/base/cbits/inputReady.c b/libraries/base/cbits/inputReady.c
index c0b1a49555..21ad36db3a 100644
--- a/libraries/base/cbits/inputReady.c
+++ b/libraries/base/cbits/inputReady.c
@@ -156,9 +156,9 @@ fdReady(int fd, int write, int msecs, int isSock)
while (1) // discard non-key events
{
- rc = PeekConsoleInput(hFile, buf, 1, &count);
+ BOOL success = PeekConsoleInput(hFile, buf, 1, &count);
// printf("peek, rc=%d, count=%d, type=%d\n", rc, count, buf[0].EventType);
- if (rc == 0) {
+ if (!success) {
rc = GetLastError();
if (rc == ERROR_INVALID_HANDLE || rc == ERROR_INVALID_FUNCTION) {
return 1;
@@ -183,8 +183,8 @@ fdReady(int fd, int write, int msecs, int isSock)
{
// it's a non-key event, a key up event, or a
// non-character key (e.g. shift). discard it.
- rc = ReadConsoleInput(hFile, buf, 1, &count);
- if (rc == 0) {
+ BOOL success = ReadConsoleInput(hFile, buf, 1, &count);
+ if (!success) {
rc = GetLastError();
if (rc == ERROR_INVALID_HANDLE || rc == ERROR_INVALID_FUNCTION) {
return 1;
@@ -214,8 +214,8 @@ fdReady(int fd, int write, int msecs, int isSock)
// PeekNamedPipe() does not block, so if it returns that
// there is no new data, we have to sleep and try again.
while (avail == 0) {
- rc = PeekNamedPipe( hFile, NULL, 0, NULL, &avail, NULL );
- if (rc != 0) {
+ BOOL success = PeekNamedPipe( hFile, NULL, 0, NULL, &avail, NULL );
+ if (success) {
if (avail != 0) {
return 1;
} else { // no new data
@@ -242,7 +242,8 @@ fdReady(int fd, int write, int msecs, int isSock)
/* PeekNamedPipe didn't work - fall through to the general case */
default:
- rc = WaitForSingleObject( hFile, msecs );
+ // This cast is OK because we assert against `msecs < 0` above.
+ rc = WaitForSingleObject( hFile, (DWORD) msecs );
/* 1 => Input ready, 0 => not ready, -1 => error */
switch (rc) {