summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2023-05-12 10:57:42 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2023-05-12 18:36:02 +0900
commitc803e92d6638c985d7ec96804ac4c83b816011bd (patch)
treeedb18ddf36e4477365bfcd6b5a06d26714a98182
parent30d72056711dc80249a428a9dd5714254d7e3119 (diff)
downloadruby-c803e92d6638c985d7ec96804ac4c83b816011bd.tar.gz
Return `errno` as the result instead of the global variable
-rw-r--r--dir.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/dir.c b/dir.c
index ff351bbae1..fc7d9049fc 100644
--- a/dir.c
+++ b/dir.c
@@ -3475,8 +3475,7 @@ nogvl_dir_empty_p(void *ptr)
/* fall through */
case 0:
if (e == ENOTDIR) return (void *)Qfalse;
- errno = e; /* for rb_sys_fail_path */
- return (void *)Qundef;
+ return (void *)INT2FIX(e);
}
}
while ((dp = READDIR(dir, NULL)) != NULL) {
@@ -3530,8 +3529,8 @@ rb_dir_s_empty_p(VALUE obj, VALUE dirname)
result = (VALUE)rb_thread_call_without_gvl(nogvl_dir_empty_p, (void *)path,
RUBY_UBF_IO, 0);
- if (UNDEF_P(result)) {
- rb_sys_fail_path(orig);
+ if (FIXNUM_P(result)) {
+ rb_syserr_fail_path((int)FIX2LONG(result), orig);
}
return result;
}