[前][次][番号順一覧][スレッド一覧]

ruby-changes:47966

From: normal <ko1@a...>
Date: Sun, 1 Oct 2017 10:44:54 +0900 (JST)
Subject: [ruby-changes:47966] normal:r60081 (trunk): file.c: remove unnecessary volatile use

normal	2017-10-01 10:44:47 +0900 (Sun, 01 Oct 2017)

  New Revision: 60081

  https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=60081

  Log:
    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

  Modified files:
    trunk/file.c
Index: file.c
===================================================================
--- file.c	(revision 60080)
+++ file.c	(revision 60081)
@@ -358,7 +358,7 @@ static VALUE https://github.com/ruby/ruby/blob/trunk/file.c#L358
 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 *re https://github.com/ruby/ruby/blob/trunk/file.c#L3902
 #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 https://github.com/ruby/ruby/blob/trunk/file.c#L3943
 {
     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 https://github.com/ruby/ruby/blob/trunk/file.c#L4028
     }
 
     OBJ_TAINT(resolved);
+    RB_GC_GUARD(unresolved_path);
+    RB_GC_GUARD(curdir);
     return resolved;
 }
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]