From cd611becbbb31217575c2031682612d36f7a2fc4 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Thu, 10 Oct 2024 14:16:04 +0900 Subject: [PATCH] [ruby/fiddle] Cast via `VALUE` function pointer between object pointer (https://github.com/ruby/fiddle/pull/150) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With gcc 13 and -pedantic: ``` ../../../src/ext/fiddle/function.c: In function ‘function_call’: ../../../src/ext/fiddle/function.c:374:15: error: ISO C forbids conversion of object pointer to function pointer type [-Wpedantic] 374 | args.fn = (void(*)(void))NUM2PTR(cfunc); | ^ ../../../src/ext/fiddle/pointer.c: In function ‘rb_fiddle_ptr_inspect’: ../../../src/ext/fiddle/pointer.c:573:84: error: ISO C forbids conversion of function pointer to object pointer type [-Wpedantic] 573 | RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free); | ^ ``` https://github.com/ruby/fiddle/commit/6421e317a1 --- ext/fiddle/function.c | 2 +- ext/fiddle/pointer.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/fiddle/function.c b/ext/fiddle/function.c index b6a105abe1..73dfb129a5 100644 --- a/ext/fiddle/function.c +++ b/ext/fiddle/function.c @@ -371,7 +371,7 @@ function_call(int argc, VALUE argv[], VALUE self) args.values[i_call] = (void *)&generic_args[i_call]; } args.values[i_call] = NULL; - args.fn = (void(*)(void))NUM2PTR(cfunc); + args.fn = (void(*)(void))(VALUE)NUM2PTR(cfunc); if (RTEST(need_gvl)) { ffi_call(args.cif, args.fn, &(args.retval), args.values); diff --git a/ext/fiddle/pointer.c b/ext/fiddle/pointer.c index 1b7d7a69f6..5c375fe9d2 100644 --- a/ext/fiddle/pointer.c +++ b/ext/fiddle/pointer.c @@ -570,7 +570,7 @@ rb_fiddle_ptr_inspect(VALUE self) TypedData_Get_Struct(self, struct ptr_data, &fiddle_ptr_data_type, data); return rb_sprintf("#<%"PRIsVALUE":%p ptr=%p size=%ld free=%p>", - RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)data->free); + RB_OBJ_CLASSNAME(self), (void *)data, data->ptr, data->size, (void *)(VALUE)data->free); } /*