Subject: kern/6653: libsa/libkern fixes to compile with egcs -Werror
To: None <gnats-bugs@gnats.netbsd.org>
From: None <jewell@mit.edu>
List: netbsd-bugs
Date: 12/26/1998 04:07:38
>Number:         6653
>Category:       kern
>Synopsis:       libsa/libkern fixes to compile with -Werror
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Dec 26 01:20:01 1998
>Last-Modified:
>Originator:     Darrin B. Jewell
>Organization:
	
>Release:        -current, last updated ~19981219T0530Z
>Environment:
	
NetBSD mourning 1.3I NetBSD 1.3I (GENERIC) #62: Sat Dec 26 01:12:42 EST 1998     dbj@dbj.ne.mediaone.net:/usr/incoming/cvs.netbsd.org/src/sys/arch/next68k/compile/GENERIC next68k

>Description:

When compiling the next68k bootblocks with
  egcs -Wall -Wstrict-prototypes -Wmissing-prototypes -Wpointer-arith -Werror -Wno-main
libsa and libkern fail to compile because of missing function prototype declarations
and pointer arithmetic on void pointers.

>How-To-Repeat:
	
>Fix:

The following patches quiet the compiler when building the next68k bootblocks.
I added some declarations to stand.h and net.h and changed some
pointer arithmetic to use char * instead of void *.

Darrin


Index: libkern/__assert.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libkern/__assert.c,v
retrieving revision 1.1
diff -u -r1.1 __assert.c
--- __assert.c	1996/08/27 00:44:20	1.1
+++ __assert.c	1998/12/26 08:45:20
@@ -34,6 +34,10 @@
 #include <sys/types.h>
 #include <sys/systm.h>
 
+#ifndef _KERNEL
+#include <lib/libkern/libkern.h>
+#endif
+
 void
 __assert(t, f, l, e)
 	const char *t, *f, *e;
Index: libsa/cd9660.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/cd9660.c,v
retrieving revision 1.5
diff -u -r1.5 cd9660.c
--- cd9660.c	1997/06/26 19:11:33	1.5
+++ cd9660.c	1998/12/26 08:45:21
@@ -66,6 +66,10 @@
 
 #define	cdb2devb(bno)	((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE)
 
+static int toupper __P((int c));
+static int pnmatch __P((char *path, struct ptable_ent *pp));
+static int dirmatch __P((char *path, struct iso_directory_record *dp));
+
 static int
 toupper(c)
 	int c;
@@ -136,7 +140,7 @@
 	struct open_file *f;
 {
 	struct file *fp = 0;
-	void *buf;
+	char *buf;
 	struct iso_primary_descriptor *vd;
 	size_t buf_size, read, psize, dsize;
 	daddr_t bno;
@@ -147,7 +151,7 @@
 	
 	/* First find the volume descriptor */
 	buf = alloc(buf_size = ISO_DEFAULT_BLOCK_SIZE);
-	vd = buf;
+	vd = (struct iso_primary_descriptor *)buf;
 	for (bno = 16;; bno++) {
 		twiddle();
 		rc = f->f_dev->dv_strategy(f->f_devdata, F_READ, cdb2devb(bno),
@@ -195,22 +199,22 @@
 	
 	rc = ENOENT;
 	while (*path) {
-		if ((void *)pp >= buf + psize)
+		if ((char *)pp >= buf + psize)
 			break;
 		if (isonum_722(pp->parent) != parent)
 			break;
 		if (!pnmatch(path, pp)) {
-			pp = (struct ptable_ent *)((void *)pp + PTSIZE(pp));
+			pp = (struct ptable_ent *)((char *)pp + PTSIZE(pp));
 			ent++;
 			continue;
 		}
 		path += isonum_711(pp->namlen) + 1;
 		parent = ent;
 		bno = isonum_732(pp->block) + isonum_711(pp->extlen);
-		while ((void *)pp < buf + psize) {
+		while ((char *)pp < buf + psize) {
 			if (isonum_722(pp->parent) == parent)
 				break;
-			pp = (struct ptable_ent *)((void *)pp + PTSIZE(pp));
+			pp = (struct ptable_ent *)((char *)pp + PTSIZE(pp));
 			ent++;
 		}
 	}
@@ -235,7 +239,7 @@
 			dp = (struct iso_directory_record *)buf;
 		}
 		if (!isonum_711(dp->length)) {
-			if ((void *)dp == buf)
+			if ((char *)dp == buf)
 				psize += ISO_DEFAULT_BLOCK_SIZE;
 			else
 				psize = roundup(psize, ISO_DEFAULT_BLOCK_SIZE);
@@ -246,7 +250,7 @@
 		if (dirmatch(path, dp))
 			break;
 		psize += isonum_711(dp->length);
-		dp = (struct iso_directory_record *)((void *)dp + isonum_711(dp->length));
+		dp = (struct iso_directory_record *)((char *)dp + isonum_711(dp->length));
 	}
 
 	if (psize >= dsize) {
@@ -322,11 +326,11 @@
 				read = off + size;
 			read -= off;
 			bcopy(buf + off, start, read);
-			start += read;
+			((char *)start) += read;
 			fp->off += read;
 			size -= read;
 		} else {
-			start += ISO_DEFAULT_BLOCK_SIZE;
+			((char *)start) += ISO_DEFAULT_BLOCK_SIZE;
 			fp->off += ISO_DEFAULT_BLOCK_SIZE;
 			size -= ISO_DEFAULT_BLOCK_SIZE;
 		}
Index: libsa/dev_net.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/dev_net.c,v
retrieving revision 1.14
diff -u -r1.14 dev_net.c
--- dev_net.c	1998/06/29 20:25:59	1.14
+++ dev_net.c	1998/12/26 08:45:21
@@ -164,13 +164,22 @@
 }
 
 int
-net_ioctl()
+net_ioctl(f, cmd, data)
+	struct open_file *f;
+	u_long cmd;
+	void *data;
 {
 	return EIO;
 }
 
 int
-net_strategy()
+net_strategy(devdata, rw, blk, size, buf, rsize)
+	void *devdata;
+	int rw;
+	daddr_t blk;
+	size_t size;
+	void *buf;
+	size_t *rsize;
 {
 	return EIO;
 }
@@ -189,7 +198,6 @@
  */
 #ifdef	SUPPORT_BOOTP
 int try_bootp;
-int bootp __P((int sock));
 #endif
 
 static int
Index: libsa/dev_net.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/dev_net.h,v
retrieving revision 1.3
diff -u -r1.3 dev_net.h
--- dev_net.h	1997/03/15 18:12:14	1.3
+++ dev_net.h	1998/12/26 08:45:21
@@ -2,6 +2,6 @@
 
 int	net_open __P((struct open_file *, ...));
 int	net_close __P((struct open_file *));
-int	net_ioctl();
-int	net_strategy();
-
+int	net_ioctl __P((struct open_file *f, u_long cmd, void *data));
+int	net_strategy __P((void *devdata, int rw, daddr_t blk, size_t size, 
+		void *buf, size_t *rsize));
Index: libsa/exit.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/exit.c,v
retrieving revision 1.12
diff -u -r1.12 exit.c
--- exit.c	1997/06/26 19:11:38	1.12
+++ exit.c	1998/12/26 08:45:21
@@ -65,7 +65,8 @@
 }
 
 void
-exit()
+exit(status)
+	int status;
 {
     panic("exit");
     /*NOTREACHED*/
Index: libsa/in_cksum.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/in_cksum.c,v
retrieving revision 1.3
diff -u -r1.3 in_cksum.c
--- in_cksum.c	1995/04/22 13:53:48	1.3
+++ in_cksum.c	1998/12/26 08:45:21
@@ -41,6 +41,8 @@
 
 #include <sys/types.h>
 
+#include "stand.h"
+
 /*
  * Checksum routine for Internet Protocol family headers.
  * This routine is very heavily used in the network
Index: libsa/net.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/net.c,v
retrieving revision 1.20
diff -u -r1.20 net.c
--- net.c	1997/12/26 22:41:30	1.20
+++ net.c	1998/12/26 08:45:22
@@ -61,6 +61,8 @@
 #include "stand.h"
 #include "net.h"
 
+static char *number __P((char *s, int *n));
+
 /* Caller must leave room for ethernet, ip and udp headers in front!! */
 ssize_t
 sendudp(d, pkt, len)
Index: libsa/net.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/net.h,v
retrieving revision 1.10
diff -u -r1.10 net.h
--- net.h	1995/10/20 00:46:30	1.10
+++ net.h	1998/12/26 08:45:22
@@ -116,5 +116,10 @@
 char	*intoa __P((n_long));		/* similar to inet_ntoa */
 n_long	inet_addr __P((char *));
 
+n_long ip_convertaddr __P((char *p));
+struct netif;
+int netif_match __P(( struct netif *nif, void *machdep_hint));
+
 /* Machine-dependent functions: */
 time_t	getsecs __P((void));
+
Index: libsa/nfs.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/nfs.h,v
retrieving revision 1.5
diff -u -r1.5 nfs.h
--- nfs.h	1996/07/10 18:32:33	1.5
+++ nfs.h	1998/12/26 08:45:22
@@ -43,3 +43,11 @@
 int	nfs_stat __P((struct open_file *f, struct stat *sb));
 int	nfs_mount __P((int, struct in_addr, char *));
 
+
+struct iodesc;
+struct nfs_iodesc;
+int nfs_getrootfh __P((struct iodesc *d, char *path, u_char *fhp));
+int nfs_lookupfh __P((struct nfs_iodesc *d, char *name, struct nfs_iodesc *newfd));
+int nfs_readlink __P((struct nfs_iodesc *d, char *buf));
+ssize_t nfs_readdata __P((struct nfs_iodesc *d, off_t off, void *addr, size_t len));
+
Index: libsa/stand.h
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/stand.h,v
retrieving revision 1.26
diff -u -r1.26 stand.h
--- stand.h	1998/09/22 20:29:03	1.26
+++ stand.h	1998/12/26 08:45:22
@@ -125,6 +125,7 @@
 char	*strerror __P((int));
 __dead void	panic __P((const char *, ...)) __attribute__((noreturn));
 __dead void	_rtt __P((void)) __attribute__((noreturn));
+__dead void exit __P((int status));
 void	bcopy __P((const void *, void *, size_t));
 void	*memcpy __P((void *, const void *, size_t));
 int	memcmp __P((const void *, const void *, size_t));
@@ -149,10 +150,15 @@
 off_t	null_seek __P((struct open_file *f, off_t offset, int where));
 int	null_stat __P((struct open_file *f, struct stat *sb));
 
+int getfile __P((char *prompt, int mode));
+int ioctl __P((int fd, u_long cmd, char *arg));
+int in_cksum __P((register void *p, register int len));
+void bootp __P((int sock));
+
 /* Machine dependent functions */
 void	machdep_start __P((char *, int, char *, char *, char *));
 int	getchar __P((void));
-void	putchar __P((int));    
+void	putchar __P((int));
 
 #ifdef __INTERNAL_LIBSA_CREAD
 int	oopen __P((const char *, int));
Index: libsa/ufs.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/ufs.c,v
retrieving revision 1.20
diff -u -r1.20 ufs.c
--- ufs.c	1998/03/01 07:15:39	1.20
+++ ufs.c	1998/12/26 08:45:23
@@ -84,6 +84,7 @@
 #endif
 
 #include "stand.h"
+#include "ufs.h"
 
 /*
  * In-core open file.
Index: libsa/ustarfs.c
===================================================================
RCS file: /cvsroot/src/sys/lib/libsa/ustarfs.c,v
retrieving revision 1.5
diff -u -r1.5 ustarfs.c
--- ustarfs.c	1998/10/30 16:56:30	1.5
+++ ustarfs.c	1998/12/26 08:45:23
@@ -466,7 +466,7 @@
 			seg = infile;
 		memcpy(start, space512 + bufferoffset, seg);
 		ustf->uas_fseek += seg;
-		start += seg;
+		((char *)start) += seg;
 		size  -= seg;
 	}
 	if (resid)
>Audit-Trail:
>Unformatted: