ruby-changes:39693
From: nobu <ko1@a...>
Date: Sun, 6 Sep 2015 11:04:56 +0900 (JST)
Subject: [ruby-changes:39693] nobu:r51774 (trunk): thread.c: suppress warnings
nobu 2015-09-06 11:04:40 +0900 (Sun, 06 Sep 2015) New Revision: 51774 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51774 Log: thread.c: suppress warnings * thread.c (do_select): suppress maybe-uninitialized warnings on maxfd. Modified files: trunk/thread.c Index: thread.c =================================================================== --- thread.c (revision 51773) +++ thread.c (revision 51774) @@ -3392,6 +3392,8 @@ rb_fd_select(int n, rb_fdset_t *readfds, https://github.com/ruby/ruby/blob/trunk/thread.c#L3392 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) https://github.com/ruby/ruby/blob/trunk/thread.c#L3459 #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 https://github.com/ruby/ruby/blob/trunk/thread.c#L3516 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 https://github.com/ruby/ruby/blob/trunk/thread.c#L3535 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; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/