aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-21 07:40:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-10-21 07:40:47 +0000
commitc4e2f4ade09a1f02fe5965b8efdb6f26f05ad4bf (patch)
treee2d7bb21f7fb2b07948d6db8d04a02ab98b5ea55 /io.c
parent526c89a6d4fea76b714de4b0af943c95af9e0abc (diff)
downloadruby-c4e2f4ade09a1f02fe5965b8efdb6f26f05ad4bf.tar.gz
prefer rb_syserr_fail
* dir.c (dir_initialize, dir_read): prefer rb_syserr_fail over rb_sys_fail. * io.c (ruby_dup, rb_sysopen): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@56464 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/io.c b/io.c
index cba9318590..8fc0ca9247 100644
--- a/io.c
+++ b/io.c
@@ -889,11 +889,12 @@ ruby_dup(int orig)
fd = rb_cloexec_dup(orig);
if (fd < 0) {
- if (rb_gc_for_fd(errno)) {
+ int e = errno;
+ if (rb_gc_for_fd(e)) {
fd = rb_cloexec_dup(orig);
}
if (fd < 0) {
- rb_sys_fail(0);
+ rb_syserr_fail(e, 0);
}
}
rb_update_max_fd(fd);
@@ -5468,11 +5469,12 @@ rb_sysopen(VALUE fname, int oflags, mode_t perm)
fd = rb_sysopen_internal(&data);
if (fd < 0) {
- if (rb_gc_for_fd(errno)) {
+ int e = errno;
+ if (rb_gc_for_fd(e)) {
fd = rb_sysopen_internal(&data);
}
if (fd < 0) {
- rb_sys_fail_path(fname);
+ rb_syserr_fail_path(e, fname);
}
}
return fd;
@@ -5488,19 +5490,19 @@ rb_fdopen(int fd, const char *modestr)
#endif
file = fdopen(fd, modestr);
if (!file) {
+ int e = errno;
#if defined(__sun)
- if (errno == 0) {
+ if (e == 0) {
rb_gc();
errno = 0;
file = fdopen(fd, modestr);
}
else
#endif
- if (rb_gc_for_fd(errno)) {
+ if (rb_gc_for_fd(e)) {
file = fdopen(fd, modestr);
}
if (!file) {
- int e = errno;
#ifdef _WIN32
if (e == 0) e = EINVAL;
#elif defined(__sun)