httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d...@ast.cam.ac.uk (David Robinson)
Subject Re: Two small bugs in Apache 0.8.4 (fwd)
Date Fri, 04 Aug 1995 18:28:00 GMT
Rob wrote:
> System:  SunOS 4.1.4; Sparc 10/51; Apache 0.8.4
> 
> 1)  conf.h: 
> > #if defined(SUNOS4) && !defined(__SUNPRO_C)
> > /* Prototypes needed to get a clean compile with gcc -Wall.
> >  * Believe it or not, these do have to be declared, at least on SunOS,
> >  * because they aren't mentioned in the relevant system headers.
> >  * Sun Quality Software.  Gotta love it.
> 
> I have the GNU libraries installed, and get a bunch of:
> > conf.h:361: conflicting types for `strcasecmp'
> > /usr/GNU/lib/gcc-lib/sparc-sun-sunos4.1.3/2.6.0/include/string.h:32:
> > previous declaration of `strcasecmp'
> > conf.h:362: conflicting types for `strncasecmp'
> > /usr/GNU/lib/gcc-lib/sparc-sun-sunos4.1.3/2.6.0/include/string.h:34:
> > previous declaration of `strncasecmp'
> etc.
> > make: *** [alloc.o] Error 1
> 
> I had to comment out that part of conf.h to get things to compile.
> Perhaps a check to see if the GNU includes are there before declaring
> in conf.h?

Yuk yuk yuk. Putting prototypes for library routines is the wrong thing
to do _especially_ if the prototypes are incorrect.

The only occasion that prototyping library routines can be safe is if the
it is done for a historic, unchanging operating system. You might think
that SunOS would fit this, but in fact it is SunOS + gcc that must be
frozen. Gcc provides prototypes for some of the library routines, but
precisely which routines seems to be version dependent.

Fixes:
1. #include <strings.h>. This provides some missing prototypes.
2. #define  __USE_FIXED_PROTOTYPES__ before #including the system headers.
   This causes the headers that gcc has fixed (stdio.h etc.) to contain
   more prototypes.

Unfortunately 1+2 do not provide prototypes for all the routines needed by
apache. The patch below implements 1+2, and supplies corrected versions of the
remaining missing prototypes. It seems to work under gcc 2.6 and 2.7
(SunOS 4.1.2).

I would suggest dropping _all_ the prototypes from the header files, and
just relying on fixes 1+2 (above). If you want to get rid of the -Wall
warnings, upgrade to Solaris 2.

Seriously though, leaving out the prototypes provokes compilation warnings
only with -Wall. Whereas including the prototypes runs the risk of compilation
failure under some (maybe future) OS/gcc versions.

 David.


------------------------------ conf.patch ------------------------------
*** conf.h.orig	Fri Aug  4 00:59:50 1995
--- conf.h	Fri Aug  4 18:06:31 1995
***************
*** 71,76 ****
--- 71,83 ----
  #undef NO_SETSID
  char *crypt(char *pw, char *salt);
  #define JMP_BUF sigjmp_buf
+ #if defined(__GNUC__)
+ /* Prototypes needed to get a clean compile with gcc -Wall.
+  * This #define causes the gcc headers to show the prototypes that
+  * gcc invented.
+  */
+ #define __USE_FIXED_PROTOTYPES__
+ #endif
       
  #elif defined(SOLARIS2)
  #undef BSD
***************
*** 359,413 ****
   * because they aren't mentioned in the relevant system headers.
   * Sun Quality Software.  Gotta love it.
   */
  
! int getopt (int, char **, char *);
  
! int strcasecmp (char *, char *);
! int strncasecmp (char *, char *, int);
! int toupper(int);
! int tolower(int);     
!      
! int printf (char *, ...);     
! int fprintf (FILE *, char *, ...);
! int fputs (char *, FILE *);
! int fread (char *, int, int, FILE *);     
! int fwrite (char *, int, int, FILE *);     
! int fflush (FILE *);
! int fclose (FILE *);
! int ungetc (int, FILE *);
! int _filbuf (FILE *);		/* !!! */
! int _flsbuf (unsigned char, FILE *); /* !!! */
! int sscanf (char *, char *, ...);
! void setbuf (FILE *, char *);
! void perror (char *);
!      
! time_t time (time_t *);
! int strftime (char *, int, char *, struct tm *);
!      
! int initgroups (char *, int);     
! int wait3 (int *, int, void*);	/* Close enough for us... */
! int lstat (const char *, struct stat *);
! int stat (const char *, struct stat *);     
! int flock (int, int);
! int getwd (char *);
! #ifndef NO_KILLPG
! int killpg(int, int);
! #endif
! int socket (int, int, int);     
! int setsockopt (int, int, int, const char*, int);
! int listen (int, int);     
! int bind (int, struct sockaddr *, int);     
! int connect (int, struct sockaddr *, int);
! int accept (int, struct sockaddr *, int *);
! int shutdown (int, int);     
  
! int getsockname (int s, struct sockaddr *name, int *namelen);
! int getpeername (int s, struct sockaddr *name, int *namelen);
! int gethostname (char *name, int namelen);     
! void syslog (int, char *, ...);
! char *mktemp (char *);
!      
! #include <stdarg.h>
! long vfprintf (FILE *, char *, va_list);
!      
  #endif
--- 366,392 ----
   * because they aren't mentioned in the relevant system headers.
   * Sun Quality Software.  Gotta love it.
   */
+ #include <strings.h>
+ extern int strncasecmp (const char *, const char *, int); /* annoying */
+ extern int toupper(int);
+ extern int tolower(int);     
  
! extern time_t time (time_t *);
  
! extern int initgroups (const char *, int);     
! extern char *getwd (char *);
! extern int killpg(int, int);
! extern int socket (int, int, int);     
! extern int setsockopt (int, int, int, const char*, int);
! extern int listen (int, int);     
! extern int bind (int, const struct sockaddr *, int);     
! extern int connect (int, struct sockaddr *, int);
! extern int accept (int, struct sockaddr *, int *);
! extern int shutdown (int, int);     
  
! extern int getsockname (int s, struct sockaddr *name, int *namelen);
! extern int getpeername (int s, struct sockaddr *name, int *namelen);
! extern int gethostname (char *name, int namelen);     
! extern void syslog (int, char *, ...);
! extern char *mktemp (char *);
  #endif
------------------------------ conf.patch ------------------------------

Mime
View raw message