Warning fixes for r1648

Bug #288824 reported by Michael D. Adams
2
Affects Status Importance Assigned to Milestone
Ikarus Scheme
Fix Committed
Low
Abdulaziz Ghuloum

Bug Description

Attached is a patch to fix a few warnings I found. Below is an explanation of the warnings and how they were fixed. After that are listed some warnings that I found that were not fixed in the patch.

FIXED WARNINGS:

ikarus-ffi.c:193: warning: ‘dump_stack’ defined but not used
  - guard with #ifdef DEBUG_FFI

ikarus-ffi.c:338: warning: ISO C forbids passing argument 2 of ‘ffi_call’ between function pointer and ‘void *’
  - use "void (*fn)() = FFI_FN(...)"

ikarus-numerics.c:804: warning: pointer of type ‘void *’ used in arithmetic
  - "(void*)res+disp_bignum_data" --> "(void*)(res+disp_bignum_data)"

ikarus-ffi.c:173: warning: comparison between signed and unsigned
ikarus-ffi.c:328: warning: comparison between signed and unsigned
ikarus-ffi.c:340: warning: comparison between signed and unsigned
ikarus-ffi.c:405: warning: comparison between signed and unsigned
  - make "i" into "unsigned int"

UNFIXED WARNINGS: The following are warnings I didn't know if or how they should be fixed

ikarus-runtime.c:126: warning: comparison between signed and unsigned
  - Maybe use "unsigned long int size" in function signature?
  - If change, ensure ik_munmap is consistent with ik_munmap_from_segmant.

ikarus-collect.c:1363: warning: comparison between signed and unsigned
  - the problem is "relative_distance != (int)relative_distance"
  - added in r1544
  - seems to be intentional but I'm not sure what the motive is or if there is a better way
  - if kept should have a comment explaining what it is about

Related branches

Revision history for this message
Michael D. Adams (mdmkolbe) wrote :
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Thanks!, fixed in rev 1653.
Re:
ikarus-collect.c:1363: warning: comparison between signed and unsigned
  - the problem is "relative_distance != (int)relative_distance"
  - added in r1544
  - seems to be intentional but I'm not sure what the motive is or if there is a better way
  - if kept should have a comment explaining what it is about

I changed that test to be:
        if(((long int)relative_distance) != ((long)((int)relative_distance))){
which means: does the value change if cast to an int. I think it's as clear as C could be. :-)

BTW, and maybe I asked you this before, but what version of gcc do you use, and what flags do you give it?

Changed in ikarus:
importance: Undecided → Low
status: New → Fix Committed
assignee: nobody → aghuloum
Revision history for this message
Michael D. Adams (mdmkolbe) wrote :

I use GCC 4.2.4 and I pass it '-W -Wall -pedantic' by using "make CFLAGS='-W -Wall -pedantic'". The stderr output I capture and filter to remove some of the more common but useless errors (e.g. "C90 forbids mixing declarations and code").

Revision history for this message
Michael D. Adams (mdmkolbe) wrote :

Ok, a few problems cropped up when you applied the changes:

ikarus-ffi.c:191: #ifdef DEBUG_FFI has extra spaces after it
ikarus-ffi.c:325: you now have it as "void (*fn)() = (void*) ..." but assigning a void* to a void(*fn)() is not legal without a cast.
  Either change it to "void (*fn)() = (void (*fn)()) ..." to explicitly do the cast or use the FFI_FN macro provided by libffi to do the cast for you.

ikarus-runtime.c:215: type of mapsize needs to be "unsigned long int" to make the comparison with size in the assert on the next line happy.
ikarus-runtime.c:258: The printf needs to use %016lx form instead of %016x form at least for the second argument which has the unsigned long mapsize in it. (Compare this with line 235 which is ok.)

Changed in ikarus:
status: Fix Committed → New
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed again in revision 1656.

Changed in ikarus:
status: New → Fix Committed
Revision history for this message
leppie (leppie) wrote :

Here is one that still comes up on Cygwin (not sure if present elsewhere):

gcc -DHAVE_CONFIG_H -I. -I.. -g -O2 -DNDEBUG -O3 -Wall -MT ikarus-runtime.o -MD -MP -MF .deps/ikarus-runtime.Tpo -c -o ikarus-runtime.o ikarus-runtime.c
ikarus-runtime.c: In function `ik_munmap':
ikarus-runtime.c:255: warning: passing arg 1 of `win_munmap' makes pointer from integer without a cast

Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in 1660. Thanks.

(btw, you should reopen a closed bug if you think it still needs fixing, like in this case)

Revision history for this message
leppie (leppie) wrote :

> like in this case

Ok :)

Revision history for this message
Michael D. Adams (mdmkolbe) wrote :

When you fixed it, you still missed these two (maybe you are compiling with -DNDEBUG):

ikarus-runtime.c:215: type of mapsize needs to be "unsigned long int" to make the comparison with size in the assert on the next line happy.
ikarus-runtime.c:258: The printf needs to use %016lx form instead of %016x form at least for the second argument which has the unsigned long mapsize in it. (Compare this with line 235 which is ok.)

Changed in ikarus:
status: Fix Committed → Confirmed
Revision history for this message
Abdulaziz Ghuloum (aghuloum) wrote :

Fixed in 1686.

Changed in ikarus:
status: Confirmed → Fix Committed
Changed in ikarus:
milestone: none → 0.0.4
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.