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

ruby-changes:51130

From: shyouhei <ko1@a...>
Date: Sat, 5 May 2018 00:03:43 +0900 (JST)
Subject: [ruby-changes:51130] shyouhei:r63337 (trunk): nobody is using the return value of rb_io_fptr_finalize

shyouhei	2018-05-05 00:03:37 +0900 (Sat, 05 May 2018)

  New Revision: 63337

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

  Log:
    nobody is using the return value of rb_io_fptr_finalize
    
    However this function is listed in ruby/io.h.  We cannot but
    define a new, void-returning variant to use instead.

  Modified files:
    trunk/internal.h
    trunk/io.c
Index: io.c
===================================================================
--- io.c	(revision 63336)
+++ io.c	(revision 63337)
@@ -4629,21 +4629,36 @@ clear_codeconv(rb_io_t *fptr) https://github.com/ruby/ruby/blob/trunk/io.c#L4629
     clear_writeconv(fptr);
 }
 
-int
-rb_io_fptr_finalize(rb_io_t *fptr)
+void
+rb_io_fptr_finalize_internal(void *ptr)
 {
-    if (!fptr) return 0;
+    rb_io_t *fptr = ptr;
+
+    if (!ptr) return;
     fptr->pathv = Qnil;
     if (0 <= fptr->fd)
-	rb_io_fptr_cleanup(fptr, TRUE);
+        rb_io_fptr_cleanup(fptr, TRUE);
     fptr->write_lock = 0;
     free_io_buffer(&fptr->rbuf);
     free_io_buffer(&fptr->wbuf);
     clear_codeconv(fptr);
     free(fptr);
-    return 1;
 }
 
+#undef rb_io_fptr_finalize
+int
+rb_io_fptr_finalize(rb_io_t *fptr)
+{
+    if (!fptr) {
+        return 0;
+    }
+    else {
+        rb_io_fptr_finalize_internal(fptr);
+        return 1;
+    }
+}
+#define rb_io_fptr_finalize(fptr) rb_io_fptr_finalize_internal(fptr)
+
 RUBY_FUNC_EXPORTED size_t
 rb_io_memsize(const rb_io_t *fptr)
 {
Index: internal.h
===================================================================
--- internal.h	(revision 63336)
+++ internal.h	(revision 63337)
@@ -1348,6 +1348,8 @@ VALUE rb_io_flush_raw(VALUE, int); https://github.com/ruby/ruby/blob/trunk/internal.h#L1348
 size_t rb_io_memsize(const rb_io_t *);
 #endif
 int rb_stderr_tty_p(void);
+void rb_io_fptr_finalize_internal(void *ptr);
+#define rb_io_fptr_finalize rb_io_fptr_finalize_internal
 
 /* load.c */
 VALUE rb_get_load_path(void);

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

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