summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-06 02:04:40 (GMT)
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-09-06 02:04:40 (GMT)
commitf476726323027191e35600e63f58f479e5c45bd3 (patch)
tree0c027b2f95e6ac10c943e6f9b79de071a6dcc3cf /thread.c
parent649016bdb1d744a79e50e23c9483ee16c55a24ab (diff)
thread.c: suppress warnings
* thread.c (do_select): suppress maybe-uninitialized warnings on maxfd. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51774 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c29
1 files changed, 17 insertions, 12 deletions
diff --git a/thread.c b/thread.c
index a7de296..e92208e 100644
--- a/thread.c
+++ b/thread.c
@@ -3392,6 +3392,8 @@ rb_fd_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_fdset_t *excep
return select(n, r, w, e, timeout);
}
+#define rb_fd_no_init(fds) ASSUME(!(fds)->maxfd)
+
#undef FD_ZERO
#undef FD_SET
#undef FD_CLR
@@ -3457,6 +3459,10 @@ rb_fd_set(int fd, rb_fdset_t *set)
#endif
+#ifndef rb_fd_no_init
+#define rb_fd_no_init(fds) (void)(fds)
+#endif
+
static inline int
retryable(int e)
{
@@ -3510,12 +3516,12 @@ do_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds,
timeout = &wait_rest;
}
- if (readfds)
- rb_fd_init_copy(&orig_read, readfds);
- if (writefds)
- rb_fd_init_copy(&orig_write, writefds);
- if (exceptfds)
- rb_fd_init_copy(&orig_except, exceptfds);
+#define fd_init_copy(f) \
+ (f##fds) ? rb_fd_init_copy(&orig_##f, f##fds) : rb_fd_no_init(&orig_##f)
+ fd_init_copy(read);
+ fd_init_copy(write);
+ fd_init_copy(except);
+#undef fd_init_copy
do {
lerrno = 0;
@@ -3529,12 +3535,11 @@ do_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds,
RUBY_VM_CHECK_INTS_BLOCKING(th);
} while (result < 0 && retryable(errno = lerrno) && do_select_update());
- if (readfds)
- rb_fd_term(&orig_read);
- if (writefds)
- rb_fd_term(&orig_write);
- if (exceptfds)
- rb_fd_term(&orig_except);
+#define fd_term(f) if (f##fds) rb_fd_term(&orig_##f)
+ fd_term(read);
+ fd_term(write);
+ fd_term(except);
+#undef fd_term
return result;
}