Skip to content

Commit

Permalink
Prefer 0 over NULL as function pointers
Browse files Browse the repository at this point in the history
SunC warns use of `NULL`, pointer to data as function pointers.
  • Loading branch information
nobu committed Jun 22, 2023
1 parent 52f8de4 commit b934976
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion class.c
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion internal/class.h
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion ractor.c
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion struct.c
Expand Up @@ -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);
}

Expand Down
2 changes: 1 addition & 1 deletion time.c
Expand Up @@ -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");
Expand Down

0 comments on commit b934976

Please sign in to comment.