[ruby/fiddle] Cast via VALUE function pointer between object

pointer
(https://github.com/ruby/fiddle/pull/150)

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
This commit is contained in:
Nobuyoshi Nakada 2024-10-10 14:16:04 +09:00
parent 3fdf0e7e6d
commit cd611becbb
No known key found for this signature in database
GPG Key ID: 3582D74E1FEE4465
2 changed files with 2 additions and 2 deletions

View File

@ -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);

View File

@ -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);
}
/*