From 0346cbbc148a6eec2f3a5b840758b00b51b3d016 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Tue, 5 Dec 2023 17:54:37 -0500 Subject: Fix parameter types for rb_ivar_foreach() callbacks For this public API, the callback is declared to take `(ID, VALUE, st_data_t)`, but it so happens that using `(st_data_t, st_data_t, st_data_t)` also type checks, because the underlying type is identical. Use it as declared and get rid of some casts. --- variable.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'variable.c') diff --git a/variable.c b/variable.c index e4b366631c..b3c74c2596 100644 --- a/variable.c +++ b/variable.c @@ -2127,9 +2127,8 @@ rb_ivar_count(VALUE obj) } static int -ivar_i(st_data_t k, st_data_t v, st_data_t a) +ivar_i(ID key, VALUE v, st_data_t a) { - ID key = (ID)k; VALUE ary = (VALUE)a; if (rb_is_instance_id(key)) { @@ -3999,9 +3998,8 @@ rb_define_class_variable(VALUE klass, const char *name, VALUE val) } static int -cv_i(st_data_t k, st_data_t v, st_data_t a) +cv_i(ID key, VALUE v, st_data_t a) { - ID key = (ID)k; st_table *tbl = (st_table *)a; if (rb_is_class_id(key)) { @@ -4216,9 +4214,9 @@ rb_class_ivar_set(VALUE obj, ID id, VALUE val) } static int -tbl_copy_i(st_data_t key, st_data_t val, st_data_t dest) +tbl_copy_i(ID key, VALUE val, st_data_t dest) { - rb_class_ivar_set(dest, key, val); + rb_class_ivar_set((VALUE)dest, key, val); return ST_CONTINUE; } -- cgit v1.2.3