Skip to content

Commit 2e4dad6

Browse files
committed
Expand FPTR_TO_FD() macro
It was introduced for compatibility with Ruby 1.8. Ruby 1.8 has gone long ago and we will never support it.
1 parent 19cc58d commit 2e4dad6

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

ext/openssl/ossl_bio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ ossl_obj2bio(VALUE obj)
2121

2222
GetOpenFile(obj, fptr);
2323
rb_io_check_readable(fptr);
24-
if ((fd = rb_cloexec_dup(FPTR_TO_FD(fptr))) < 0){
24+
if ((fd = rb_cloexec_dup(fptr->fd)) < 0){
2525
rb_sys_fail(0);
2626
}
2727
rb_update_max_fd(fd);

ext/openssl/ossl_ssl.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,7 @@ ossl_ssl_setup(VALUE self)
14831483
GetOpenFile(io, fptr);
14841484
rb_io_check_readable(fptr);
14851485
rb_io_check_writable(fptr);
1486-
SSL_set_fd(ssl, TO_SOCKET(FPTR_TO_FD(fptr)));
1486+
SSL_set_fd(ssl, TO_SOCKET(fptr->fd));
14871487

14881488
return Qtrue;
14891489
}
@@ -1548,12 +1548,12 @@ ossl_start_ssl(VALUE self, int (*func)(), const char *funcname, VALUE opts)
15481548
case SSL_ERROR_WANT_WRITE:
15491549
if (no_exception_p(opts)) { return sym_wait_writable; }
15501550
write_would_block(nonblock);
1551-
rb_io_wait_writable(FPTR_TO_FD(fptr));
1551+
rb_io_wait_writable(fptr->fd);
15521552
continue;
15531553
case SSL_ERROR_WANT_READ:
15541554
if (no_exception_p(opts)) { return sym_wait_readable; }
15551555
read_would_block(nonblock);
1556-
rb_io_wait_readable(FPTR_TO_FD(fptr));
1556+
rb_io_wait_readable(fptr->fd);
15571557
continue;
15581558
case SSL_ERROR_SYSCALL:
15591559
if (errno) rb_sys_fail(funcname);
@@ -1691,7 +1691,7 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
16911691
GetOpenFile(io, fptr);
16921692
if (ssl_started(ssl)) {
16931693
if(!nonblock && SSL_pending(ssl) <= 0)
1694-
rb_thread_wait_fd(FPTR_TO_FD(fptr));
1694+
rb_thread_wait_fd(fptr->fd);
16951695
for (;;){
16961696
nread = SSL_read(ssl, RSTRING_PTR(str), RSTRING_LENINT(str));
16971697
switch(ssl_get_error(ssl, nread)){
@@ -1703,12 +1703,12 @@ ossl_ssl_read_internal(int argc, VALUE *argv, VALUE self, int nonblock)
17031703
case SSL_ERROR_WANT_WRITE:
17041704
if (no_exception_p(opts)) { return sym_wait_writable; }
17051705
write_would_block(nonblock);
1706-
rb_io_wait_writable(FPTR_TO_FD(fptr));
1706+
rb_io_wait_writable(fptr->fd);
17071707
continue;
17081708
case SSL_ERROR_WANT_READ:
17091709
if (no_exception_p(opts)) { return sym_wait_readable; }
17101710
read_would_block(nonblock);
1711-
rb_io_wait_readable(FPTR_TO_FD(fptr));
1711+
rb_io_wait_readable(fptr->fd);
17121712
continue;
17131713
case SSL_ERROR_SYSCALL:
17141714
if (!ERR_peek_error()) {
@@ -1809,12 +1809,12 @@ ossl_ssl_write_internal(VALUE self, VALUE str, VALUE opts)
18091809
case SSL_ERROR_WANT_WRITE:
18101810
if (no_exception_p(opts)) { return sym_wait_writable; }
18111811
write_would_block(nonblock);
1812-
rb_io_wait_writable(FPTR_TO_FD(fptr));
1812+
rb_io_wait_writable(fptr->fd);
18131813
continue;
18141814
case SSL_ERROR_WANT_READ:
18151815
if (no_exception_p(opts)) { return sym_wait_readable; }
18161816
read_would_block(nonblock);
1817-
rb_io_wait_readable(FPTR_TO_FD(fptr));
1817+
rb_io_wait_readable(fptr->fd);
18181818
continue;
18191819
case SSL_ERROR_SYSCALL:
18201820
if (errno) rb_sys_fail(0);

ext/openssl/ruby_missing.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
#if !defined(_OSSL_RUBY_MISSING_H_)
1111
#define _OSSL_RUBY_MISSING_H_
1212

13-
#define FPTR_TO_FD(fptr) ((fptr)->fd)
14-
1513
#ifndef RB_INTEGER_TYPE_P
1614
/* for Ruby 2.3 compatibility */
1715
#define RB_INTEGER_TYPE_P(obj) (RB_FIXNUM_P(obj) || RB_TYPE_P(obj, T_BIGNUM))

0 commit comments

Comments
 (0)