From 4ffcadd39cb7061ff501478ed436a56e7f99f3dc Mon Sep 17 00:00:00 2001 From: Takashi Kokubun Date: Fri, 20 Sep 2019 17:44:16 +0900 Subject: [PATCH] Fix rb_define_singleton_method warning for debug counters ``` ../include/ruby/intern.h:1175:137: warning: passing argument 3 of 'rb_define_singleton_method0' from incompatible pointer type [-Wincompatible-pointer-types] #define rb_define_singleton_method(klass, mid, func, arity) rb_define_singleton_method_choose_prototypem3((arity),(func))((klass),(mid),(func),(arity)); ^ ../vm.c:2958:5: note: in expansion of macro 'rb_define_singleton_method' rb_define_singleton_method(rb_cRubyVM, "show_debug_counters", rb_debug_counter_show, 0); ^~~~~~~~~~~~~~~~~~~~~~~~~~ ../include/ruby/intern.h:1139:99: note: expected 'VALUE (*)(VALUE) {aka long unsigned int (*)(long unsigned int)}' but argument is of type 'VALUE (*)(void) {aka long unsigned int (*)(void)}' __attribute__((__unused__,__weakref__("rb_define_singleton_method"),__nonnull__(2,3)))static void rb_define_singleton_method0 (VALUE,const char*,VALUE(*)(VALUE),int); ``` --- debug_counter.c | 4 ++-- debug_counter.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/debug_counter.c b/debug_counter.c index f17b3b4d7c..60cc2c3ac1 100644 --- a/debug_counter.c +++ b/debug_counter.c @@ -44,14 +44,14 @@ rb_debug_counter_show_results(const char *msg) } VALUE -rb_debug_counter_show(void) +rb_debug_counter_show(RB_UNUSED_VAR(VALUE klass)) { rb_debug_counter_show_results("method call"); return Qnil; } VALUE -rb_debug_counter_reset(void) +rb_debug_counter_reset(RB_UNUSED_VAR(VALUE klass)) { for (int i = 0; i < RB_DEBUG_COUNTER_MAX; i++) { switch (i) { diff --git a/debug_counter.h b/debug_counter.h index 3fa644828d..2add2acc25 100644 --- a/debug_counter.h +++ b/debug_counter.h @@ -349,8 +349,8 @@ rb_debug_counter_add(enum rb_debug_counter_type type, int add, int cond) return cond; } -VALUE rb_debug_counter_reset(void); -VALUE rb_debug_counter_show(void); +VALUE rb_debug_counter_reset(VALUE klass); +VALUE rb_debug_counter_show(VALUE klass); #define RB_DEBUG_COUNTER_INC(type) rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, 1) #define RB_DEBUG_COUNTER_INC_UNLESS(type, cond) (!rb_debug_counter_add(RB_DEBUG_COUNTER_##type, 1, !(cond)))