Subject: port-i386/1070: Warnings in i386 startup code
To: None <gnats-admin@sun-lamp.cs.berkeley.edu>
From: Thorsten Lockert <tholo@SigmaSoft.COM>
List: netbsd-bugs
Date: 05/19/1995 21:20:05
>Number:         1070
>Category:       port-i386
>Synopsis:       Warnings in i386 startup code
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    gnats-admin (GNATS administrator)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Fri May 19 21:20:03 1995
>Originator:     Thorsten Lockert
>Organization:
SigmaSoft, Th. Lockert
>Release:        May 7th, 1995
>Environment:
	
System: NetBSD gandalf.sigmasoft.com 1.0A NetBSD 1.0A (GANDALF) #1: Sun May 7 21:49:27 PDT 1995 tholo@gandalf.sigmasoft.com:/usr/src/sys/arch/i386/compile/GANDALF i386


>Description:
	There are multiple compile-time warnings in src/lib/csu/i386/crt0.c
	if compiled with -Wall and -Wstrict-prototypes

	Function declarations also do not follow the coding convention
>How-To-Repeat:
	Add "-Wall -Wstrict-prototypes" to CFLAGS in src/lib/csu/Makefile
>Fix:
	Apply the following patch:

--- src/lib/csu/i386/crt0.c.orig	Fri May 19 20:35:09 1995
+++ src/lib/csu/i386/crt0.c	Fri May 19 21:03:22 1995
@@ -35,9 +35,6 @@
 static char sccsid[] = "%W% (Erasmus) %G%";
 #endif /* LIBC_SCCS and not lint */
 
-extern void exit();
-int _callmain();
-
 #include <sys/param.h>
 
 #ifdef DYNAMIC
@@ -55,13 +52,19 @@
 #define MAP_COPY	MAP_PRIVATE
 #define MAP_ANON	0
 #endif
+#include <stdlib.h>
 #include <link.h>
 
+int _callmain __P((void));
+int main __P((int, char **, char **));
+
 extern struct _dynamic _DYNAMIC;
 static struct ld_entry	*ld_entry;
-static void	__do_dynamic_link ();
-static char	*_getenv();
-static int	_strncmp();
+static void	__do_dynamic_link __P((void));
+#ifdef DEBUG
+static char	*_getenv __P((char *));
+static int	_strncmp __P((char *, char *, int));
+#endif
 
 #ifdef sun
 #define LDSO	"/usr/lib/ld.so"
@@ -72,15 +75,16 @@
 
 #endif /* DYNAMIC */
 
-static char		*_strrchr();
+static char		*_strrchr __P((char *, char));
+int			__syscall __P((int, ...));
 
 char			**environ;
 
 #ifdef BSD
 extern	unsigned char	etext;
 extern	unsigned char	eprol asm ("eprol");
-extern			start() asm("start");
-extern			mcount() asm ("mcount");
+extern	void		start __P((void)) asm("start");
+extern	void		mcount __P((void)) asm ("mcount");
 
 int			errno;
 static char		empty[1];
@@ -110,7 +114,7 @@
 	write(2, str, sizeof(str)), \
 	_exit(1);
 
-
+void
 start()
 {
 	struct kframe {
@@ -125,7 +129,10 @@
 	register struct kframe *kfp;
 	register char **targv;
 	register char **argv;
-	extern void _mcleanup();
+#ifdef MCRT0
+	extern void monstartup __P((u_long, u_long));
+	extern void _mcleanup __P((void));
+#endif
 #ifdef DYNAMIC
 	volatile caddr_t x;
 #endif
@@ -165,7 +172,7 @@
 
 #ifdef MCRT0
 	atexit(_mcleanup);
-	monstartup(&eprol, &etext);
+	monstartup((u_long)&eprol, (u_long)&etext);
 #endif MCRT0
 
 asm ("__callmain:");		/* Defined for the benefit of debuggers */
@@ -179,8 +186,7 @@
 	struct crt_ldso	crt;
 	struct exec	hdr;
 	char		*ldso;
-	int		dupzfd;
-	int		(*entry)();
+	int		(*entry) __P((int, struct crt_ldso *));
 
 #ifdef DEBUG
 	/* Provision for alternate ld.so - security risk! */
@@ -245,7 +251,7 @@
 	crt.crt_bp = (caddr_t)_callmain;
 	crt.crt_prog = __progname;
 
-	entry = (int (*)())(crt.crt_ba + sizeof hdr);
+	entry = (int (*) __P((int, struct crt_ldso *)))(crt.crt_ba + sizeof hdr);
 	if ((*entry)(CRT_VERSION_BSD_3, &crt) == -1) {
 		_FATAL("ld.so failed\n");
 	}
@@ -305,10 +311,11 @@
  * Support routines
  */
 
+#ifdef DEBUG
 static int
 _strncmp(s1, s2, n)
 	register char *s1, *s2;
-	register n;
+	register int n;
 {
 
 	if (n == 0)
@@ -338,6 +345,7 @@
 			}
 	return (char *)0;
 }
+#endif
 
 	asm("	___syscall:");
 	asm("		popl %ecx");
>Audit-Trail:
>Unformatted: