This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[patch]: fix warning regression in jcf-io.c


As noted in the comments inline, it used to be enough to cast the
function pointer to (void*), but some new pedantic warnings require a
bit of extra effort to silence.

Fixes:
 > jcf-io.c:382: warning: ISO C forbids conversion of function pointer to object pointer type
 > jcf-io.c:383: warning: ISO C forbids passing argument 3 of scandir between function pointer and void *

Bootstrapped on i686-pc-linux-gnu, ok for mainline?

		Thanks,
		--Kaveh


2005-01-01  Kaveh R. Ghazi  <ghazi@caip.rutgers.edu>

	* jcf-io.c (caching_stat): Use __extension__ to avoid pedantic
	warning.
	* Make-lang.in: Don't elide warnings in jcf-io.c.

diff -rc5p orig/egcc-CVS20041231/gcc/java/jcf-io.c egcc-CVS20041231/gcc/java/jcf-io.c
*** orig/egcc-CVS20041231/gcc/java/jcf-io.c	2004-10-17 18:51:35.000000000 -0400
--- egcc-CVS20041231/gcc/java/jcf-io.c	2005-01-01 09:36:49.000000000 -0500
*************** caching_stat (char *filename, struct sta
*** 374,388 ****
        dent->dir = xstrdup (filename);
        /* Unfortunately, scandir is not fully standardized.  In
  	 particular, the type of the function pointer passed as the
  	 third argument sometimes takes a "const struct dirent *"
  	 parameter, and sometimes just a "struct dirent *".  We cast
! 	 to (void *) so that either way it is quietly accepted.
! 	 FIXME: scandir is not in POSIX.  */
!       dent->num_files = scandir (filename, &dent->files, 
! 				 (void *) java_or_class_file, 
! 				 alphasort);
        *slot = dent;
      }
    else
      dent = *((memoized_dirlist_entry **) slot);
  
--- 374,388 ----
        dent->dir = xstrdup (filename);
        /* Unfortunately, scandir is not fully standardized.  In
  	 particular, the type of the function pointer passed as the
  	 third argument sometimes takes a "const struct dirent *"
  	 parameter, and sometimes just a "struct dirent *".  We cast
! 	 to (void *) and use __extension__ so that either way it is
! 	 quietly accepted.  FIXME: scandir is not in POSIX.  */
!       dent->num_files = __extension__ scandir (filename, &dent->files, 
! 					       (void *) java_or_class_file, 
! 					       alphasort);
        *slot = dent;
      }
    else
      dent = *((memoized_dirlist_entry **) slot);
  
diff -rc5p orig/egcc-CVS20041231/gcc/java/Make-lang.in egcc-CVS20041231/gcc/java/Make-lang.in
*** orig/egcc-CVS20041231/gcc/java/Make-lang.in	2004-12-06 12:59:57.000000000 -0500
--- egcc-CVS20041231/gcc/java/Make-lang.in	2005-01-01 09:37:30.000000000 -0500
*************** jvspec.o-warn = -Wno-error
*** 127,139 ****
  
  # Bison-1.75 output often yields (harmless) -Wtraditional warnings
  java/parse-scan.o-warn = -Wno-error
  java/parse.o-warn = -Wno-error
  
- # Use of non-standardized scandir
- java/jcf-io.o-warn = -Wno-error
- 
  jc1$(exeext): $(JAVA_OBJS) $(BACKEND) $(LIBDEPS)
  	rm -f $@
  	$(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
  		$(JAVA_OBJS) $(BACKEND) $(ZLIB) $(LIBICONV) $(LIBS)
  


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]