1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Get rid of type-punning pointer casts

This commit is contained in:
Nobuyoshi Nakada 2022-04-07 19:19:13 +09:00
parent 9e58c3c519
commit 7b1ece9b94
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
4 changed files with 18 additions and 17 deletions

View file

@ -2706,7 +2706,7 @@ obj_refer_only_shareables_p(VALUE obj)
static int
obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
{
VALUE replacement;
st_data_t replacement;
if (RB_SPECIAL_CONST_P(obj)) {
data->replacement = obj;
@ -2719,14 +2719,14 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
case traverse_stop: return 1; // stop search
}
replacement = data->replacement;
replacement = (st_data_t)data->replacement;
if (UNLIKELY(st_lookup(obj_traverse_replace_rec(data), (st_data_t)obj, (st_data_t *)&replacement))) {
data->replacement = replacement;
if (UNLIKELY(st_lookup(obj_traverse_replace_rec(data), (st_data_t)obj, &replacement))) {
data->replacement = (VALUE)replacement;
return 0;
}
else {
st_insert(obj_traverse_replace_rec(data), (st_data_t)obj, (st_data_t)replacement);
st_insert(obj_traverse_replace_rec(data), (st_data_t)obj, replacement);
}
if (!data->move) {
@ -2872,7 +2872,7 @@ obj_traverse_replace_i(VALUE obj, struct obj_traverse_replace_data *data)
rb_bug("unreachable");
}
data->replacement = replacement;
data->replacement = (VALUE)replacement;
if (data->leave_func(obj, data) == traverse_stop) {
return 1;
@ -3052,9 +3052,9 @@ ractor_local_storage_mark(rb_ractor_t *r)
for (int i=0; i<freed_ractor_local_keys.cnt; i++) {
rb_ractor_local_key_t key = freed_ractor_local_keys.keys[i];
st_data_t val;
if (st_delete(r->local_storage, (st_data_t *)&key, &val) &&
key->type->free) {
st_data_t val, k = (st_data_t)key;
if (st_delete(r->local_storage, &k, &val) &&
(key = (rb_ractor_local_key_t)k)->type->free) {
(*key->type->free)((void *)val);
}
}
@ -3179,9 +3179,9 @@ ractor_local_set(rb_ractor_local_key_t key, void *ptr)
VALUE
rb_ractor_local_storage_value(rb_ractor_local_key_t key)
{
VALUE val;
if (ractor_local_ref(key, (void **)&val)) {
return val;
void *val;
if (ractor_local_ref(key, &val)) {
return (VALUE)val;
}
else {
return Qnil;

View file

@ -1021,8 +1021,9 @@ rb_vm_lookup_overloaded_cme(const rb_callable_method_entry_t *cme)
static void
delete_overloaded_cme(const rb_callable_method_entry_t *cme)
{
st_data_t cme_data = (st_data_t)cme;
ASSERT_vm_locking();
st_delete(overloaded_cme_table(), (st_data_t *)&cme, NULL);
st_delete(overloaded_cme_table(), &cme_data, NULL);
}
static const rb_callable_method_entry_t *

View file

@ -855,7 +855,7 @@ socklist_lookup(SOCKET sock, int *flagp)
thread_exclusive(socklist) {
if (!socklist) continue;
ret = st_lookup(socklist, (st_data_t)sock, (st_data_t *)&data);
ret = st_lookup(socklist, (st_data_t)sock, &data);
if (ret && flagp)
*flagp = (int)data;
}

View file

@ -3212,9 +3212,9 @@ jit_thread_s_current(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci,
static method_codegen_t
lookup_cfunc_codegen(const rb_method_definition_t *def)
{
method_codegen_t gen_fn;
if (st_lookup(yjit_method_codegen_table, def->method_serial, (st_data_t *)&gen_fn)) {
return gen_fn;
st_data_t gen_fn;
if (st_lookup(yjit_method_codegen_table, def->method_serial, &gen_fn)) {
return (method_codegen_t)gen_fn;
}
return NULL;
}