diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-08-16 01:52:15 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-08-16 01:57:04 +0000 |
commit | 9f30805bc4ff65ad4ca0be9dfb26b1a9bdc70c51 (patch) | |
tree | c974cbd69173710607707545817b66883c5b650f /ext/kgio/tryopen.c | |
parent | 8be51237720fd18cb45188f29c717bbac0ca1964 (diff) | |
download | kgio-9f30805bc4ff65ad4ca0be9dfb26b1a9bdc70c51.tar.gz |
check syscall returns against < 0 instead of == -1
This may help us avoid errors in case of C library bugs, and also results in smaller code: $ ~/linux/scripts/bloat-o-meter before.so after.so add/remove: 0/0 grow/shrink: 0/9 up/down: 0/-66 (-66) function old new delta s_trywrite 160 159 -1 kgio_write 160 159 -1 kgio_trywrite 160 159 -1 my_recv 616 610 -6 my_peek 616 610 -6 stream_connect 456 448 -8 my_socket 222 213 -9 my_writev 1703 1687 -16 write_check 427 409 -18
Diffstat (limited to 'ext/kgio/tryopen.c')
-rw-r--r-- | ext/kgio/tryopen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/kgio/tryopen.c b/ext/kgio/tryopen.c index 0ee6a54..5fa6ada 100644 --- a/ext/kgio/tryopen.c +++ b/ext/kgio/tryopen.c @@ -106,7 +106,7 @@ static VALUE s_tryopen(int argc, VALUE *argv, VALUE klass) retry: fd = (int)rb_thread_blocking_region(nogvl_open, &o, RUBY_UBF_IO, 0); - if (fd == -1) { + if (fd < 0) { if (errno == EMFILE || errno == ENFILE || errno == ENOMEM) { rb_gc(); if (retried) @@ -114,7 +114,7 @@ retry: retried = 1; goto retry; } - if (fd == -1) { + if (fd < 0) { int saved_errno = errno; if (!st_lookup(errno2sym, (st_data_t)errno, &rv)) { |