summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeetu Golani <jeetu.golani@gmail.com>2010-04-22 23:23:27 +0530
committerJeetu Golani <jeetu.golani@gmail.com>2010-04-22 23:23:27 +0530
commit56962e42a509dc4d0d9541e46b93689dac61c4fd (patch)
tree048ba88636814aca19d4297db51fd7428a1eda84
parent0e0c80e749eccf121e55c1e855c48d03b54f33ef (diff)
Set errno=0 in read_block. On Win32 there is no errno and this makes the
do..while loop execute only once. Also set the return value to -1 in _xcb_open if control reaches the end - if all goes well it shouldn't reach there.
-rw-r--r--src/xcb_in.c9
-rw-r--r--src/xcb_util.c2
2 files changed, 4 insertions, 7 deletions
diff --git a/src/xcb_in.c b/src/xcb_in.c
index 8689344..b481295 100644
--- a/src/xcb_in.c
+++ b/src/xcb_in.c
@@ -297,15 +297,12 @@ static int read_block(const int fd, void *buf, const ssize_t len)
fd_set fds;
FD_ZERO(&fds);
FD_SET(fd, &fds);
-#ifndef _WIN32
+
+ /* Initializing errno here makes sure that for Win32 this loop will execute only once */
+ errno = 0;
do {
ret = select(fd + 1, &fds, 0, 0, 0);
} while (ret == -1 && errno == EINTR);
-#else
- /* the do while loop used for the non-windows version isn't required*/
- /* for windows since there are no signals in Windows hence no EINTR*/
- ret = select(fd + 1, &fds, 0, 0, 0);
-#endif /* !_WIN32 */
#endif /* USE_POLL */
}
if(ret <= 0)
diff --git a/src/xcb_util.c b/src/xcb_util.c
index 2be59d2..e08a320 100644
--- a/src/xcb_util.c
+++ b/src/xcb_util.c
@@ -180,10 +180,10 @@ static int _xcb_open(char *host, char *protocol, const int display)
fd = _xcb_open_abstract(protocol, file, filelen);
if (fd >= 0 || (errno != ENOENT && errno != ECONNREFUSED))
return fd;
-
#endif
return _xcb_open_unix(protocol, file);
#endif /* !_WIN32 */
+ return -1; /* if control reaches here then something has gone wrong */
}
static int _xcb_socket(int family, int type, int proto)