aboutsummaryrefslogtreecommitdiffstats
path: root/file.c
diff options
context:
space:
mode:
authornormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-01 01:44:47 +0000
committernormal <normal@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-10-01 01:44:47 +0000
commite689ee01a0e14c95252fe508e785fec909af0811 (patch)
treea6f78d17c93556d8b7ea33f61a03ef7458da8ea7 /file.c
parent204b7732e5a59753f143c6e79a6a7f9c1325125f (diff)
downloadruby-e689ee01a0e14c95252fe508e785fec909af0811.tar.gz
file.c: remove unnecessary volatile use
For apply2files, all callers use the `path' VALUE for generating exceptions, so there is no need to guard it. In realpath_rec, RB_GC_GUARD is already used on link_orig. In rb_check_realpath_internal, RB_GC_GUARD is necessary and preferable (see Appendix E. of doc/extension.rdoc) * file.c (apply2files): remove unnecessary volatile (realpath_rec): ditto (rb_check_realpath_internal): ditto, and add RB_GC_GUARD git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@60081 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'file.c')
-rw-r--r--file.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/file.c b/file.c
index deb666e096..a73ed57360 100644
--- a/file.c
+++ b/file.c
@@ -358,7 +358,7 @@ static VALUE
apply2files(void (*func)(const char *, VALUE, void *), int argc, VALUE *argv, void *arg)
{
long i;
- volatile VALUE path;
+ VALUE path;
for (i=0; i<argc; i++) {
const char *s;
@@ -3902,7 +3902,7 @@ realpath_rec(long *prefixlenp, VALUE *resolvedp, const char *unresolved,
#ifdef HAVE_READLINK
if (S_ISLNK(sbuf.st_mode)) {
VALUE link;
- volatile VALUE link_orig = Qnil;
+ VALUE link_orig = Qnil;
const char *link_prefix, *link_names;
long link_prefixlen;
rb_hash_aset(loopcheck, testpath, ID2SYM(resolving));
@@ -3943,9 +3943,9 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, enum rb_realpath_mode mode
{
long prefixlen;
VALUE resolved;
- volatile VALUE unresolved_path;
+ VALUE unresolved_path;
VALUE loopcheck;
- volatile VALUE curdir = Qnil;
+ VALUE curdir = Qnil;
rb_encoding *enc, *origenc;
char *path_names = NULL, *basedir_names = NULL, *curdir_names = NULL;
@@ -4028,6 +4028,8 @@ rb_check_realpath_internal(VALUE basedir, VALUE path, enum rb_realpath_mode mode
}
OBJ_TAINT(resolved);
+ RB_GC_GUARD(unresolved_path);
+ RB_GC_GUARD(curdir);
return resolved;
}