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

ruby-changes:59952

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 7 Feb 2020 14:24:38 +0900 (JST)
Subject: [ruby-changes:59952] 115fec062c (master): more on NULL versus functions.

https://git.ruby-lang.org/ruby.git/commit/?id=115fec062c

From 115fec062ccf7c6d72c8d5f64b7a5d84c9fb2dd8 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Fri, 7 Feb 2020 14:14:05 +0900
Subject: more on NULL versus functions.

Function pointers are not void*.  See also
ce4ea956d24eab5089a143bba38126f2b11b55b6
8427fca49bd85205f5a8766292dd893f003c0e48

diff --git a/dir.c b/dir.c
index 0957800..ea0edf5 100644
--- a/dir.c
+++ b/dir.c
@@ -2714,7 +2714,7 @@ ruby_glob(const char *path, int flags, ruby_glob_func *func, VALUE arg) https://github.com/ruby/ruby/blob/trunk/dir.c#L2714
 {
     ruby_glob_funcs_t funcs;
     funcs.match = func;
-    funcs.error = NULL;
+    funcs.error = 0;
     return ruby_glob0(path, AT_FDCWD, 0, flags & ~GLOB_VERBOSE,
 		      &funcs, arg, rb_ascii8bit_encoding());
 }
@@ -2843,7 +2843,7 @@ ruby_brace_glob_with_enc(const char *str, int flags, ruby_glob_func *func, VALUE https://github.com/ruby/ruby/blob/trunk/dir.c#L2843
 
     flags &= ~GLOB_VERBOSE;
     args.funcs.match = func;
-    args.funcs.error = NULL;
+    args.funcs.error = 0;
     args.value = arg;
     args.flags = flags;
     return ruby_brace_expand(str, flags, glob_brace, (VALUE)&args, enc, Qfalse);
diff --git a/dln.c b/dln.c
index 78c4c45..2251547 100644
--- a/dln.c
+++ b/dln.c
@@ -1254,7 +1254,8 @@ static bool https://github.com/ruby/ruby/blob/trunk/dln.c#L1254
 dln_incompatible_library_p(void *handle)
 {
     void *ex = dlsym(handle, EXTERNAL_PREFIX"ruby_xmalloc");
-    return ex && ex != ruby_xmalloc;
+    void *const fp = (void *)ruby_xmalloc;
+    return ex && ex != fp;
 }
 COMPILER_WARNING_POP
 #endif
diff --git a/enc/trans/newline.trans b/enc/trans/newline.trans
index a200ec0..9e76340 100644
--- a/enc/trans/newline.trans
+++ b/enc/trans/newline.trans
@@ -98,7 +98,7 @@ rb_universal_newline = { https://github.com/ruby/ruby/blob/trunk/enc/trans/newline.trans#L98
     2, /* max_output */
     asciicompat_converter, /* asciicompat_type */
     2, universal_newline_init, universal_newline_init, /* state_size, state_init, state_fini */
-    NULL, NULL, NULL, fun_so_universal_newline,
+    0, 0, 0, fun_so_universal_newline,
     universal_newline_finish
 };
 
@@ -110,8 +110,8 @@ rb_crlf_newline = { https://github.com/ruby/ruby/blob/trunk/enc/trans/newline.trans#L110
     1, /* max_input */
     2, /* max_output */
     asciicompat_converter, /* asciicompat_type */
-    0, NULL, NULL, /* state_size, state_init, state_fini */
-    NULL, NULL, NULL, NULL
+    0, 0, 0, /* state_size, state_init, state_fini */
+    0, 0, 0, 0
 };
 
 static const rb_transcoder
@@ -122,8 +122,8 @@ rb_cr_newline = { https://github.com/ruby/ruby/blob/trunk/enc/trans/newline.trans#L122
     1, /* max_input */
     1, /* max_output */
     asciicompat_converter, /* asciicompat_type */
-    0, NULL, NULL, /* state_size, state_init, state_fini */
-    NULL, NULL, NULL, NULL
+    0, 0, 0, /* state_size, state_init, state_fini */
+    0, 0, 0, 0
 };
 
 void
diff --git a/encoding.c b/encoding.c
index c77d351..ca98b8e 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1966,7 +1966,7 @@ Init_Encoding(void) https://github.com/ruby/ruby/blob/trunk/encoding.c#L1966
 	rb_ary_push(list, enc_new(enc_table.list[i].enc));
     }
 
-    rb_marshal_define_compat(rb_cEncoding, Qnil, NULL, enc_m_loader);
+    rb_marshal_define_compat(rb_cEncoding, Qnil, 0, enc_m_loader);
 }
 
 void
diff --git a/ext/-test-/typeddata/typeddata.c b/ext/-test-/typeddata/typeddata.c
index ae06096..374cbdf 100644
--- a/ext/-test-/typeddata/typeddata.c
+++ b/ext/-test-/typeddata/typeddata.c
@@ -2,7 +2,7 @@ https://github.com/ruby/ruby/blob/trunk/ext/-test-/typeddata/typeddata.c#L2
 
 static const rb_data_type_t test_data = {
     "typed_data",
-    {NULL, ruby_xfree, NULL},
+    {0, ruby_xfree, 0},
     NULL, NULL,
     0/* deferred free */,
 };
diff --git a/range.c b/range.c
index e182934..8309016 100644
--- a/range.c
+++ b/range.c
@@ -1569,7 +1569,7 @@ r_cover_range_p(VALUE range, VALUE beg, VALUE end, VALUE val) https://github.com/ruby/ruby/blob/trunk/range.c#L1569
         return TRUE;
     }
 
-    val_max = rb_rescue2(r_call_max, val, NULL, Qnil, rb_eTypeError, (VALUE)0);
+    val_max = rb_rescue2(r_call_max, val, 0, Qnil, rb_eTypeError, (VALUE)0);
     if (val_max == Qnil) return FALSE;
 
     return r_less(end, val_max) >= 0;
diff --git a/st.c b/st.c
index 3d95c81..9fababe 100644
--- a/st.c
+++ b/st.c
@@ -1721,7 +1721,7 @@ int https://github.com/ruby/ruby/blob/trunk/st.c#L1721
 st_foreach(st_table *tab, st_foreach_callback_func *func, st_data_t arg)
 {
     const struct functor f = { func, arg };
-    return st_general_foreach(tab, apply_functor, NULL, (st_data_t)&f, FALSE);
+    return st_general_foreach(tab, apply_functor, 0, (st_data_t)&f, FALSE);
 }
 
 /* See comments for function st_delete_safe.  */
@@ -1729,7 +1729,7 @@ int https://github.com/ruby/ruby/blob/trunk/st.c#L1729
 st_foreach_check(st_table *tab, st_foreach_check_callback_func *func, st_data_t arg,
                  st_data_t never ATTRIBUTE_UNUSED)
 {
-    return st_general_foreach(tab, func, NULL, arg, TRUE);
+    return st_general_foreach(tab, func, 0, arg, TRUE);
 }
 
 /* Set up array KEYS by at most SIZE keys of head table TAB entries.
diff --git a/thread.c b/thread.c
index ee73f36..f5efe40 100644
--- a/thread.c
+++ b/thread.c
@@ -488,7 +488,7 @@ static void https://github.com/ruby/ruby/blob/trunk/thread.c#L488
 unblock_function_clear(rb_thread_t *th)
 {
     rb_native_mutex_lock(&th->interrupt_lock);
-    th->unblock.func = NULL;
+    th->unblock.func = 0;
     rb_native_mutex_unlock(&th->interrupt_lock);
 }
 
@@ -961,7 +961,7 @@ thread_initialize(VALUE thread, VALUE args) https://github.com/ruby/ruby/blob/trunk/thread.c#L961
         }
     }
     else {
-        return thread_create_core(thread, args, NULL);
+        return thread_create_core(thread, args, 0);
     }
 }
 
@@ -4582,7 +4582,7 @@ thgroup_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/thread.c#L4582
 
 static const rb_data_type_t thgroup_data_type = {
     "thgroup",
-    {NULL, RUBY_TYPED_DEFAULT_FREE, thgroup_memsize,},
+    {0, RUBY_TYPED_DEFAULT_FREE, thgroup_memsize,},
     0, 0, RUBY_TYPED_FREE_IMMEDIATELY
 };
 
diff --git a/thread_pthread.c b/thread_pthread.c
index cbe6aa0..29284ff 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -587,7 +587,7 @@ Init_native_thread(rb_thread_t *th) https://github.com/ruby/ruby/blob/trunk/thread_pthread.c#L587
         if (r) condattr_monotonic = NULL;
     }
 #endif
-    pthread_key_create(&ruby_native_thread_key, NULL);
+    pthread_key_create(&ruby_native_thread_key, 0);
     th->thread_id = pthread_self();
     fill_thread_id_str(th);
     native_thread_init(th);
diff --git a/thread_sync.c b/thread_sync.c
index efe295e..7af5172 100644
--- a/thread_sync.c
+++ b/thread_sync.c
@@ -78,7 +78,7 @@ static const char* rb_mutex_unlock_th(rb_mutex_t *mutex, rb_thread_t *th); https://github.com/ruby/ruby/blob/trunk/thread_sync.c#L78
  *
  */
 
-#define mutex_mark NULL
+#define mutex_mark ((void(*)(void*))0)
 
 static size_t
 rb_mutex_num_waiting(rb_mutex_t *mutex)
diff --git a/time.c b/time.c
index fcc5f52..61d81e5 100644
--- a/time.c
+++ b/time.c
@@ -5314,8 +5314,8 @@ time_mload(VALUE time, VALUE str) https://github.com/ruby/ruby/blob/trunk/time.c#L5314
     get_attr(nano_num, {});
     get_attr(nano_den, {});
     get_attr(submicro, {});
-    get_attr(offset, (offset = rb_rescue(validate_utc_offset, offset, NULL, Qnil)));
-    get_attr(zone, (zone = rb_rescue(validate_zone_name, zone, NULL, Qnil)));
+    get_attr(offset, (offset = rb_rescue(validate_utc_offset, offset, 0, Qnil)));
+    get_attr(zone, (zone = rb_rescue(validate_zone_name, zone, 0, Qnil)));
     get_attr(year, {});
 
 #undef get_attr
diff --git a/tool/transcode-tblgen.rb b/tool/transcode-tblgen.rb
index 156b2de..c6b58db 100644
--- a/tool/transcode-tblgen.rb
+++ b/tool/transcode-tblgen.rb
@@ -895,9 +895,9 @@ static const rb_transcoder https://github.com/ruby/ruby/blob/trunk/tool/transcode-tblgen.rb#L895
     #{max_input}, /* max_input */
     #{max_output}, /* max_output */
     #{ascii_compatibility}, /* asciicompat_type */
-    0, NULL, NULL, /* state_size, state_init, state_fini */
-    NULL, NULL, NULL, NULL,
-    NULL, NULL, NULL
+    0, 0, 0, /* state_size, state_init, state_fini */
+    0, 0, 0, 0,
+    0, 0, 0
 };
 End
   TRANSCODE_GENERATED_TRANSCODER_CODE << transcoder_code
diff --git a/transcode.c b/transcode.c
index 5cdaaaf..12c35f9 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2925,7 +2925,7 @@ econv_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/transcode.c#L2925
 
 static const rb_data_type_t econv_data_type = {
     "econv",
-    {NULL, econv_free, econv_memsize,},
+    {0, econv_free, econv_memsize,},
     0, 0, RUBY_TYPED_FREE_IMMEDIATELY
 };
 
diff --git a/vm.c b/vm.c
index fae2b68..f2f160b 100644
--- a/vm.c
+++ b/vm.c
@@ -2383,7 +2383,7 @@ vm_memsize(const void *ptr) https://github.com/ruby/ruby/blob/trunk/vm.c#L2383
 
 static const rb_data_type_t vm_data_type = {
     "VM",
-    {NULL, NULL, vm_memsize,},
+    {0, 0, vm_memsize,},
     0, 0, RUBY_TYPED_FREE_IMMEDIATELY
 };
 
@@ -3666,9 +3666,9 @@ usage_analysis_register_clear(VALUE self) https://github.com/ruby/ruby/blob/trunk/vm.c#L3666
 
 #else
 
-MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_insn)(int insn)) = NULL;
-MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_operand)(int insn, int n, VALUE op)) = NULL;
-MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_register)(int reg, int isset)) = NULL;
+MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_insn)(int insn)) = 0;
+MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_operand)(int insn, int n, VALUE op)) = 0;
+MAYBE_UNUSED(static void (*ruby_vm_collect_usage_func_register)(int reg, int isset)) = 0;
 
 #endif
 
-- 
cgit v0.10.2


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

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