From: Ivan Maidanski Date: Mon, 4 Jun 2018 20:04:17 +0000 (+0300) Subject: Eliminate 'cast between incompatible function types' compiler warning X-Git-Tag: v8.0.0~142 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fa40a7127129321a69719dcb8b8b38bf44c1982;p=platform%2Fupstream%2Flibgc.git Eliminate 'cast between incompatible function types' compiler warning * cord/cordxtra.c (refill_cache): Add GC_CALLBACK; change return type from char to void*; change argument type from refill_data* to void*; add necessary casts to client_data and the return expression. * cord/cordxtra.c (CORD_lf_func): Do not cast refill_cache. * os_dep.c [MPROTECT_VDB] (GC_write_fault_handler, GC_mprotect_dirty_init): Cast SIG_DFL, SIG_IGN and oldact.sa_handler to SIG_HNDLR_PTR via signed_word type. * os_dep.c [MPROTECT_VDB && !MSWIN32 && !MSWINCE] (GC_write_fault_handler): Cast old_handler to PLAIN_HNDLR_PTR via signed_word type. --- diff --git a/cord/cordxtra.c b/cord/cordxtra.c index d29f344..62b1f83 100644 --- a/cord/cordxtra.c +++ b/cord/cordxtra.c @@ -527,14 +527,14 @@ typedef struct { } refill_data; /* Executed with allocation lock. */ -static char refill_cache(refill_data * client_data) +static void * GC_CALLBACK refill_cache(void * client_data) { - lf_state * state = client_data -> state; - size_t file_pos = client_data -> file_pos; + lf_state * state = ((refill_data *)client_data) -> state; + size_t file_pos = ((refill_data *)client_data) -> file_pos; FILE *f = state -> lf_file; size_t line_start = LINE_START(file_pos); size_t line_no = DIV_LINE_SZ(MOD_CACHE_SZ(file_pos)); - cache_line * new_cache = client_data -> new_cache; + cache_line * new_cache = ((refill_data *)client_data) -> new_cache; if (line_start != state -> lf_current && fseek(f, (long)line_start, SEEK_SET) != 0) { @@ -550,7 +550,7 @@ static char refill_cache(refill_data * client_data) GC_end_stubborn_change((/* no volatile */ void *)(state -> lf_cache + line_no)); state -> lf_current = line_start + LINE_SZ; - return(new_cache->data[MOD_LINE_SZ(file_pos)]); + return (void *)((GC_word)new_cache->data[MOD_LINE_SZ(file_pos)]); } char CORD_lf_func(size_t i, void * client_data) @@ -568,8 +568,7 @@ char CORD_lf_func(size_t i, void * client_data) rd.file_pos = i; rd.new_cache = GC_NEW_ATOMIC(cache_line); if (rd.new_cache == 0) OUT_OF_MEMORY; - return((char)(GC_word) - GC_call_with_alloc_lock((GC_fn_type) refill_cache, &rd)); + return (char)((GC_word)GC_call_with_alloc_lock(refill_cache, &rd)); } return(cl -> data[MOD_LINE_SZ(i)]); } diff --git a/os_dep.c b/os_dep.c index a12c26a..c43f128 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3263,7 +3263,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) } # endif - if (old_handler == (SIG_HNDLR_PTR)SIG_DFL) { + if (old_handler == (SIG_HNDLR_PTR)(signed_word)SIG_DFL) { # if !defined(MSWIN32) && !defined(MSWINCE) ABORT_ARG1("Unexpected bus error or segmentation fault", " at %p", (void *)addr); @@ -3283,7 +3283,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) ((SIG_HNDLR_PTR)old_handler) (sig, si, raw_sc); else /* FIXME: should pass nonstandard args as well. */ - ((PLAIN_HNDLR_PTR)old_handler) (sig); + ((PLAIN_HNDLR_PTR)(signed_word)old_handler)(sig); return; # endif } @@ -3390,14 +3390,14 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) GC_old_segv_handler = oldact.sa_sigaction; GC_old_segv_handler_used_si = TRUE; } else { - GC_old_segv_handler = (SIG_HNDLR_PTR)oldact.sa_handler; + GC_old_segv_handler = (SIG_HNDLR_PTR)(signed_word)oldact.sa_handler; GC_old_segv_handler_used_si = FALSE; } - if (GC_old_segv_handler == (SIG_HNDLR_PTR)SIG_IGN) { + if (GC_old_segv_handler == (SIG_HNDLR_PTR)(signed_word)SIG_IGN) { WARN("Previously ignored segmentation violation!?\n", 0); - GC_old_segv_handler = (SIG_HNDLR_PTR)SIG_DFL; + GC_old_segv_handler = (SIG_HNDLR_PTR)(signed_word)SIG_DFL; } - if (GC_old_segv_handler != (SIG_HNDLR_PTR)SIG_DFL) { + if (GC_old_segv_handler != (SIG_HNDLR_PTR)(signed_word)SIG_DFL) { GC_VERBOSE_LOG_PRINTF("Replaced other SIGSEGV handler\n"); } # if defined(HPUX) || defined(LINUX) || defined(HURD) \ @@ -3409,19 +3409,19 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) GC_old_bus_handler_used_si = TRUE; # endif } else { - GC_old_bus_handler = (SIG_HNDLR_PTR)oldact.sa_handler; + GC_old_bus_handler = (SIG_HNDLR_PTR)(signed_word)oldact.sa_handler; # if !defined(LINUX) GC_old_bus_handler_used_si = FALSE; # endif } - if (GC_old_bus_handler == (SIG_HNDLR_PTR)SIG_IGN) { + if (GC_old_bus_handler == (SIG_HNDLR_PTR)(signed_word)SIG_IGN) { WARN("Previously ignored bus error!?\n", 0); # if !defined(LINUX) - GC_old_bus_handler = (SIG_HNDLR_PTR)SIG_DFL; + GC_old_bus_handler = (SIG_HNDLR_PTR)(signed_word)SIG_DFL; # else /* GC_old_bus_handler is not used by GC_write_fault_handler. */ # endif - } else if (GC_old_bus_handler != (SIG_HNDLR_PTR)SIG_DFL) { + } else if (GC_old_bus_handler != (SIG_HNDLR_PTR)(signed_word)SIG_DFL) { GC_VERBOSE_LOG_PRINTF("Replaced other SIGBUS handler\n"); } # endif /* HPUX || LINUX || HURD || (FREEBSD && SUNOS5SIGS) */ @@ -3435,7 +3435,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) if (GC_old_segv_handler != NULL) { GC_COND_LOG_PRINTF("Replaced other UnhandledExceptionFilter\n"); } else { - GC_old_segv_handler = SIG_DFL; + GC_old_segv_handler = (signed_word)SIG_DFL; } # elif defined(MSWINCE) /* MPROTECT_VDB is unsupported for WinCE at present. */ @@ -4249,7 +4249,7 @@ GC_INNER GC_bool GC_mprotect_dirty_init(void) /* sa.sa_restorer is deprecated and should not be initialized. */ if (sigaction(SIGBUS, &sa, &oldsa) < 0) ABORT("sigaction failed"); - if ((SIG_HNDLR_PTR)oldsa.sa_handler != SIG_DFL) { + if (oldsa.sa_handler != (SIG_HNDLR_PTR)(signed_word)SIG_DFL) { GC_VERBOSE_LOG_PRINTF("Replaced other SIGBUS handler\n"); } }