This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Patch installed to fix scandir warning in jcf-io.c
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- To: gcc-patches at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: Fri, 17 Jan 2003 09:37:14 -0500 (EST)
- Subject: Patch installed to fix scandir warning in jcf-io.c
I get the following warning bootstrapping on irix6.
> java/jcf-io.c:383: warning: passing arg 3 of `scandir' from incompatible pointer type
If you read the comments in the code below, the warning arises because
scandir isn't standardized and may require arguments differing in
their const-ness on different platforms.
At first I considered writing lots of autoconf hackery to find the
appropriate decl and diddle the const-ness based on that. Sort of
like what the intl stuff does for the iconv() decl. (See AM_ICONV in
gcc/aclocal.m4 in you're interested in the gory details.)
Then sanity came to me and I just added the cast. :-)
Bootstrapped on mips-sgi-irix6.5 (warning gone) and so I installed the
patch as "obvious".
PS: with this fixed, irix6 now bootstraps with -Werror!
2003-01-16 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* jcf-io.c (caching_stat): Cast the 3rd arg of scandir to void*.
diff -rcp orig/egcc-CVS20030116/gcc/java/jcf-io.c egcc-CVS20030116/gcc/java/jcf-io.c
*** orig/egcc-CVS20030116/gcc/java/jcf-io.c Thu Jan 9 17:53:39 2003
--- egcc-CVS20030116/gcc/java/jcf-io.c Thu Jan 16 20:39:17 2003
*************** caching_stat (char *filename, struct sta
*** 368,378 ****
/* 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 rely
! on the ability to interchange these two types of function
! pointers. */
dent->num_files = scandir (filename, &dent->files,
! java_or_class_file,
alphasort);
*slot = dent;
}
--- 368,377 ----
/* 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. */
dent->num_files = scandir (filename, &dent->files,
! (void *) java_or_class_file,
alphasort);
*slot = dent;
}