From 0bbab1e5151c3396ebe544d09cad997cd9cb5e3b Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 7 May 2021 00:04:36 +0900 Subject: [PATCH] Protoized old pre-ANSI K&R style declarations and definitions --- dln.c | 16 ++++++++-------- eval_jump.c | 2 +- gc.c | 4 ++-- hash.c | 2 +- include/ruby/thread_native.h | 2 +- internal/gc.h | 2 +- thread_pthread.h | 2 +- vm_insnhelper.c | 4 ++-- vm_method.c | 2 +- vsnprintf.c | 6 ++++-- 10 files changed, 22 insertions(+), 20 deletions(-) diff --git a/dln.c b/dln.c index b0508989d4..ac09430492 100644 --- a/dln.c +++ b/dln.c @@ -312,7 +312,7 @@ dln_load(const char *file) HINSTANCE handle; WCHAR *winfile; char message[1024]; - void (*init_fct)(); + void (*init_fct)(void); char *buf; /* Load the file as an object one */ @@ -341,7 +341,7 @@ dln_load(const char *file) } #endif - if ((init_fct = (void(*)())GetProcAddress(handle, buf)) == NULL) { + if ((init_fct = (void(*)(void))GetProcAddress(handle, buf)) == NULL) { dln_loaderror("%s - %s\n%s", dln_strerror(), buf, file); } @@ -358,7 +358,7 @@ dln_load(const char *file) #define DLN_DEFINED { void *handle; - void (*init_fct)(); + void (*init_fct)(void); #ifndef RTLD_LAZY # define RTLD_LAZY 1 @@ -393,7 +393,7 @@ dln_load(const char *file) } # endif - init_fct = (void(*)())(VALUE)dlsym(handle, buf); + init_fct = (void(*)(void))(VALUE)dlsym(handle, buf); if (init_fct == NULL) { const size_t errlen = strlen(error = dln_strerror()) + 1; error = memcpy(ALLOCA_N(char, errlen), error, errlen); @@ -412,7 +412,7 @@ dln_load(const char *file) { shl_t lib = NULL; int flags; - void (*init_fct)(); + void (*init_fct)(void); flags = BIND_DEFERRED; lib = shl_load(file, flags, 0); @@ -436,9 +436,9 @@ dln_load(const char *file) #if defined(_AIX) #define DLN_DEFINED { - void (*init_fct)(); + void (*init_fct)(void); - init_fct = (void(*)())load((char*)file, 1, 0); + init_fct = (void(*)(void))load((char*)file, 1, 0); if (init_fct == NULL) { aix_loaderror(file); } @@ -467,7 +467,7 @@ dln_load(const char *file) /* "file" is module file name . "buf" is pointer to initial function name with "_" . */ - void (*init_fct)(); + void (*init_fct)(void); dyld_result = NSCreateObjectFileImageFromFile(file, &obj_file); diff --git a/eval_jump.c b/eval_jump.c index 75d4ad0207..2ea73b0da3 100644 --- a/eval_jump.c +++ b/eval_jump.c @@ -48,7 +48,7 @@ rb_f_at_exit(VALUE _) } struct end_proc_data { - void (*func) (); + void (*func) (VALUE); VALUE data; struct end_proc_data *next; }; diff --git a/gc.c b/gc.c index cdc8f4f9da..3adc526ed1 100644 --- a/gc.c +++ b/gc.c @@ -2382,7 +2382,7 @@ rvargc_find_region(size_t size, rb_ractor_t *cr, RVALUE *freelist) #endif int -rb_slot_size() +rb_slot_size(void) { return sizeof(RVALUE); } @@ -4592,7 +4592,7 @@ obj_memsize_of(VALUE obj, int use_all_types) case T_HASH: if (RHASH_AR_TABLE_P(obj)) { if (RHASH_AR_TABLE(obj) != NULL) { - size_t rb_hash_ar_table_size(); + size_t rb_hash_ar_table_size(void); size += rb_hash_ar_table_size(); } } diff --git a/hash.c b/hash.c index ce0e72a017..9b98739c97 100644 --- a/hash.c +++ b/hash.c @@ -4820,7 +4820,7 @@ extern char **environ; #endif static inline rb_encoding * -env_encoding() +env_encoding(void) { #ifdef _WIN32 return rb_utf8_encoding(); diff --git a/include/ruby/thread_native.h b/include/ruby/thread_native.h index 7e08c2e97f..343c02c30d 100644 --- a/include/ruby/thread_native.h +++ b/include/ruby/thread_native.h @@ -47,7 +47,7 @@ typedef pthread_cond_t rb_nativethread_cond_t; RUBY_SYMBOL_EXPORT_BEGIN -rb_nativethread_id_t rb_nativethread_self(); +rb_nativethread_id_t rb_nativethread_self(void); void rb_nativethread_lock_initialize(rb_nativethread_lock_t *lock); void rb_nativethread_lock_destroy(rb_nativethread_lock_t *lock); diff --git a/internal/gc.h b/internal/gc.h index cd87264555..86a2512c85 100644 --- a/internal/gc.h +++ b/internal/gc.h @@ -114,7 +114,7 @@ void rb_gc_mark_vm_stack_values(long n, const VALUE *values); void *ruby_sized_xrealloc(void *ptr, size_t new_size, size_t old_size) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2)); void *ruby_sized_xrealloc2(void *ptr, size_t new_count, size_t element_size, size_t old_count) RUBY_ATTR_RETURNS_NONNULL RUBY_ATTR_ALLOC_SIZE((2, 3)); void ruby_sized_xfree(void *x, size_t size); -int rb_slot_size(); +int rb_slot_size(void); RUBY_SYMBOL_EXPORT_END MJIT_SYMBOL_EXPORT_BEGIN diff --git a/thread_pthread.h b/thread_pthread.h index 8b7583d266..2ac354046c 100644 --- a/thread_pthread.h +++ b/thread_pthread.h @@ -102,7 +102,7 @@ RUBY_SYMBOL_EXPORT_BEGIN #ifdef RB_THREAD_LOCAL_SPECIFIER #ifdef __APPLE__ // on Darwin, TLS can not be accessed across .so - struct rb_execution_context_struct *rb_current_ec(); + struct rb_execution_context_struct *rb_current_ec(void); void rb_current_ec_set(struct rb_execution_context_struct *); #else RUBY_EXTERN RB_THREAD_LOCAL_SPECIFIER struct rb_execution_context_struct *ruby_current_ec; diff --git a/vm_insnhelper.c b/vm_insnhelper.c index 840bd490b6..171b0f4273 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -1857,7 +1857,7 @@ vm_search_method(VALUE cd_owner, struct rb_call_data *cd, VALUE recv) } static inline int -check_cfunc(const rb_callable_method_entry_t *me, VALUE (*func)()) +check_cfunc(const rb_callable_method_entry_t *me, VALUE (*func)(ANYARGS)) { if (! me) { return false; @@ -1876,7 +1876,7 @@ check_cfunc(const rb_callable_method_entry_t *me, VALUE (*func)()) } static inline int -vm_method_cfunc_is(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv, VALUE (*func)()) +vm_method_cfunc_is(const rb_iseq_t *iseq, CALL_DATA cd, VALUE recv, VALUE (*func)(ANYARGS)) { VM_ASSERT(iseq != NULL); const struct rb_callcache *cc = vm_search_method((VALUE)iseq, cd, recv); diff --git a/vm_method.c b/vm_method.c index ffb290d601..be0c1ef719 100644 --- a/vm_method.c +++ b/vm_method.c @@ -416,7 +416,7 @@ static VALUE } static void -setup_method_cfunc_struct(rb_method_cfunc_t *cfunc, VALUE (*func)(), int argc) +setup_method_cfunc_struct(rb_method_cfunc_t *cfunc, VALUE (*func)(ANYARGS), int argc) { cfunc->func = func; cfunc->argc = argc; diff --git a/vsnprintf.c b/vsnprintf.c index 90c827f6a0..8bfa0c1656 100644 --- a/vsnprintf.c +++ b/vsnprintf.c @@ -166,6 +166,8 @@ struct __sbuf { * * NB: see WARNING above before changing the layout of this structure! */ +struct __suio; + typedef struct __sFILE { unsigned char *_p; /* current position in (some) buffer */ #if 0 @@ -178,8 +180,8 @@ typedef struct __sFILE { #if 0 size_t _lbfsize; /* 0 or -_bf._size, for inline putc */ #endif - int (*vwrite)(/* struct __sFILE*, struct __suio * */); - const char *(*vextra)(/* struct __sFILE*, size_t, void*, long*, int */); + int (*vwrite)(struct __sFILE*, struct __suio *); + const char *(*vextra)(struct __sFILE*, size_t, void*, long*, int); } FILE;