On Thursday 19 June 2008 15:33:14 Parrot via RT wrote:
> "src/packfile.c", line 351: warning: argument #1 is incompatible with
> prototype:
>         prototype: pointer to char : "/usr/include/sys/mman.h", line 161
>         argument : pointer to long
> "src/packfile.c", line 878: warning: argument #1 is incompatible with
> prototype:
>         prototype: pointer to char : "/usr/include/sys/mman.h", line 161
>         argument : pointer to long

I'm concluding that these warnings are due to incorrect casting inside of 
packfile.c.

In both cases, the code generating the warnings looks like this:

        munmap(PARROT_const_cast(opcode_t *, pf->src), pf->size);

pf->src is a const opcode_t* and the purpose of the PARROT_const_cast is to 
drop the const. The first argument to munmap() is a void* on Linux and Mac, 
but a char* on Solaris;  I tried globally defining the feature-test macros 
_POSIX_C_SOURCE or _XPG4_2, but these are supposed to be an all-or-nothing 
choice, and in both cases they broke the build elsewhere.

In C any pointer auto-converts to a void*, but has to be cast to any other 
pointer type such as a char*. If we change the above casts to void* the 
warning on Solaris goes away. I have checked this on Linux and it builds 
fine.  Hence the attached patch to packfile.c

- Andrew
-- 
Talk is cheap. Show me the code. -- Linus Torvalds
Index: src/packfile.c
===================================================================
--- src/packfile.c	(revision 28514)
+++ src/packfile.c	(working copy)
@@ -348,7 +348,7 @@
 #ifdef PARROT_HAS_HEADER_SYSMMAN
     if (pf->is_mmap_ped) {
         DECL_CONST_CAST;
-        munmap(PARROT_const_cast(opcode_t *, pf->src), pf->size);
+        munmap(PARROT_const_cast(void *, pf->src), pf->size);
     }
 #endif
 
@@ -875,7 +875,7 @@
     if (self->is_mmap_ped
     && (self->need_endianize || self->need_wordsize)) {
         DECL_CONST_CAST;
-        munmap(PARROT_const_cast(opcode_t *, self->src), self->size);
+        munmap(PARROT_const_cast(void *, self->src), self->size);
         self->is_mmap_ped = 0;
     }
 #endif

Reply via email to