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

ruby-changes:51284

From: k0kubun <ko1@a...>
Date: Wed, 23 May 2018 00:39:39 +0900 (JST)
Subject: [ruby-changes:51284] k0kubun:r63490 (trunk): mjit.c: show error message on remove failure

k0kubun	2018-05-23 00:39:34 +0900 (Wed, 23 May 2018)

  New Revision: 63490

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

  Log:
    mjit.c: show error message on remove failure

  Modified files:
    trunk/mjit.c
Index: mjit.c
===================================================================
--- mjit.c	(revision 63489)
+++ mjit.c	(revision 63490)
@@ -771,6 +771,15 @@ print_jit_result(const char *result, con https://github.com/ruby/ruby/blob/trunk/mjit.c#L771
             RSTRING_PTR(rb_iseq_path(unit->iseq)), FIX2INT(unit->iseq->body->location.first_lineno), c_file);
 }
 
+static void
+remove_file(const char *filename)
+{
+    if (remove(filename) && (mjit_opts.warnings || mjit_opts.verbose)) {
+        fprintf(stderr, "MJIT warning: failed to remove \"%s\": %s\n",
+                filename, strerror(errno));
+    }
+}
+
 /* Compile ISeq in UNIT and return function pointer of JIT-ed code.
    It may return NOT_COMPILABLE_JIT_ISEQ_FUNC if something went wrong. */
 static mjit_func_t
@@ -869,7 +878,7 @@ convert_unit_to_func(struct rb_mjit_unit https://github.com/ruby/ruby/blob/trunk/mjit.c#L878
     fclose(f);
     if (!success) {
         if (!mjit_opts.save_temps)
-            remove(c_file);
+            remove_file(c_file);
         print_jit_result("failure", unit, 0, c_file);
         return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
     }
@@ -879,7 +888,7 @@ convert_unit_to_func(struct rb_mjit_unit https://github.com/ruby/ruby/blob/trunk/mjit.c#L888
     end_time = real_ms_time();
 
     if (!mjit_opts.save_temps)
-        remove(c_file);
+        remove_file(c_file);
     if (!success) {
         verbose(2, "Failed to generate so: %s", so_file);
         return (mjit_func_t)NOT_COMPILABLE_JIT_ISEQ_FUNC;
@@ -890,7 +899,7 @@ convert_unit_to_func(struct rb_mjit_unit https://github.com/ruby/ruby/blob/trunk/mjit.c#L899
 #ifdef _WIN32
         unit->so_file = strdup(so_file);
 #else
-        remove(so_file);
+        remove_file(so_file);
 #endif
     }
 
@@ -1466,7 +1475,7 @@ mjit_finish(void) https://github.com/ruby/ruby/blob/trunk/mjit.c#L1475
 
     /* cleanup temps */
     if (!mjit_opts.save_temps)
-        remove(pch_file);
+        remove_file(pch_file);
 
     xfree(tmp_dir); tmp_dir = NULL;
     xfree(pch_file); pch_file = NULL;

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

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