diff options
author | Eric Wong <e@80x24.org> | 2015-01-10 03:31:46 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2015-01-10 03:35:14 +0000 |
commit | f9a11c4476090c656c6c8dd9b6a681f8bd3ab547 (patch) | |
tree | 2875c8ab812438ae3560a204ca21137ea83e13b6 | |
parent | 851855c73f5ea3b1a7117af99b63e8348bc3b2d8 (diff) | |
download | ruby_io_splice-f9a11c4476090c656c6c8dd9b6a681f8bd3ab547.tar.gz |
This should allow faster instructions to be used in some cases. Technically this may be less pedantically correct, but there is enough existing code out there which does the same thing to discourage kernel/libc developers from overloading negative return values. ...And glibc even favors comparison against zero, too.
-rw-r--r-- | ext/io_splice/io_splice_ext.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/ext/io_splice/io_splice_ext.c b/ext/io_splice/io_splice_ext.c index 276f3a6..97f744c 100644 --- a/ext/io_splice/io_splice_ext.c +++ b/ext/io_splice/io_splice_ext.c @@ -167,7 +167,7 @@ static ssize_t do_splice(int argc, VALUE *argv, unsigned dflags) a.fd_in = check_fileno(io_in); a.fd_out = check_fileno(io_out); bytes = (ssize_t)io_run(nogvl_splice, &a); - if (bytes == -1) { + if (bytes < 0) { if (errno == EINTR) continue; if (waitall && errno == EAGAIN) { @@ -238,7 +238,7 @@ static VALUE my_splice(int argc, VALUE *argv, VALUE self) if (n == 0) rb_eof_error(); - if (n == -1) + if (n < 0) rb_sys_fail("splice"); return SSIZET2NUM(n); } @@ -264,7 +264,7 @@ static VALUE trysplice(int argc, VALUE *argv, VALUE self) if (n == 0) return Qnil; - if (n == -1) { + if (n < 0) { if (errno == EAGAIN) return sym_EAGAIN; rb_sys_fail("splice"); @@ -309,7 +309,7 @@ static ssize_t do_tee(int argc, VALUE *argv, unsigned dflags) a.fd_in = check_fileno(io_in); a.fd_out = check_fileno(io_out); bytes = (ssize_t)io_run(nogvl_tee, &a); - if (bytes == -1) { + if (bytes < 0) { if (errno == EINTR) continue; if (waitall && errno == EAGAIN) { @@ -366,7 +366,7 @@ static VALUE my_tee(int argc, VALUE *argv, VALUE self) if (n == 0) rb_eof_error(); - if (n == -1) + if (n < 0) rb_sys_fail("tee"); return SSIZET2NUM(n); @@ -391,7 +391,7 @@ static VALUE trytee(int argc, VALUE *argv, VALUE self) if (n == 0) return Qnil; - if (n == -1) { + if (n < 0) { if (errno == EAGAIN) return sym_EAGAIN; rb_sys_fail("tee"); @@ -520,7 +520,7 @@ static VALUE my_vmsplice(int argc, VALUE * argv, VALUE self) a.fd = check_fileno(io); n = (ssize_t)io_run(nogvl_vmsplice, &a); - if (n == -1) { + if (n < 0) { if (errno == EAGAIN) { if (a.flags & SPLICE_F_NONBLOCK) rb_sys_fail("vmsplice"); |