Prefer 0 over NULL as function pointers

SunC warns use of `NULL`, pointer to data as function pointers.
This commit is contained in:
Nobuyoshi Nakada 2023-06-23 03:15:55 +09:00 committed by GitHub
parent 52f8de4f21
commit b934976024
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
Notes: git 2023-06-22 18:16:14 +00:00
Merged: https://github.com/ruby/ruby/pull/7972

Merged-By: nobu <nobu@ruby-lang.org>
5 changed files with 5 additions and 5 deletions

View File

@ -249,7 +249,7 @@ class_alloc(VALUE flags, VALUE klass)
*/
RCLASS_SET_ORIGIN((VALUE)obj, (VALUE)obj);
RB_OBJ_WRITE(obj, &RCLASS_REFINED_CLASS(obj), Qnil);
RCLASS_SET_ALLOCATOR((VALUE)obj, NULL);
RCLASS_SET_ALLOCATOR((VALUE)obj, 0);
return (VALUE)obj;
}

View File

@ -148,7 +148,7 @@ static inline rb_alloc_func_t
RCLASS_ALLOCATOR(VALUE klass)
{
if (FL_TEST_RAW(klass, FL_SINGLETON)) {
return NULL;
return 0;
}
return RCLASS_EXT(klass)->as.class.allocator;
}

View File

@ -648,7 +648,7 @@ ractor_sleep_with_cleanup(rb_execution_context_t *ec, rb_ractor_t *cr, enum rb_r
static enum rb_ractor_wakeup_status
ractor_sleep(rb_execution_context_t *ec, rb_ractor_t *cr, enum rb_ractor_wait_status wait_status)
{
return ractor_sleep_with_cleanup(ec, cr, wait_status, NULL, NULL);
return ractor_sleep_with_cleanup(ec, cr, wait_status, 0, NULL);
}
// Ractor.receive

View File

@ -1871,7 +1871,7 @@ rb_data_with(int argc, const VALUE *argv, VALUE self)
}
VALUE h = rb_struct_to_h(self);
rb_hash_update_by(h, kwargs, NULL);
rb_hash_update_by(h, kwargs, 0);
return rb_class_new_instance_kw(1, &h, rb_obj_class(self), TRUE);
}

2
time.c
View File

@ -5828,7 +5828,7 @@ Init_Time(void)
if (debug_find_time_numguess) {
rb_define_hooked_variable("$find_time_numguess", (VALUE *)&find_time_numguess,
find_time_numguess_getter, NULL);
find_time_numguess_getter, 0);
}
rb_cTimeTM = Init_tm(rb_cTime, "tm");