]> granicus.if.org Git - gc/commitdiff
Eliminate 'cast between incompatible function types' compiler warning
authorIvan Maidanski <ivmai@mail.ru>
Mon, 4 Jun 2018 20:04:17 +0000 (23:04 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Sun, 8 Jul 2018 20:57:52 +0000 (23:57 +0300)
(a cherry-pick of commits 0fa40a713134dee3 from 'master')

* 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 (except for when assigning
SIG_DFL to GC_old_segv_handler).
* os_dep.c [MPROTECT_VDB && !MSWIN32 && !MSWINCE]
(GC_write_fault_handler): Cast old_handler to PLAIN_HNDLR_PTR via
signed_word type.

cord/cordxtra.c
os_dep.c

index 110196422cce82bec65eaf2f1f51aa8f8930ea13..b89f1a30746a73dc2392c2b372ce29af08fea301 100644 (file)
@@ -526,14 +526,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)
 {
-    register lf_state * state = client_data -> state;
-    register size_t file_pos = client_data -> file_pos;
+    register lf_state * state = ((refill_data *)client_data) -> state;
+    register 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) {
@@ -547,7 +547,7 @@ static char refill_cache(refill_data * client_data)
     /* Store barrier goes here. */
     ATOMIC_WRITE(state -> lf_cache[line_no], new_cache);
     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)
@@ -565,8 +565,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)]);
 }
index 74891f465110ff1dd0cc889cd0778b8384c6f60d..249a2ceefedd57a743a3cfdc4cd6f70035a2223f 100644 (file)
--- a/os_dep.c
+++ b/os_dep.c
@@ -3281,7 +3281,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);
@@ -3301,7 +3301,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
             }
@@ -3419,14 +3419,14 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
         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) \
@@ -3438,19 +3438,19 @@ GC_INNER void GC_remove_protection(struct hblk *h, word nblocks,
           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) */
@@ -4172,7 +4172,7 @@ GC_INNER GC_bool GC_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");
       }
     }