Subject: kern/3317: -Wall -Werror fixes for sys/lib/libsa
To: None <gnats-bugs@gnats.netbsd.org>
From: Matthias Drochner <drochner@zelz26.zel.kfa-juelich.de>
List: netbsd-bugs
Date: 03/11/1997 16:16:15
>Number:         3317
>Category:       kern
>Synopsis:       sys/lib/libsa does not compile with -Wall -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:   Tue Mar 11 07:20:01 1997
>Last-Modified:
>Originator:     Matthias Drochner
>Organization:
	KFA Juelich
>Release:        NetBSD-current
>Environment:
	NetBSD-current, i386
System: NetBSD zelz26 1.2C NetBSD 1.2C (TULIP) #38: Mon Feb 24 22:00:30 MET 1997 drochner@zel024:/home/drochner/netbsd-970206/sys/arch/i386/compile/TULIP i386


>Description:
	The following warnings arise when sys/lib/libsa is compiled with -Wall:
- variables which gcc calls "unititialized":
	bestf in alloc.c -- sorry, this is already fixed
	pp and dp in cd9660.c
- printf format warnings in alloc.c
- unused variable nif in netif.c
- missing prototypes:
	panic in alloc.c
	bcmp in memcmp.c
	bzero in cread.c and cd9660.c (should go into libkern.h)
Some functions exported by libsa are not declared in libsa/*.h:
strerror
bootp
>How-To-Repeat:
	Try to compile sys/lib/libsa with -Wall -Werror.
>Fix:

*** /zelnfs/p3/drochner/netbsd-current/src/sys/lib/libsa/alloc.c	Mon Feb 17 08:01:20 1997
--- /zelnfs/r3/NetBSD/users/drochner/netbsd-970206/sys/lib/libsa/alloc.c	Tue Mar 11 14:47:07 1997
***************
*** 1,4 ****
! /*	$NetBSD: alloc.c,v 1.7 1997/02/16 13:02:59 leo Exp $	*/
  
  /*
   * Copyright (c) 1997 Christopher G. Demetriou.  All rights reserved.
--- 1,4 ----
! /*	$NetBSD: alloc.c,v 1.6 1997/02/04 18:36:33 thorpej Exp $	*/
  
  /*
   * Copyright (c) 1997 Christopher G. Demetriou.  All rights reserved.
***************
*** 85,90 ****
--- 85,91 ----
   */
  
  #include <sys/param.h>
+ #include "stand.h"
  
  /*
   * Each block actually has ALIGN(unsigned) + ALIGN(size) bytes allocated
***************
*** 122,128 ****
  alloc(size)
  	unsigned size;
  {
! 	register struct fl **f = &freelist, **bestf = NULL;
  	unsigned bestsize = 0xffffffff;	/* greater than any real size */
  	char *help;
  	int failed;
--- 123,129 ----
  alloc(size)
  	unsigned size;
  {
! 	register struct fl **f = &freelist, **bestf = 0;
  	unsigned bestsize = 0xffffffff;	/* greater than any real size */
  	char *help;
  	int failed;
***************
*** 173,179 ****
  #endif
  		*(unsigned *)help = ALIGN(size);
  #ifdef ALLOC_TRACE
! 		printf("=%x\n", help + ALIGN(sizeof(unsigned)));
  #endif
  		return(help + ALIGN(sizeof(unsigned)));
  	}
--- 174,180 ----
  #endif
  		*(unsigned *)help = ALIGN(size);
  #ifdef ALLOC_TRACE
! 		printf("=%lx\n", (u_long)help + ALIGN(sizeof(unsigned)));
  #endif
  		return(help + ALIGN(sizeof(unsigned)));
  	}
***************
*** 186,192 ****
          help = (char*)*f;
  	*f = (*f)->next;
  #ifdef ALLOC_TRACE
! 	printf("=%lx (origsize %u)\n", help + ALIGN(sizeof(unsigned)),
  	    *(unsigned *)help);
  #endif
  	return(help + ALIGN(sizeof(unsigned)));
--- 187,193 ----
          help = (char*)*f;
  	*f = (*f)->next;
  #ifdef ALLOC_TRACE
! 	printf("=%lx (origsize %u)\n", (u_long)help + ALIGN(sizeof(unsigned)),
  	    *(unsigned *)help);
  #endif
  	return(help + ALIGN(sizeof(unsigned)));
***************
*** 200,211 ****
  	register struct fl *f =
  	    (struct fl *)((char*)ptr - ALIGN(sizeof(unsigned)));
  #ifdef ALLOC_TRACE
! 	printf("free(%lx, %u) (origsize %u)\n", ptr, size, f->size);
  #endif
  #ifdef DEBUG
          if (size > f->size)
  	        printf("free %u bytes @%lx, should be <=%u\n",
! 		    size, ptr, f->size);
  #ifdef HEAP_START
  	if (ptr < (void *)HEAP_START)
  #else
--- 201,212 ----
  	register struct fl *f =
  	    (struct fl *)((char*)ptr - ALIGN(sizeof(unsigned)));
  #ifdef ALLOC_TRACE
! 	printf("free(%lx, %u) (origsize %u)\n", (u_long)ptr, size, f->size);
  #endif
  #ifdef DEBUG
          if (size > f->size)
  	        printf("free %u bytes @%lx, should be <=%u\n",
! 		    size, (u_long)ptr, f->size);
  #ifdef HEAP_START
  	if (ptr < (void *)HEAP_START)
  #else

*** /zelnfs/p3/drochner/netbsd-current/src/sys/lib/libsa/cd9660.c	Fri Jan 24 13:20:45 1997
--- /zelnfs/r3/NetBSD/users/drochner/netbsd-970206/sys/lib/libsa/cd9660.c	Tue Mar 11 15:03:20 1997
***************
*** 44,49 ****
--- 44,51 ----
  #include "stand.h"
  #include "cd9660.h"
  
+ extern void bzero __P((void*, int)); /* XXX */
+ 
  struct file {
  	off_t off;			/* Current offset within file */
  	daddr_t bno;			/* Starting block number  */
***************
*** 137,144 ****
  	size_t buf_size, read, psize, dsize;
  	daddr_t bno;
  	int parent, ent;
! 	struct ptable_ent *pp;
! 	struct iso_directory_record *dp;
  	int rc;
  	
  	/* First find the volume descriptor */
--- 139,146 ----
  	size_t buf_size, read, psize, dsize;
  	daddr_t bno;
  	int parent, ent;
! 	struct ptable_ent *pp = 0;
! 	struct iso_directory_record *dp = 0;
  	int rc;
  	
  	/* First find the volume descriptor */

*** /zelnfs/p3/drochner/netbsd-current/src/sys/lib/libsa/cread.c	Wed Feb  5 13:20:49 1997
--- /zelnfs/r3/NetBSD/users/drochner/netbsd-970206/sys/lib/libsa/cread.c	Tue Mar 11 15:07:31 1997
***************
*** 48,53 ****
--- 48,55 ----
  #include "stand.h"
  #include "../libz/zlib.h"
  
+ extern void bzero __P((void*, int));
+ 
  #define EOF (-1) /* needed by compression code */
  
  #ifdef SAVE_MEMORY
***************
*** 95,100 ****
--- 97,103 ----
    free(ptr, 0); /* XXX works only with modified allocator */
  }
  
+ #if 0
  void zmemcpy(dest, source, len)
  unsigned char *dest;
  unsigned char *source;
***************
*** 102,107 ****
--- 105,113 ----
  {
    bcopy(source, dest, len);
  }
+ #else
+ #define zmemcpy(d, s, l) bcopy(s, d, l)
+ #endif
  
  static int get_byte(s)
      struct sd *s;

*** /zelnfs/p3/drochner/netbsd-current/src/sys/lib/libsa/memcmp.c	Thu Jan 16 13:19:48 1997
--- /zelnfs/r3/NetBSD/users/drochner/netbsd-970206/sys/lib/libsa/memcmp.c	Fri Feb 28 17:54:56 1997
***************
*** 33,38 ****
--- 33,39 ----
   */
  
  #include <sys/types.h>
+ #include <lib/libkern/libkern.h>
  #include "stand.h"
  
  /*

*** /zelnfs/p3/drochner/netbsd-current/src/sys/lib/libsa/netif.c	Mon Oct 14 18:40:38 1996
--- /zelnfs/r3/NetBSD/users/drochner/netbsd-970206/sys/lib/libsa/netif.c	Sat Mar  8 14:18:35 1997
***************
*** 226,232 ****
--- 226,234 ----
  	size_t len;
  	time_t timo;
  {
+ #ifdef NETIF_DEBUG
  	struct netif *nif = desc->io_netif;
+ #endif
  	struct netif_driver *drv = desc->io_netif->nif_driver;
  	ssize_t rv;
  
***************
*** 254,260 ****
--- 256,264 ----
  	void *pkt;
  	size_t len;
  {
+ #ifdef NETIF_DEBUG
  	struct netif *nif = desc->io_netif;
+ #endif
  	struct netif_driver *drv = desc->io_netif->nif_driver;
  	ssize_t rv;
  

>Audit-Trail:
>Unformatted: