summaryrefslogtreecommitdiff
path: root/sys/lib/libsa
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2003-08-11 06:23:10 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2003-08-11 06:23:10 +0000
commit16824dd3bbb4d43b141d300c76afbdd0c30fa7b9 (patch)
tree08f2b84878ea46e749b47e3b2953507245ad5384 /sys/lib/libsa
parent678b21869f24e6ddc3a341fad1a87c353c5464ca (diff)
ansification and knf and protos
Diffstat (limited to 'sys/lib/libsa')
-rw-r--r--sys/lib/libsa/alloc.c40
-rw-r--r--sys/lib/libsa/arp.c44
-rw-r--r--sys/lib/libsa/bootp.c57
-rw-r--r--sys/lib/libsa/bootp.h5
-rw-r--r--sys/lib/libsa/bootparam.c41
-rw-r--r--sys/lib/libsa/cd9660.c48
-rw-r--r--sys/lib/libsa/close.c9
-rw-r--r--sys/lib/libsa/closeall.c10
-rw-r--r--sys/lib/libsa/cons.c19
-rw-r--r--sys/lib/libsa/cread.c527
-rw-r--r--sys/lib/libsa/ctime.c13
-rw-r--r--sys/lib/libsa/dev.c11
-rw-r--r--sys/lib/libsa/disklabel.c12
-rw-r--r--sys/lib/libsa/dkcksum.c9
-rw-r--r--sys/lib/libsa/ether.c25
-rw-r--r--sys/lib/libsa/exec.c21
-rw-r--r--sys/lib/libsa/exit.c4
-rw-r--r--sys/lib/libsa/fstat.c8
-rw-r--r--sys/lib/libsa/getfile.c8
-rw-r--r--sys/lib/libsa/gets.c11
-rw-r--r--sys/lib/libsa/in_cksum.c19
-rw-r--r--sys/lib/libsa/ioctl.c9
-rw-r--r--sys/lib/libsa/loadfile.c25
-rw-r--r--sys/lib/libsa/lseek.c11
-rw-r--r--sys/lib/libsa/memset.c5
-rw-r--r--sys/lib/libsa/net.c79
-rw-r--r--sys/lib/libsa/net.h3
-rw-r--r--sys/lib/libsa/netif.c52
-rw-r--r--sys/lib/libsa/nfs.c100
-rw-r--r--sys/lib/libsa/nullfs.c14
-rw-r--r--sys/lib/libsa/open.c12
-rw-r--r--sys/lib/libsa/printf.c24
-rw-r--r--sys/lib/libsa/rarp.c22
-rw-r--r--sys/lib/libsa/read.c11
-rw-r--r--sys/lib/libsa/readdir.c16
-rw-r--r--sys/lib/libsa/rpc.c46
-rw-r--r--sys/lib/libsa/rpc.h4
-rw-r--r--sys/lib/libsa/snprintf.c5
-rw-r--r--sys/lib/libsa/stand.h8
-rw-r--r--sys/lib/libsa/stat.c6
-rw-r--r--sys/lib/libsa/strchr.c7
-rw-r--r--sys/lib/libsa/strcmp.c6
-rw-r--r--sys/lib/libsa/strerror.c6
-rw-r--r--sys/lib/libsa/strlen.c12
-rw-r--r--sys/lib/libsa/strncmp.c9
-rw-r--r--sys/lib/libsa/strncpy.c10
-rw-r--r--sys/lib/libsa/strtol.c3
-rw-r--r--sys/lib/libsa/ufs.c134
-rw-r--r--sys/lib/libsa/unixdev.c56
-rw-r--r--sys/lib/libsa/write.c9
50 files changed, 685 insertions, 960 deletions
diff --git a/sys/lib/libsa/alloc.c b/sys/lib/libsa/alloc.c
index de916193fda..2f41d683364 100644
--- a/sys/lib/libsa/alloc.c
+++ b/sys/lib/libsa/alloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: alloc.c,v 1.8 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: alloc.c,v 1.9 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: alloc.c,v 1.6 1997/02/04 18:36:33 thorpej Exp $ */
/*
@@ -119,10 +119,9 @@ static char *top = end;
#endif
void *
-alloc(size)
- unsigned size;
+alloc(unsigned int size)
{
- register struct fl **f = &freelist, **bestf = NULL;
+ struct fl **f = &freelist, **bestf = NULL;
#ifndef ALLOC_FIRST_FIT
unsigned bestsize = 0xffffffff; /* greater than any real size */
#endif
@@ -147,11 +146,11 @@ alloc(size)
if ((*f)->size < bestsize) {
/* keep best fit */
- bestf = f;
- bestsize = (*f)->size;
- }
- }
- f = &((*f)->next);
+ bestf = f;
+ bestsize = (*f)->size;
+ }
+ }
+ f = &((*f)->next);
}
/* no match in freelist if bestsize unchanged */
@@ -159,11 +158,11 @@ alloc(size)
#endif
if (failed) { /* nothing found */
- /*
+ /*
* allocate from heap, keep chunk len in
* first word
*/
- help = top;
+ help = top;
/* make _sure_ the region can hold a struct fl. */
if (size < ALIGN(sizeof (struct fl *)))
@@ -171,7 +170,7 @@ alloc(size)
top += ALIGN(sizeof(unsigned)) + ALIGN(size);
#ifdef HEAP_LIMIT
if (top > (char *)HEAP_LIMIT)
- panic("heap full (0x%lx+%u)", help, size);
+ panic("heap full (0x%lx+%u)", help, size);
#endif
*(unsigned *)help = ALIGN(size);
#ifdef ALLOC_TRACE
@@ -186,8 +185,8 @@ alloc(size)
#ifndef ALLOC_FIRST_FIT
found:
#endif
- /* remove from freelist */
- help = (char *)*f;
+ /* remove from freelist */
+ help = (char *)*f;
*f = (*f)->next;
#ifdef ALLOC_TRACE
printf("=%p (origsize %u)\n", help + ALIGN(sizeof(unsigned)),
@@ -197,18 +196,17 @@ found:
}
void
-free(ptr, size)
- void *ptr;
- unsigned size; /* only for consistence check */
+free(void *ptr, unsigned int size)
{
- register struct fl *f =
- (struct fl *)((char *)ptr - ALIGN(sizeof(unsigned)));
+ struct fl *f = (struct fl *)((char *)ptr -
+ ALIGN(sizeof(unsigned)));
+
#ifdef ALLOC_TRACE
printf("free(%p, %u) (origsize %u)\n", ptr, size, f->size);
#endif
#ifdef DEBUG
- if (size > f->size)
- printf("free %u bytes @%p, should be <=%u\n",
+ if (size > f->size)
+ printf("free %u bytes @%p, should be <=%u\n",
size, ptr, f->size);
#ifdef HEAP_START
if (ptr < (void *)HEAP_START)
diff --git a/sys/lib/libsa/arp.c b/sys/lib/libsa/arp.c
index b441d77df9a..ff4623737c4 100644
--- a/sys/lib/libsa/arp.c
+++ b/sys/lib/libsa/arp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arp.c,v 1.10 2003/06/01 17:00:32 deraadt Exp $ */
+/* $OpenBSD: arp.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: arp.c,v 1.15 1996/10/13 02:28:58 christos Exp $ */
/*
@@ -69,13 +69,11 @@ static ssize_t arprecv(struct iodesc *, void *, size_t, time_t);
/* Broadcast an ARP packet, asking who has addr on interface d */
u_char *
-arpwhohas(d, addr)
- register struct iodesc *d;
- struct in_addr addr;
+arpwhohas(struct iodesc *d, struct in_addr addr)
{
- register int i;
- register struct ether_arp *ah;
- register struct arp_list *al;
+ int i;
+ struct ether_arp *ah;
+ struct arp_list *al;
struct {
struct ether_header eh;
struct {
@@ -146,10 +144,7 @@ arpwhohas(d, addr)
}
static ssize_t
-arpsend(d, pkt, len)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
+arpsend(struct iodesc *d, void *pkt, size_t len)
{
#ifdef ARP_DEBUG
@@ -165,14 +160,10 @@ arpsend(d, pkt, len)
* else -1 (and errno == 0)
*/
static ssize_t
-arprecv(d, pkt, len, tleft)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
- time_t tleft;
+arprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
{
- register ssize_t n;
- register struct ether_arp *ah;
+ ssize_t n;
+ struct ether_arp *ah;
u_int16_t etype; /* host order */
#ifdef ARP_DEBUG
@@ -204,8 +195,7 @@ arprecv(d, pkt, len, tleft)
if (ah->arp_hrd != htons(ARPHRD_ETHER) ||
ah->arp_pro != htons(ETHERTYPE_IP) ||
ah->arp_hln != sizeof(ah->arp_sha) ||
- ah->arp_pln != sizeof(ah->arp_spa) )
- {
+ ah->arp_pln != sizeof(ah->arp_spa)) {
#ifdef ARP_DEBUG
if (debug)
printf("bad hrd/pro/hln/pln\n");
@@ -231,9 +221,8 @@ arprecv(d, pkt, len, tleft)
}
/* Is the reply from the source we want? */
- if (bcmp(&arp_list[arp_num].addr,
- ah->arp_spa, sizeof(ah->arp_spa)))
- {
+ if (bcmp(&arp_list[arp_num].addr, ah->arp_spa,
+ sizeof(ah->arp_spa))) {
#ifdef ARP_DEBUG
if (debug)
printf("unwanted address\n");
@@ -255,17 +244,14 @@ arprecv(d, pkt, len, tleft)
* Notes: Re-uses buffer. Pad to length = 46.
*/
void
-arp_reply(d, pkt)
- register struct iodesc *d;
- register void *pkt; /* the request */
+arp_reply(struct iodesc *d, void *pkt)
{
struct ether_arp *arp = pkt;
if (arp->arp_hrd != htons(ARPHRD_ETHER) ||
arp->arp_pro != htons(ETHERTYPE_IP) ||
arp->arp_hln != sizeof(arp->arp_sha) ||
- arp->arp_pln != sizeof(arp->arp_spa) )
- {
+ arp->arp_pln != sizeof(arp->arp_spa)) {
#ifdef ARP_DEBUG
if (debug)
printf("arp_reply: bad hrd/pro/hln/pln\n");
@@ -304,5 +290,5 @@ arp_reply(d, pkt)
* requestor will just ask again.
*/
(void) sendether(d, pkt, sizeof(*arp) + 18,
- arp->arp_tha, ETHERTYPE_ARP);
+ arp->arp_tha, ETHERTYPE_ARP);
}
diff --git a/sys/lib/libsa/bootp.c b/sys/lib/libsa/bootp.c
index 5e1eaeed887..d553a634832 100644
--- a/sys/lib/libsa/bootp.c
+++ b/sys/lib/libsa/bootp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootp.c,v 1.10 2003/06/01 17:00:32 deraadt Exp $ */
+/* $OpenBSD: bootp.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: bootp.c,v 1.10 1996/10/13 02:28:59 christos Exp $ */
/*
@@ -65,11 +65,10 @@ static void vend_rfc1048(u_char *, u_int);
/* Fetch required bootp infomation */
void
-bootp(sock)
- int sock;
+bootp(int sock)
{
struct iodesc *d;
- register struct bootp *bp;
+ struct bootp *bp;
struct {
u_char header[HEADER_SIZE];
struct bootp wbootp;
@@ -121,12 +120,9 @@ bootp(sock)
/* Transmit a bootp request */
static ssize_t
-bootpsend(d, pkt, len)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
+bootpsend(struct iodesc *d, void *pkt, size_t len)
{
- register struct bootp *bp;
+ struct bootp *bp;
#ifdef BOOTP_DEBUG
if (debug)
@@ -146,14 +142,10 @@ bootpsend(d, pkt, len)
/* Returns 0 if this is the packet we're waiting for else -1 (and errno == 0) */
static ssize_t
-bootprecv(d, pkt, len, tleft)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
- time_t tleft;
+bootprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
{
- register ssize_t n;
- register struct bootp *bp;
+ ssize_t n;
+ struct bootp *bp;
#ifdef BOOTP_DEBUG
if (debug)
@@ -269,10 +261,9 @@ bad:
}
static void
-vend_cmu(cp)
- u_char *cp;
+vend_cmu(u_char *cp)
{
- register struct cmu_vend *vp;
+ struct cmu_vend *vp;
#ifdef BOOTP_DEBUG
if (debug)
@@ -280,22 +271,18 @@ vend_cmu(cp)
#endif
vp = (struct cmu_vend *)cp;
- if (vp->v_smask.s_addr != 0) {
+ if (vp->v_smask.s_addr != 0)
smask = vp->v_smask.s_addr;
- }
- if (vp->v_dgate.s_addr != 0) {
+ if (vp->v_dgate.s_addr != 0)
gateip = vp->v_dgate;
- }
}
static void
-vend_rfc1048(cp, len)
- register u_char *cp;
- u_int len;
+vend_rfc1048(u_char *cp, u_int len)
{
- register u_char *ep;
- register int size;
- register u_char tag;
+ u_char *ep;
+ int size;
+ u_char tag;
#ifdef BOOTP_DEBUG
if (debug)
@@ -312,18 +299,14 @@ vend_rfc1048(cp, len)
if (tag == TAG_END)
break;
- if (tag == TAG_SUBNET_MASK) {
+ if (tag == TAG_SUBNET_MASK)
bcopy(cp, &smask, sizeof(smask));
- }
- if (tag == TAG_GATEWAY) {
+ if (tag == TAG_GATEWAY)
bcopy(cp, &gateip.s_addr, sizeof(gateip.s_addr));
- }
- if (tag == TAG_SWAPSERVER) {
+ if (tag == TAG_SWAPSERVER)
bcopy(cp, &swapip.s_addr, sizeof(swapip.s_addr));
- }
- if (tag == TAG_DOMAIN_SERVER) {
+ if (tag == TAG_DOMAIN_SERVER)
bcopy(cp, &nameip.s_addr, sizeof(nameip.s_addr));
- }
if (tag == TAG_ROOTPATH) {
strncpy(rootpath, (char *)cp, sizeof(rootpath));
rootpath[size] = '\0';
diff --git a/sys/lib/libsa/bootp.h b/sys/lib/libsa/bootp.h
index 8731adfa153..5405a0a0201 100644
--- a/sys/lib/libsa/bootp.h
+++ b/sys/lib/libsa/bootp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootp.h,v 1.4 1996/12/08 15:15:46 niklas Exp $ */
+/* $OpenBSD: bootp.h,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: bootp.h,v 1.3 1996/09/26 23:22:01 cgd Exp $ */
/*
@@ -125,6 +125,7 @@ struct cmu_vend {
unsigned char v_unused[25]; /* currently unused */
};
-
/* v_flags values */
#define VF_SMASK 1 /* Subnet mask field contains valid data */
+
+void bootp(int);
diff --git a/sys/lib/libsa/bootparam.c b/sys/lib/libsa/bootparam.c
index 46691b4b832..0ca999fe417 100644
--- a/sys/lib/libsa/bootparam.c
+++ b/sys/lib/libsa/bootparam.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bootparam.c,v 1.10 2002/03/14 03:16:09 millert Exp $ */
+/* $OpenBSD: bootparam.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: bootparam.c,v 1.10 1996/10/14 21:16:55 thorpej Exp $ */
/*
@@ -100,8 +100,7 @@ int xdr_string_decode(char **p, char *str, int *len_p);
* know about us (don't want to broadcast a getport call).
*/
int
-bp_whoami(sockfd)
- int sockfd;
+bp_whoami(int sockfd)
{
/* RPC structures for PMAPPROC_CALLIT */
struct args {
@@ -160,8 +159,8 @@ bp_whoami(sockfd)
/* rpc_call will set d->destport */
len = rpc_call(d, PMAPPROG, PMAPVERS, PMAPPROC_CALLIT,
- args, send_tail - (char *)args,
- repl, sizeof(*repl));
+ args, send_tail - (char *)args,
+ repl, sizeof(*repl));
if (len < 8) {
printf("bootparamd: 'whoami' call failed\n");
return (-1);
@@ -181,10 +180,8 @@ bp_whoami(sockfd)
inet_ntoa(bp_server_addr), ntohs(bp_server_port)));
/* We have just done a portmap call, so cache the portnum. */
- rpc_pmap_putcache(bp_server_addr,
- BOOTPARAM_PROG,
- BOOTPARAM_VERS,
- (int)ntohs(bp_server_port));
+ rpc_pmap_putcache(bp_server_addr, BOOTPARAM_PROG, BOOTPARAM_VERS,
+ (int)ntohs(bp_server_port));
/*
* Parse the encapsulated results from bootparam/whoami
@@ -229,11 +226,7 @@ bp_whoami(sockfd)
* server pathname
*/
int
-bp_getfile(sockfd, key, serv_addr, pathname)
- int sockfd;
- char *key;
- char *pathname;
- struct in_addr *serv_addr;
+bp_getfile(int sockfd, char *key, struct in_addr *serv_addr, char *pathname)
{
struct {
n_long h[RPC_HEADER_WORDS];
@@ -323,12 +316,8 @@ bp_getfile(sockfd, key, serv_addr, pathname)
* (but with non-standard args...)
*/
-
int
-xdr_string_encode(pkt, str, len)
- char **pkt;
- char *str;
- int len;
+xdr_string_encode(char **pkt, char *str, int len)
{
u_int32_t *lenp;
char *datap;
@@ -347,10 +336,7 @@ xdr_string_encode(pkt, str, len)
}
int
-xdr_string_decode(pkt, str, len_p)
- char **pkt;
- char *str;
- int *len_p; /* bufsize - 1 */
+xdr_string_decode(char **pkt, char *str, int *len_p)
{
u_int32_t *lenp;
char *datap;
@@ -375,11 +361,8 @@ xdr_string_decode(pkt, str, len_p)
return (0);
}
-
int
-xdr_inaddr_encode(pkt, ia)
- char **pkt;
- struct in_addr ia; /* network order */
+xdr_inaddr_encode(char **pkt, struct in_addr ia)
{
struct xdr_inaddr *xi;
u_char *cp;
@@ -410,9 +393,7 @@ xdr_inaddr_encode(pkt, ia)
}
int
-xdr_inaddr_decode(pkt, ia)
- char **pkt;
- struct in_addr *ia; /* network order */
+xdr_inaddr_decode(char **pkt, struct in_addr *ia)
{
struct xdr_inaddr *xi;
u_char *cp;
diff --git a/sys/lib/libsa/cd9660.c b/sys/lib/libsa/cd9660.c
index 1a4c0a5b2c6..39751e4e2b2 100644
--- a/sys/lib/libsa/cd9660.c
+++ b/sys/lib/libsa/cd9660.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cd9660.c,v 1.9 2003/06/01 17:00:32 deraadt Exp $ */
+/* $OpenBSD: cd9660.c,v 1.10 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: cd9660.c,v 1.1 1996/09/30 16:01:19 ws Exp $ */
/*
@@ -75,9 +75,7 @@ struct ptable_ent {
#define cdb2devb(bno) ((bno) * ISO_DEFAULT_BLOCK_SIZE / DEV_BSIZE)
static int
-pnmatch(path, pp)
- char *path;
- struct ptable_ent *pp;
+pnmatch(char *path, struct ptable_ent *pp)
{
char *cp;
int i;
@@ -94,9 +92,7 @@ pnmatch(path, pp)
}
static int
-dirmatch(path, dp)
- char *path;
- struct iso_directory_record *dp;
+dirmatch(char *path, struct iso_directory_record *dp)
{
char *cp;
int i;
@@ -132,9 +128,7 @@ dirmatch(path, dp)
}
int
-cd9660_open(path, f)
- char *path;
- struct open_file *f;
+cd9660_open(char *path, struct open_file *f)
{
struct file *fp = 0;
void *buf;
@@ -254,7 +248,8 @@ cd9660_open(path, f)
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 *)((void *)dp +
+ isonum_711(dp->length));
}
if (psize >= dsize) {
@@ -283,8 +278,7 @@ out:
}
int
-cd9660_close(f)
- struct open_file *f;
+cd9660_close(struct open_file *f)
{
struct file *fp = (struct file *)f->f_fsdata;
@@ -295,11 +289,7 @@ cd9660_close(f)
}
int
-cd9660_read(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid;
+cd9660_read(struct open_file *f, void *start, size_t size, size_t *resid)
{
struct file *fp = (struct file *)f->f_fsdata;
int rc = 0;
@@ -345,20 +335,13 @@ cd9660_read(f, start, size, resid)
}
int
-cd9660_write(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid;
+cd9660_write(struct open_file *f, void *start, size_t size, size_t *resid)
{
return EROFS;
}
off_t
-cd9660_seek(f, offset, where)
- struct open_file *f;
- off_t offset;
- int where;
+cd9660_seek(struct open_file *f, off_t offset, int where)
{
struct file *fp = (struct file *)f->f_fsdata;
@@ -379,13 +362,11 @@ cd9660_seek(f, offset, where)
}
int
-cd9660_stat(f, sb)
- struct open_file *f;
- struct stat *sb;
+cd9660_stat(struct open_file *f, struct stat *sb)
{
struct file *fp = (struct file *)f->f_fsdata;
- /* only importatn stuff */
+ /* only important stuff */
sb->st_mode = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH;
sb->st_uid = sb->st_gid = 0;
sb->st_size = fp->size;
@@ -397,11 +378,8 @@ cd9660_stat(f, sb)
*/
#ifndef NO_READDIR
int
-cd9660_readdir(f, name)
- struct open_file *f;
- char *name;
+cd9660_readdir(struct open_file *f, char *name)
{
return (EROFS);
}
#endif
-
diff --git a/sys/lib/libsa/close.c b/sys/lib/libsa/close.c
index 0db50d53e98..52698b39b73 100644
--- a/sys/lib/libsa/close.c
+++ b/sys/lib/libsa/close.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: close.c,v 1.7 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: close.c,v 1.8 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: close.c,v 1.5 1995/09/06 19:53:29 pk Exp $ */
/*-
@@ -66,13 +66,12 @@
int
#ifndef __INTERNAL_LIBSA_CREAD
-close(fd)
+close(int fd)
#else
-oclose(fd)
+oclose(int fd)
#endif
- int fd;
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
int err1 = 0, err2 = 0;
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
diff --git a/sys/lib/libsa/closeall.c b/sys/lib/libsa/closeall.c
index 0cf4de33589..017dfc45035 100644
--- a/sys/lib/libsa/closeall.c
+++ b/sys/lib/libsa/closeall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: closeall.c,v 1.4 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: closeall.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: close.c,v 1.5 1995/09/06 19:53:29 pk Exp $ */
/*-
@@ -64,11 +64,11 @@
#include "stand.h"
void
-closeall()
+closeall(void)
{
int i;
- for (i = 0; i < SOPEN_MAX; i++)
- if (files[i].f_flags != 0)
- (void)close(i);
+ for (i = 0; i < SOPEN_MAX; i++)
+ if (files[i].f_flags != 0)
+ (void)close(i);
}
diff --git a/sys/lib/libsa/cons.c b/sys/lib/libsa/cons.c
index 6779002b57a..700d9acf0f5 100644
--- a/sys/lib/libsa/cons.c
+++ b/sys/lib/libsa/cons.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cons.c,v 1.10 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: cons.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -45,9 +45,9 @@
#include <dev/cons.h>
void
-cninit()
+cninit(void)
{
- register struct consdev *cp;
+ struct consdev *cp;
/*
* Collect information about all possible consoles
@@ -71,8 +71,7 @@ cninit()
}
int
-cnset(dev)
- dev_t dev;
+cnset(dev_t dev)
{
struct consdev *cp;
@@ -98,7 +97,7 @@ cnset(dev)
}
int
-cngetc()
+cngetc(void)
{
if (cn_tab == NULL)
return (0);
@@ -106,8 +105,7 @@ cngetc()
}
void
-cnputc(c)
- register int c;
+cnputc(int c)
{
if (cn_tab != NULL && c) {
(*cn_tab->cn_putc)(cn_tab->cn_dev, c);
@@ -117,10 +115,9 @@ cnputc(c)
}
int
-cnischar()
+cnischar(void)
{
if (cn_tab != NULL)
return ((*cn_tab->cn_getc)(cn_tab->cn_dev|0x80));
- else
- return 0;
+ return 0;
}
diff --git a/sys/lib/libsa/cread.c b/sys/lib/libsa/cread.c
index 382e0ea9ec9..e683fdadf98 100644
--- a/sys/lib/libsa/cread.c
+++ b/sys/lib/libsa/cread.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cread.c,v 1.10 2003/04/17 13:22:38 mickey Exp $ */
+/* $OpenBSD: cread.c,v 1.11 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: cread.c,v 1.2 1997/02/04 18:38:20 thorpej Exp $ */
/*
@@ -62,21 +62,21 @@
static int gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */
/* gzip flag byte */
-#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
-#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
-#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
-#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
-#define COMMENT 0x10 /* bit 4 set: file comment present */
-#define RESERVED 0xE0 /* bits 5..7: reserved */
+#define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */
+#define HEAD_CRC 0x02 /* bit 1 set: header CRC present */
+#define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */
+#define ORIG_NAME 0x08 /* bit 3 set: original file name present */
+#define COMMENT 0x10 /* bit 4 set: file comment present */
+#define RESERVED 0xE0 /* bits 5..7: reserved */
static struct sd {
- z_stream stream;
- int z_err; /* error code for last stream operation */
- int z_eof; /* set if end of input file */
- int fd;
- unsigned char *inbuf; /* input buffer */
- unsigned long crc; /* crc32 of uncompressed data */
- int transparent; /* 1 if input file is not a .gz file */
+ z_stream stream;
+ int z_err; /* error code for last stream operation */
+ int z_eof; /* set if end of input file */
+ int fd;
+ unsigned char *inbuf; /* input buffer */
+ unsigned long crc; /* crc32 of uncompressed data */
+ int transparent; /* 1 if input file is not a .gz file */
} *ss[SOPEN_MAX];
#ifdef DEBUG
@@ -87,100 +87,114 @@ int z_verbose = 0;
* compression utilities
*/
-void *zcalloc (opaque, items, size)
-void *opaque;
-unsigned items;
-unsigned size;
+void *zcalloc(void *, unsigned int, unsigned int);
+void zcfree(void *, void *);
+
+void *
+zcalloc(void *opaque, unsigned int items, unsigned int size)
{
- return(alloc(items * size));
+ return(alloc(items * size));
}
-void zcfree (opaque, ptr)
-void *opaque;
-void *ptr;
+void
+zcfree(void *opaque, void *ptr)
{
- free(ptr, 0); /* XXX works only with modified allocator */
+ free(ptr, 0); /* XXX works only with modified allocator */
}
-static int get_byte(s)
- struct sd *s;
+static int
+get_byte(struct sd *s)
{
- if (s->z_eof) return EOF;
- if (s->stream.avail_in == 0) {
- errno = 0;
- s->stream.avail_in = oread(s->fd, s->inbuf, Z_BUFSIZE);
- if (s->stream.avail_in <= 0) {
- s->z_eof = 1;
- if (errno) s->z_err = Z_ERRNO;
- return EOF;
+ if (s->z_eof)
+ return EOF;
+ if (s->stream.avail_in == 0) {
+ errno = 0;
+ s->stream.avail_in = oread(s->fd, s->inbuf, Z_BUFSIZE);
+ if (s->stream.avail_in <= 0) {
+ s->z_eof = 1;
+ if (errno)
+ s->z_err = Z_ERRNO;
+ return EOF;
+ }
+ s->stream.next_in = s->inbuf;
}
- s->stream.next_in = s->inbuf;
- }
- s->stream.avail_in--;
- return *(s->stream.next_in)++;
+ s->stream.avail_in--;
+ return *(s->stream.next_in)++;
}
-static unsigned long getLong (s)
- struct sd *s;
+static unsigned long
+getLong(struct sd *s)
{
- unsigned long x = (unsigned long)get_byte(s);
- int c;
-
- x += ((unsigned long)get_byte(s))<<8;
- x += ((unsigned long)get_byte(s))<<16;
- c = get_byte(s);
- if (c == EOF) s->z_err = Z_DATA_ERROR;
- x += ((unsigned long)c)<<24;
- return x;
+ unsigned long x = (unsigned long)get_byte(s);
+ int c;
+
+ x += ((unsigned long)get_byte(s))<<8;
+ x += ((unsigned long)get_byte(s))<<16;
+ c = get_byte(s);
+ if (c == EOF)
+ s->z_err = Z_DATA_ERROR;
+ x += ((unsigned long)c)<<24;
+ return x;
}
-static void check_header(s)
- struct sd *s;
+static void
+check_header(struct sd *s)
{
- int method; /* method byte */
- int flags; /* flags byte */
- unsigned int len;
- int c;
+ int method; /* method byte */
+ int flags; /* flags byte */
+ unsigned int len;
+ int c;
+
+ /* Check the gzip magic header */
+ for (len = 0; len < 2; len++) {
+ c = get_byte(s);
+ if (c != gz_magic[len]) {
+ if (len != 0) {
+ s->stream.avail_in++;
+ s->stream.next_in--;
+ }
+ if (c != EOF) {
+ s->stream.avail_in++;
+ s->stream.next_in--;
+ s->transparent = 1;
+ }
- /* Check the gzip magic header */
- for (len = 0; len < 2; len++) {
- c = get_byte(s);
- if (c != gz_magic[len]) {
- if (len != 0) s->stream.avail_in++, s->stream.next_in--;
- if (c != EOF) {
- s->stream.avail_in++, s->stream.next_in--;
- s->transparent = 1;
- }
- s->z_err = s->stream.avail_in != 0 ? Z_OK : Z_STREAM_END;
- return;
+ s->z_err = s->stream.avail_in != 0 ? Z_OK :
+ Z_STREAM_END;
+ return;
+ }
}
- }
- method = get_byte(s);
- flags = get_byte(s);
- if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
- s->z_err = Z_DATA_ERROR;
- return;
- }
-
- /* Discard time, xflags and OS code: */
- for (len = 0; len < 6; len++) (void)get_byte(s);
-
- if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
- len = (unsigned int)get_byte(s);
- len += ((unsigned int)get_byte(s))<<8;
- /* len is garbage if EOF but the loop below will quit anyway */
- while (len-- != 0 && get_byte(s) != EOF) ;
- }
- if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
- while ((c = get_byte(s)) != 0 && c != EOF) ;
- }
- if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
- for (len = 0; len < 2; len++) (void)get_byte(s);
- }
- s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
+ method = get_byte(s);
+ flags = get_byte(s);
+ if (method != Z_DEFLATED || (flags & RESERVED) != 0) {
+ s->z_err = Z_DATA_ERROR;
+ return;
+ }
+
+ /* Discard time, xflags and OS code: */
+ for (len = 0; len < 6; len++)
+ (void)get_byte(s);
+
+ if ((flags & EXTRA_FIELD) != 0) { /* skip the extra field */
+ len = (unsigned int)get_byte(s);
+ len += ((unsigned int)get_byte(s))<<8;
+ /* len is garbage if EOF but the loop below will quit anyway */
+ while (len-- != 0 && get_byte(s) != EOF)
+ ;
+ }
+ if ((flags & ORIG_NAME) != 0) { /* skip the original file name */
+ while ((c = get_byte(s)) != 0 && c != EOF)
+ ;
+ }
+ if ((flags & COMMENT) != 0) { /* skip the .gz file comment */
+ while ((c = get_byte(s)) != 0 && c != EOF)
+ ;
+ }
+ if ((flags & HEAD_CRC) != 0) { /* skip the header crc */
+ for (len = 0; len < 2; len++)
+ (void)get_byte(s);
+ }
+ s->z_err = s->z_eof ? Z_DATA_ERROR : Z_OK;
}
/*
@@ -188,50 +202,49 @@ static void check_header(s)
*/
int
-open(fname, mode)
- const char *fname;
- int mode;
+open(const char *fname, int mode)
{
- int fd;
- struct sd *s = 0;
+ int fd;
+ struct sd *s = 0;
- if(((fd = oopen(fname, mode)) == -1)
- || (mode != 0)) /* compression only for read */
+ if (((fd = oopen(fname, mode)) == -1) ||
+ (mode != 0)) /* compression only for read */
return(fd);
- ss[fd] = s = alloc(sizeof(struct sd));
- if(!s) goto errout;
- bzero(s, sizeof(struct sd));
+ ss[fd] = s = alloc(sizeof(struct sd));
+ if (!s)
+ goto errout;
+ bzero(s, sizeof(struct sd));
#ifdef SAVE_MEMORY
- if(inflateInit2(&(s->stream), -11) != Z_OK)
+ if (inflateInit2(&(s->stream), -11) != Z_OK)
#else
- if(inflateInit2(&(s->stream), -15) != Z_OK)
+ if (inflateInit2(&(s->stream), -15) != Z_OK)
#endif
- goto errout;
+ goto errout;
- s->stream.next_in = s->inbuf = (unsigned char *)alloc(Z_BUFSIZE);
- if(!s->inbuf) {
- inflateEnd(&(s->stream));
- goto errout;
- }
+ s->stream.next_in = s->inbuf = (unsigned char *)alloc(Z_BUFSIZE);
+ if (!s->inbuf) {
+ inflateEnd(&(s->stream));
+ goto errout;
+ }
- s->fd = fd;
- check_header(s); /* skip the .gz header */
- return(fd);
+ s->fd = fd;
+ check_header(s); /* skip the .gz header */
+ return(fd);
errout:
- if(s) free(s, sizeof(struct sd));
- oclose(fd);
- return(-1);
+ if (s)
+ free(s, sizeof(struct sd));
+ oclose(fd);
+ return(-1);
}
int
-close(fd)
- int fd;
+close(int fd)
{
struct open_file *f;
- struct sd *s;
+ struct sd *s;
if ((unsigned)fd >= SOPEN_MAX) {
errno = EBADF;
@@ -239,7 +252,7 @@ close(fd)
}
f = &files[fd];
- if(!(f->f_flags & F_READ))
+ if (!(f->f_flags & F_READ))
return(oclose(fd));
s = ss[fd];
@@ -253,144 +266,148 @@ close(fd)
}
ssize_t
-read(fd, buf, len)
- int fd;
- void *buf;
- size_t len;
+read(int fd, void *buf, size_t len)
{
- struct sd *s;
- unsigned char *start = buf; /* starting point for crc computation */
-
- s = ss[fd];
-
- if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO) return -1;
- if (s->z_err == Z_STREAM_END) return 0; /* EOF */
-
- s->stream.next_out = buf;
- s->stream.avail_out = len;
-
- while (s->stream.avail_out != 0) {
-
- if (s->transparent) {
- /* Copy first the lookahead bytes: */
- unsigned int n = s->stream.avail_in;
- if (n > s->stream.avail_out) n = s->stream.avail_out;
- if (n > 0) {
- zmemcpy(s->stream.next_out, s->stream.next_in, n);
- s->stream.next_out += n;
- s->stream.next_in += n;
- s->stream.avail_out -= n;
- s->stream.avail_in -= n;
- }
- if (s->stream.avail_out > 0) {
- int n;
- n = oread(fd, s->stream.next_out, s->stream.avail_out);
- if (n <= 0) {
- s->z_eof = 1;
- if (errno) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.avail_out -= n;
- }
- len -= s->stream.avail_out;
- s->stream.total_in += (unsigned long)len;
- s->stream.total_out += (unsigned long)len;
- if (len == 0) s->z_eof = 1;
- return (int)len;
- }
-
- if (s->stream.avail_in == 0 && !s->z_eof) {
-
- errno = 0;
- s->stream.avail_in = oread(fd, s->inbuf, Z_BUFSIZE);
- if (s->stream.avail_in <= 0) {
- s->z_eof = 1;
- if (errno) {
- s->z_err = Z_ERRNO;
- break;
- }
- }
- s->stream.next_in = s->inbuf;
- }
- s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
+ struct sd *s;
+ unsigned char *start = buf; /* starting point for crc computation */
+
+ s = ss[fd];
- if (s->z_err == Z_STREAM_END) {
- /* Check CRC and original size */
- s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start));
- start = s->stream.next_out;
+ if (s->z_err == Z_DATA_ERROR || s->z_err == Z_ERRNO)
+ return -1;
+ if (s->z_err == Z_STREAM_END)
+ return 0; /* EOF */
- if (getLong(s) != s->crc) {
- s->z_err = Z_DATA_ERROR;
- } else {
- (void)getLong(s);
- /* The uncompressed length returned by above getlong() may
- * be different from s->stream.total_out) in case of
- * concatenated .gz files. Check for such files:
- */
- check_header(s);
- if (s->z_err == Z_OK) {
- unsigned long total_in = s->stream.total_in;
- unsigned long total_out = s->stream.total_out;
-
- inflateReset(&(s->stream));
- s->stream.total_in = total_in;
- s->stream.total_out = total_out;
- s->crc = crc32(0L, Z_NULL, 0);
+ s->stream.next_out = buf;
+ s->stream.avail_out = len;
+
+ while (s->stream.avail_out != 0) {
+
+ if (s->transparent) {
+ /* Copy first the lookahead bytes: */
+ unsigned int n = s->stream.avail_in;
+
+ if (n > s->stream.avail_out)
+ n = s->stream.avail_out;
+ if (n > 0) {
+ zmemcpy(s->stream.next_out, s->stream.next_in, n);
+ s->stream.next_out += n;
+ s->stream.next_in += n;
+ s->stream.avail_out -= n;
+ s->stream.avail_in -= n;
+ }
+ if (s->stream.avail_out > 0) {
+ int n;
+
+ n = oread(fd, s->stream.next_out,
+ s->stream.avail_out);
+ if (n <= 0) {
+ s->z_eof = 1;
+ if (errno) {
+ s->z_err = Z_ERRNO;
+ break;
+ }
+ }
+ s->stream.avail_out -= n;
+ }
+ len -= s->stream.avail_out;
+ s->stream.total_in += (unsigned long)len;
+ s->stream.total_out += (unsigned long)len;
+ if (len == 0)
+ s->z_eof = 1;
+ return (int)len;
}
- }
- }
- if (s->z_err != Z_OK || s->z_eof) break;
- }
- s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start));
- return (int)(len - s->stream.avail_out);
+ if (s->stream.avail_in == 0 && !s->z_eof) {
+ errno = 0;
+ s->stream.avail_in = oread(fd, s->inbuf, Z_BUFSIZE);
+ if (s->stream.avail_in <= 0) {
+ s->z_eof = 1;
+ if (errno) {
+ s->z_err = Z_ERRNO;
+ break;
+ }
+ }
+ s->stream.next_in = s->inbuf;
+ }
+ s->z_err = inflate(&(s->stream), Z_NO_FLUSH);
+
+ if (s->z_err == Z_STREAM_END) {
+ /* Check CRC and original size */
+ s->crc = crc32(s->crc, start,
+ (unsigned int)(s->stream.next_out - start));
+ start = s->stream.next_out;
+
+ if (getLong(s) != s->crc) {
+ s->z_err = Z_DATA_ERROR;
+ } else {
+ (void)getLong(s);
+
+ /* The uncompressed length returned by
+ * above getlong() may be different from
+ * s->stream.total_out in case of concatenated
+ * .gz files. Check for such files:
+ */
+ check_header(s);
+ if (s->z_err == Z_OK) {
+ unsigned long total_in = s->stream.total_in;
+ unsigned long total_out = s->stream.total_out;
+
+ inflateReset(&(s->stream));
+ s->stream.total_in = total_in;
+ s->stream.total_out = total_out;
+ s->crc = crc32(0L, Z_NULL, 0);
+ }
+ }
+ }
+ if (s->z_err != Z_OK || s->z_eof)
+ break;
+ }
+ s->crc = crc32(s->crc, start, (unsigned int)(s->stream.next_out - start));
+
+ return (int)(len - s->stream.avail_out);
}
off_t
-lseek(fd, offset, where)
- int fd;
- off_t offset;
- int where;
+lseek(int fd, off_t offset, int where)
{
- register struct open_file *f;
- struct sd *s;
+ struct open_file *f;
+ struct sd *s;
- if ((unsigned)fd >= SOPEN_MAX) {
+ if ((unsigned)fd >= SOPEN_MAX) {
errno = EBADF;
return (-1);
- }
- f = &files[fd];
+ }
+ f = &files[fd];
- if(!(f->f_flags & F_READ))
+ if (!(f->f_flags & F_READ))
return(olseek(fd, offset, where));
- s = ss[fd];
+ s = ss[fd];
- if(s->transparent) {
+ if (s->transparent) {
off_t res = olseek(fd, offset, where);
- if(res != (off_t)-1) {
- /* make sure the lookahead buffer is invalid */
- s->stream.avail_in = 0;
+ if (res != (off_t)-1) {
+ /* make sure the lookahead buffer is invalid */
+ s->stream.avail_in = 0;
}
return(res);
- }
+ }
- switch(where) {
- case SEEK_CUR:
- offset += s->stream.total_out;
- case SEEK_SET:
+ switch(where) {
+ case SEEK_CUR:
+ offset += s->stream.total_out;
+ case SEEK_SET:
- /* if seek backwards, simply start from
- the beginning */
- if(offset < s->stream.total_out) {
+ /* if seek backwards, simply start from
+ the beginning */
+ if (offset < s->stream.total_out) {
off_t res;
void *sav_inbuf;
res = olseek(fd, 0, SEEK_SET);
- if(res == (off_t)-1)
- return(res);
+ if (res == (off_t)-1)
+ return(res);
/* ??? perhaps fallback to close / open */
inflateEnd(&(s->stream));
@@ -403,34 +420,36 @@ lseek(fd, offset, where)
s->fd = fd;
check_header(s); /* skip the .gz header */
- }
+ }
- /* to seek forwards, throw away data */
- if(offset > s->stream.total_out) {
+ /* to seek forwards, throw away data */
+ if (offset > s->stream.total_out) {
off_t toskip = offset - s->stream.total_out;
while(toskip > 0) {
#define DUMMYBUFSIZE 256
- char dummybuf[DUMMYBUFSIZE];
- off_t len = toskip;
- if(len > DUMMYBUFSIZE) len = DUMMYBUFSIZE;
- if(read(fd, dummybuf, len) != len) {
- errno = EOFFSET;
- return((off_t)-1);
- }
- toskip -= len;
+ char dummybuf[DUMMYBUFSIZE];
+ off_t len = toskip;
+
+ if (len > DUMMYBUFSIZE)
+ len = DUMMYBUFSIZE;
+ if (read(fd, dummybuf, len) != len) {
+ errno = EOFFSET;
+ return((off_t)-1);
+ }
+ toskip -= len;
}
- }
+ }
#ifdef DEBUG
- if(offset != s->stream.total_out)
+ if (offset != s->stream.total_out)
panic("lseek compressed");
#endif
- return(offset);
- case SEEK_END:
- errno = EOFFSET;
- break;
- default:
- errno = EINVAL;
- }
- return((off_t)-1);
+ return(offset);
+ case SEEK_END:
+ errno = EOFFSET;
+ break;
+ default:
+ errno = EINVAL;
+ }
+ return((off_t)-1);
}
diff --git a/sys/lib/libsa/ctime.c b/sys/lib/libsa/ctime.c
index 30a730b9567..d48cea26ddf 100644
--- a/sys/lib/libsa/ctime.c
+++ b/sys/lib/libsa/ctime.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctime.c,v 1.4 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: ctime.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/*
* Copyright (c) 1998 Michael Shalayeff
@@ -31,8 +31,7 @@
#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
char *
-ctime(clock)
- const time_t *clock;
+ctime(const time_t *clock)
{
static const char wdays[][4] = {
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
@@ -46,7 +45,7 @@ ctime(clock)
};
static char buf[64];
int ss, mm, hh, wday, month, year;
- register time_t tt = *clock;
+ time_t tt = *clock;
ss = tt % 60;
tt /= 60; /* minutes */
@@ -69,8 +68,8 @@ ctime(clock)
/* no field widths in printf() */
snprintf(buf, sizeof buf, "%s %s %d %d:%d:%d %d\n",
- ((wday < 0 || wday >= 7)? "???": wdays[wday]),
- ((month < 0 || month >= 12)? "???": months[month]),
- (int)tt, hh, mm, ss, year);
+ ((wday < 0 || wday >= 7)? "???": wdays[wday]),
+ ((month < 0 || month >= 12)? "???": months[month]),
+ (int)tt, hh, mm, ss, year);
return buf;
}
diff --git a/sys/lib/libsa/dev.c b/sys/lib/libsa/dev.c
index b0d0d012696..c5a86655d9b 100644
--- a/sys/lib/libsa/dev.c
+++ b/sys/lib/libsa/dev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dev.c,v 1.3 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: dev.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: dev.c,v 1.4 1994/10/30 21:48:23 cgd Exp $ */
/*-
@@ -40,22 +40,19 @@
int errno;
int
-nodev()
+nodev(void)
{
return (ENXIO);
}
void
-nullsys()
+nullsys(void)
{
}
/* ARGSUSED */
int
-noioctl(f, cmd, data)
- struct open_file *f;
- u_long cmd;
- void *data;
+noioctl(struct open_file *f, u_long cmd, void *data)
{
return (EINVAL);
}
diff --git a/sys/lib/libsa/disklabel.c b/sys/lib/libsa/disklabel.c
index 54264817ba5..1272a942727 100644
--- a/sys/lib/libsa/disklabel.c
+++ b/sys/lib/libsa/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.4 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: disklabel.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: disklabel.c,v 1.3 1994/10/26 05:44:42 cgd Exp $ */
/*-
@@ -37,25 +37,23 @@
#include "stand.h"
char *
-getdisklabel(buf, lp)
- const char *buf;
- struct disklabel *lp;
+getdisklabel(const char *buf, struct disklabel *lp)
{
struct disklabel *dlp, *elp;
- char *msg = (char *)0;
+ char *msg = NULL;
elp = (struct disklabel *)(buf + DEV_BSIZE - sizeof(*dlp));
for (dlp = (struct disklabel *)buf; dlp <= elp;
dlp = (struct disklabel *)((char *)dlp + sizeof(long))) {
if (dlp->d_magic != DISKMAGIC || dlp->d_magic2 != DISKMAGIC) {
- if (msg == (char *)0)
+ if (msg == NULL)
msg = "no disk label";
} else if (dlp->d_npartitions > MAXPARTITIONS ||
dkcksum(dlp) != 0)
msg = "disk label corrupted";
else {
*lp = *dlp;
- msg = (char *)0;
+ msg = NULL;
break;
}
}
diff --git a/sys/lib/libsa/dkcksum.c b/sys/lib/libsa/dkcksum.c
index 1aba3a5ff49..f46cecb3f9c 100644
--- a/sys/lib/libsa/dkcksum.c
+++ b/sys/lib/libsa/dkcksum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dkcksum.c,v 1.4 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: dkcksum.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: disklabel.c,v 1.3 1994/10/26 05:44:42 cgd Exp $ */
/*-
@@ -40,11 +40,10 @@
* Compute checksum for disk label.
*/
u_int
-dkcksum(lp)
- register struct disklabel *lp;
+dkcksum(struct disklabel *lp)
{
- register u_short *start, *end;
- register u_short sum = 0;
+ u_short *start, *end;
+ u_short sum = 0;
start = (u_short *)lp;
end = (u_short *)&lp->d_partitions[lp->d_npartitions];
diff --git a/sys/lib/libsa/ether.c b/sys/lib/libsa/ether.c
index 69773361022..38d9d320301 100644
--- a/sys/lib/libsa/ether.c
+++ b/sys/lib/libsa/ether.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ether.c,v 1.6 2003/06/01 17:00:32 deraadt Exp $ */
+/* $OpenBSD: ether.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: ether.c,v 1.8 1996/10/13 02:29:00 christos Exp $ */
/*
@@ -63,8 +63,8 @@ sendether(d, pkt, len, dea, etype)
u_char *dea;
int etype;
{
- register ssize_t n;
- register struct ether_header *eh;
+ssize_t n;
+struct ether_header *eh;
#ifdef ETHER_DEBUG
if (debug)
@@ -93,14 +93,14 @@ sendether(d, pkt, len, dea, etype)
*/
ssize_t
readether(d, pkt, len, tleft, etype)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
+struct iodesc *d;
+void *pkt;
+size_t len;
time_t tleft;
- register u_int16_t *etype;
+u_int16_t *etype;
{
- register ssize_t n;
- register struct ether_header *eh;
+ssize_t n;
+struct ether_header *eh;
#ifdef ETHER_DEBUG
if (debug)
@@ -135,12 +135,11 @@ readether(d, pkt, len, tleft, etype)
*/
static char digits[] = "0123456789abcdef";
char *
-ether_sprintf(ap)
- register u_char *ap;
+ether_sprintf(u_char *ap)
{
- register int i;
+ int i;
static char etherbuf[18];
- register char *cp = etherbuf;
+ char *cp = etherbuf;
for (i = 0; i < 6; i++) {
*cp++ = digits[*ap >> 4];
diff --git a/sys/lib/libsa/exec.c b/sys/lib/libsa/exec.c
index 29ea322ff31..a013ace34fd 100644
--- a/sys/lib/libsa/exec.c
+++ b/sys/lib/libsa/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.25 2003/08/04 16:30:35 millert Exp $ */
+/* $OpenBSD: exec.c,v 1.26 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: exec.c,v 1.15 1996/10/13 02:29:01 christos Exp $ */
/*-
@@ -44,10 +44,7 @@ static char *ssym, *esym;
extern u_int opendev;
void
-exec(path, loadaddr, howto)
- char *path;
- void *loadaddr;
- int howto;
+exec(char *path, void *loadaddr, int howto)
{
int io;
#ifndef INSECURE
@@ -82,7 +79,7 @@ exec(path, loadaddr, howto)
x.a_entry, x.a_trsize, x.a_drsize);
#endif
- /* Text */
+ /* Text */
printf("%u", x.a_text);
addr = loadaddr;
sz = x.a_text;
@@ -103,7 +100,7 @@ exec(path, loadaddr, howto)
while ((long)addr & (N_PAGSIZ(x) - 1))
*addr++ = 0;
- /* Data */
+ /* Data */
#ifdef EXEC_DEBUG
daddr = addr;
#endif
@@ -112,12 +109,12 @@ exec(path, loadaddr, howto)
goto shread;
addr += x.a_data;
- /* Bss */
+ /* Bss */
printf("+%u", x.a_bss);
for (i = 0; i < x.a_bss; i++)
*addr++ = 0;
- /* Symbols */
+ /* Symbols */
if (x.a_syms) {
ssym = addr;
bcopy(&x.a_syms, addr, sizeof(x.a_syms));
@@ -162,10 +159,10 @@ exec(path, loadaddr, howto)
printf(" start=0x%x\n", x.a_entry);
#ifdef EXEC_DEBUG
- printf("loadaddr=%p etxt=%p daddr=%p ssym=%p esym=%p\n",
+ printf("loadaddr=%p etxt=%p daddr=%p ssym=%p esym=%p\n",
loadaddr, etxt, daddr, ssym, esym);
- printf("\n\nReturn to boot...\n");
- getchar();
+ printf("\n\nReturn to boot...\n");
+ getchar();
#endif
machdep_start((char *)((register_t)x.a_entry), howto, loadaddr, ssym,
diff --git a/sys/lib/libsa/exit.c b/sys/lib/libsa/exit.c
index b4503f7860c..db825baa9b4 100644
--- a/sys/lib/libsa/exit.c
+++ b/sys/lib/libsa/exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exit.c,v 1.7 2003/06/01 17:00:32 deraadt Exp $ */
+/* $OpenBSD: exit.c,v 1.8 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: exit.c,v 1.11 1996/12/01 20:22:19 pk Exp $ */
/*-
@@ -54,7 +54,7 @@ panic(const char *fmt, ...)
}
void
-exit()
+exit(void)
{
panic("exit");
/*NOTREACHED*/
diff --git a/sys/lib/libsa/fstat.c b/sys/lib/libsa/fstat.c
index fd6c579f29e..efa9b17d964 100644
--- a/sys/lib/libsa/fstat.c
+++ b/sys/lib/libsa/fstat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fstat.c,v 1.3 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: fstat.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd Exp $ */
/*-
@@ -35,11 +35,9 @@
#include "stand.h"
int
-fstat(fd, sb)
- int fd;
- struct stat *sb;
+fstat(int fd, struct stat *sb)
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
errno = EBADF;
diff --git a/sys/lib/libsa/getfile.c b/sys/lib/libsa/getfile.c
index 1821e68431a..ff9bcee9073 100644
--- a/sys/lib/libsa/getfile.c
+++ b/sys/lib/libsa/getfile.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: getfile.c,v 1.4 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: getfile.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: getfile.c,v 1.6 1996/10/14 04:49:21 cgd Exp $ */
/*-
@@ -35,10 +35,10 @@
#define CTRL(x) (x&037)
+int getfile(char *, int);
+
int
-getfile(prompt, mode)
- char *prompt;
- int mode;
+getfile(char *prompt, int mode)
{
int fd;
char buf[100];
diff --git a/sys/lib/libsa/gets.c b/sys/lib/libsa/gets.c
index 95b2c28d029..a724a3c14ca 100644
--- a/sys/lib/libsa/gets.c
+++ b/sys/lib/libsa/gets.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: gets.c,v 1.3 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: gets.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: gets.c,v 1.5.2.1 1995/10/13 19:54:26 pk Exp $ */
/*-
@@ -35,11 +35,10 @@
#include "stand.h"
void
-gets(buf)
- char *buf;
+gets(char *buf)
{
- register int c;
- register char *lp;
+ int c;
+ char *lp;
for (lp = buf;;)
switch (c = getchar() & 0177) {
@@ -64,7 +63,7 @@ gets(buf)
break;
#endif
case 'r'&037: {
- register char *p;
+ char *p;
putchar('\n');
for (p = buf; p < lp; ++p)
diff --git a/sys/lib/libsa/in_cksum.c b/sys/lib/libsa/in_cksum.c
index 928b4fe0e80..f9a12cd8791 100644
--- a/sys/lib/libsa/in_cksum.c
+++ b/sys/lib/libsa/in_cksum.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: in_cksum.c,v 1.2 1996/09/23 14:18:55 mickey Exp $ */
+/* $OpenBSD: in_cksum.c,v 1.3 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: in_cksum.c,v 1.3 1995/04/22 13:53:48 cgd Exp $ */
/*
@@ -41,6 +41,15 @@
*/
#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+
+#include <netinet/if_ether.h>
+#include <netinet/in_systm.h>
+
+#include "stand.h"
+#include "net.h"
/*
* Checksum routine for Internet Protocol family headers.
@@ -49,12 +58,10 @@
* In particular, it should not be this one.
*/
int
-in_cksum(p, len)
- register void *p;
- register int len;
+in_cksum(void *p, int len)
{
- register int sum = 0, oddbyte = 0, v = 0;
- register u_char *cp = p;
+ int sum = 0, oddbyte = 0, v = 0;
+ u_char *cp = p;
/* we assume < 2^16 bytes being summed */
while (len > 0) {
diff --git a/sys/lib/libsa/ioctl.c b/sys/lib/libsa/ioctl.c
index 1941666af18..6cd27141c9a 100644
--- a/sys/lib/libsa/ioctl.c
+++ b/sys/lib/libsa/ioctl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ioctl.c,v 1.4 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: ioctl.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: ioctl.c,v 1.4 1994/10/30 21:48:24 cgd Exp $ */
/*-
@@ -64,12 +64,9 @@
#include "stand.h"
int
-ioctl(fd, cmd, arg)
- int fd;
- u_long cmd;
- char *arg;
+ioctl(int fd, u_long cmd, char *arg)
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
errno = EBADF;
diff --git a/sys/lib/libsa/loadfile.c b/sys/lib/libsa/loadfile.c
index e047b3fec16..3000583965a 100644
--- a/sys/lib/libsa/loadfile.c
+++ b/sys/lib/libsa/loadfile.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile.c,v 1.6 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: loadfile.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -108,10 +108,7 @@ static int aout_exec(int, struct exec *, u_long *, int);
* Fill in marks
*/
int
-loadfile(fname, marks, flags)
- const char *fname;
- u_long *marks;
- int flags;
+loadfile(const char *fname, u_long *marks, int flags)
{
union {
#ifdef BOOT_ECOFF
@@ -177,11 +174,7 @@ err:
#ifdef BOOT_ECOFF
static int
-coff_exec(fd, coff, marks, flags)
- int fd;
- struct ecoff_exechdr *coff;
- u_long *marks;
- int flags;
+coff_exec(int fd, struct ecoff_exechdr *coff, u_long *marks, int flags)
{
paddr_t offset = marks[MARK_START];
paddr_t minp = ~0, maxp = 0, pos;
@@ -263,11 +256,7 @@ coff_exec(fd, coff, marks, flags)
#ifdef BOOT_ELF
static int
-elf_exec(fd, elf, marks, flags)
- int fd;
- Elf_Ehdr *elf;
- u_long *marks;
- int flags;
+elf_exec(int fd, Elf_Ehdr *elf, u_long *marks, int flags)
{
Elf_Shdr *shp;
Elf_Off off;
@@ -434,11 +423,7 @@ elf_exec(fd, elf, marks, flags)
#ifdef BOOT_AOUT
static int
-aout_exec(fd, x, marks, flags)
- int fd;
- struct exec *x;
- u_long *marks;
- int flags;
+aout_exec(int fd, struct exec *x, u_long *marks, int flags)
{
u_long entry = x->a_entry;
paddr_t aoutp = 0;
diff --git a/sys/lib/libsa/lseek.c b/sys/lib/libsa/lseek.c
index c32b861015c..96b64e12e37 100644
--- a/sys/lib/libsa/lseek.c
+++ b/sys/lib/libsa/lseek.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lseek.c,v 1.6 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: lseek.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: lseek.c,v 1.3 1996/06/21 20:09:03 pk Exp $ */
/*-
@@ -65,15 +65,12 @@
off_t
#ifndef __INTERNAL_LIBSA_CREAD
-lseek(fd, offset, where)
+lseek(int fd, off_t offset, int where)
#else
-olseek(fd, offset, where)
+olseek(int fd, off_t offset, int where)
#endif
- int fd;
- off_t offset;
- int where;
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
if ((unsigned)fd >= SOPEN_MAX || f->f_flags == 0) {
errno = EBADF;
diff --git a/sys/lib/libsa/memset.c b/sys/lib/libsa/memset.c
index 3c1dc4b19f2..6438f4366ec 100644
--- a/sys/lib/libsa/memset.c
+++ b/sys/lib/libsa/memset.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memset.c,v 1.3 2003/08/08 03:36:07 deraadt Exp $ */
+/* $OpenBSD: memset.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1993
@@ -37,7 +37,8 @@
void *
memset(void *s1, int c, size_t n)
{
- register char *p = s1;
+ char *p = s1;
+
while (n--)
*p++ = c;
return s1;
diff --git a/sys/lib/libsa/net.c b/sys/lib/libsa/net.c
index c3ebf23d289..eeea424abca 100644
--- a/sys/lib/libsa/net.c
+++ b/sys/lib/libsa/net.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: net.c,v 1.12 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: net.c,v 1.13 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: net.c,v 1.14 1996/10/13 02:29:02 christos Exp $ */
/*
@@ -59,16 +59,13 @@
/* Caller must leave room for ethernet, ip and udp headers in front!! */
ssize_t
-sendudp(d, pkt, len)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
+sendudp(struct iodesc *d, void *pkt, size_t len)
{
- register ssize_t cc;
- register struct ip *ip;
- register struct udpiphdr *ui;
- register struct udphdr *uh;
- register u_char *ea;
+ ssize_t cc;
+ struct ip *ip;
+ struct udpiphdr *ui;
+ struct udphdr *uh;
+ u_char *ea;
struct ip tip;
#ifdef NET_DEBUG
@@ -129,17 +126,13 @@ sendudp(d, pkt, len)
* Caller leaves room for the headers (Ether, IP, UDP)
*/
ssize_t
-readudp(d, pkt, len, tleft)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
- time_t tleft;
+readudp(struct iodesc *d, void *pkt, size_t len, time_t tleft)
{
- register ssize_t n;
- register size_t hlen;
- register struct ip *ip;
- register struct udphdr *uh;
- register struct udpiphdr *ui;
+ ssize_t n;
+ size_t hlen;
+ struct ip *ip;
+ struct udphdr *uh;
+ struct udpiphdr *ui;
struct ip tip;
u_int16_t etype; /* host order */
@@ -276,17 +269,13 @@ readudp(d, pkt, len, tleft)
* zero errno to indicate it isn't done yet.
*/
ssize_t
-sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
- register struct iodesc *d;
- register ssize_t (*sproc)(struct iodesc *, void *, size_t);
- register void *sbuf;
- register size_t ssize;
- register ssize_t (*rproc)(struct iodesc *, void *, size_t, time_t);
- register void *rbuf;
- register size_t rsize;
+sendrecv(struct iodesc *d, ssize_t (*sproc)(struct iodesc *, void *, size_t),
+ void *sbuf, size_t ssize,
+ ssize_t (*rproc)(struct iodesc *, void *, size_t, time_t),
+ void *rbuf, size_t rsize)
{
- register ssize_t cc;
- register time_t t, tmo, tlast;
+ ssize_t cc;
+ time_t t, tmo, tlast;
long tleft;
#ifdef NET_DEBUG
@@ -333,14 +322,13 @@ sendrecv(d, sproc, sbuf, ssize, rproc, rbuf, rsize)
* Return values are in network order.
*/
n_long
-inet_addr(cp)
- char *cp;
+inet_addr(char *cp)
{
- register u_long val;
- register int n;
- register char c;
+ u_long val;
+ int n;
+ char c;
u_int parts[4];
- register u_int *pp = parts;
+ u_int *pp = parts;
for (;;) {
/*
@@ -411,20 +399,18 @@ inet_addr(cp)
}
char *
-inet_ntoa(ia)
- struct in_addr ia;
+inet_ntoa(struct in_addr ia)
{
return (intoa(ia.s_addr));
}
/* Similar to inet_ntoa() */
char *
-intoa(addr)
- register n_long addr;
+intoa(n_long addr)
{
- register char *cp;
- register u_int byte;
- register int n;
+ char *cp;
+ u_int byte;
+ int n;
static char buf[sizeof(".255.255.255.255")];
NTOHL(addr);
@@ -450,9 +436,7 @@ intoa(addr)
}
static char *
-number(s, n)
- char *s;
- int *n;
+number(char *s, int *n)
{
for (*n = 0; isdigit(*s); s++)
*n = (*n * 10) + *s - '0';
@@ -460,8 +444,7 @@ number(s, n)
}
n_long
-ip_convertaddr(p)
- char *p;
+ip_convertaddr(char *p)
{
#define IP_ANYADDR 0
n_long addr = 0, n;
diff --git a/sys/lib/libsa/net.h b/sys/lib/libsa/net.h
index efd33d52424..c43cfa5b779 100644
--- a/sys/lib/libsa/net.h
+++ b/sys/lib/libsa/net.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: net.h,v 1.6 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: net.h,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: net.h,v 1.10 1995/10/20 00:46:30 cgd Exp $ */
/*
@@ -95,6 +95,7 @@ extern struct iodesc sockets[SOPEN_MAX];
u_char *arpwhohas(struct iodesc *, struct in_addr);
void arp_reply(struct iodesc *, void *);
int rarp_getipaddress(int);
+n_long ip_convertaddr(char *);
/* Link functions: */
ssize_t sendether(struct iodesc *d, void *pkt, size_t len,
diff --git a/sys/lib/libsa/netif.c b/sys/lib/libsa/netif.c
index 58d067e4e84..9ca5ffa77be 100644
--- a/sys/lib/libsa/netif.c
+++ b/sys/lib/libsa/netif.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: netif.c,v 1.7 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: netif.c,v 1.8 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: netif.c,v 1.7 1996/10/13 02:29:03 christos Exp $ */
/*
@@ -56,7 +56,7 @@ int netif_debug = 0;
*/
void
-netif_init()
+netif_init(void)
{
struct netif_driver *drv;
int d, i;
@@ -72,10 +72,8 @@ netif_init()
}
}
-int
-netif_match(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
+static int
+netif_match(struct netif *nif, void *machdep_hint)
{
struct netif_driver *drv = nif->nif_driver;
@@ -88,8 +86,7 @@ netif_match(nif, machdep_hint)
}
struct netif *
-netif_select(machdep_hint)
- void *machdep_hint;
+netif_select(void *machdep_hint)
{
int d, u, unit_done, s;
struct netif_driver *drv;
@@ -151,22 +148,20 @@ netif_select(machdep_hint)
if (best_if.nif_driver == NULL)
return NULL;
- best_if.nif_driver->
- netif_ifs[best_if.nif_unit].dif_used |= (1 << best_if.nif_sel);
+ best_if.nif_driver->netif_ifs[best_if.nif_unit].dif_used |=
+ (1 << best_if.nif_sel);
#ifdef NETIF_DEBUG
if (netif_debug)
printf("netif_select: %s%d(%d) wins\n",
- best_if.nif_driver->netif_bname,
- best_if.nif_unit, best_if.nif_sel);
+ best_if.nif_driver->netif_bname,
+ best_if.nif_unit, best_if.nif_sel);
#endif
return &best_if;
}
int
-netif_probe(nif, machdep_hint)
- struct netif *nif;
- void *machdep_hint;
+netif_probe(struct netif *nif, void *machdep_hint)
{
struct netif_driver *drv = nif->nif_driver;
@@ -178,10 +173,7 @@ netif_probe(nif, machdep_hint)
}
void
-netif_attach(nif, desc, machdep_hint)
- struct netif *nif;
- struct iodesc *desc;
- void *machdep_hint;
+netif_attach(struct netif *nif, struct iodesc *desc, void *machdep_hint)
{
struct netif_driver *drv = nif->nif_driver;
@@ -201,8 +193,7 @@ netif_attach(nif, desc, machdep_hint)
}
void
-netif_detach(nif)
- struct netif *nif;
+netif_detach(struct netif *nif)
{
struct netif_driver *drv = nif->nif_driver;
@@ -219,11 +210,7 @@ netif_detach(nif)
}
ssize_t
-netif_get(desc, pkt, len, timo)
- struct iodesc *desc;
- void *pkt;
- size_t len;
- time_t timo;
+netif_get(struct iodesc *desc, void *pkt, size_t len, time_t timo)
{
#ifdef NETIF_DEBUG
struct netif *nif = desc->io_netif;
@@ -250,10 +237,7 @@ netif_get(desc, pkt, len, timo)
}
ssize_t
-netif_put(desc, pkt, len)
- struct iodesc *desc;
- void *pkt;
- size_t len;
+netif_put(struct iodesc *desc, void *pkt, size_t len)
{
#ifdef NETIF_DEBUG
struct netif *nif = desc->io_netif;
@@ -291,11 +275,10 @@ socktodesc(sock)
}
int
-netif_open(machdep_hint)
- void *machdep_hint;
+netif_open(void *machdep_hint)
{
int fd;
- register struct iodesc *s;
+ struct iodesc *s;
struct netif *nif;
/* find a free socket */
@@ -323,8 +306,7 @@ fnd:
}
int
-netif_close(sock)
- int sock;
+netif_close(int sock)
{
if (sock >= SOPEN_MAX) {
errno = EBADF;
diff --git a/sys/lib/libsa/nfs.c b/sys/lib/libsa/nfs.c
index d103b186c74..86e0b65d1dd 100644
--- a/sys/lib/libsa/nfs.c
+++ b/sys/lib/libsa/nfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nfs.c,v 1.9 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: nfs.c,v 1.10 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: nfs.c,v 1.19 1996/10/13 02:29:04 christos Exp $ */
/*-
@@ -102,13 +102,10 @@ struct nfs_iodesc nfs_root_node;
* Fetch the root file handle (call mount daemon)
* On error, return non-zero and set errno.
*/
-int
-nfs_getrootfh(d, path, fhp)
- register struct iodesc *d;
- char *path;
- u_char *fhp;
+static int
+nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
{
- register int len;
+ int len;
struct args {
n_long len;
char path[FNAME_SIZE];
@@ -165,13 +162,10 @@ nfs_getrootfh(d, path, fhp)
* Lookup a file. Store handle and attributes.
* Return zero or error number.
*/
-int
-nfs_lookupfh(d, name, newfd)
- struct nfs_iodesc *d;
- char *name;
- struct nfs_iodesc *newfd;
+static int
+nfs_lookupfh(struct nfs_iodesc *d, char *name, struct nfs_iodesc *newfd)
{
- register int len, rlen;
+ int len, rlen;
struct args {
u_char fh[NFS_FHSIZE];
n_long len;
@@ -230,10 +224,8 @@ nfs_lookupfh(d, name, newfd)
/*
* Get the destination of a symbolic link.
*/
-int
-nfs_readlink(d, buf)
- struct nfs_iodesc *d;
- char *buf;
+static int
+nfs_readlink(struct nfs_iodesc *d, char *buf)
{
struct {
n_long h[RPC_HEADER_WORDS];
@@ -252,8 +244,8 @@ nfs_readlink(d, buf)
bcopy(d->fh, sdata.fh, NFS_FHSIZE);
cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK,
- sdata.fh, NFS_FHSIZE,
- &rdata.d, sizeof(rdata.d));
+ sdata.fh, NFS_FHSIZE,
+ &rdata.d, sizeof(rdata.d));
if (cc == -1)
return (errno);
@@ -276,12 +268,8 @@ nfs_readlink(d, buf)
* Read data from a file.
* Return transfer count or -1 (and set errno)
*/
-ssize_t
-nfs_readdata(d, off, addr, len)
- struct nfs_iodesc *d;
- off_t off;
- void *addr;
- size_t len;
+static ssize_t
+nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len)
{
struct nfs_read_args *args;
struct nfs_read_repl *repl;
@@ -339,10 +327,7 @@ nfs_readdata(d, off, addr, len)
* On error, return non-zero and set errno.
*/
int
-nfs_mount(sock, ip, path)
- int sock;
- struct in_addr ip;
- char *path;
+nfs_mount(int sock, struct in_addr ip, char *path)
{
struct iodesc *desc;
struct nfsv2_fattrs *fa;
@@ -377,17 +362,12 @@ nfs_mount(sock, ip, path)
* return zero or error number
*/
int
-nfs_open(path, f)
- char *path;
- struct open_file *f;
+nfs_open(char *path, struct open_file *f)
{
struct nfs_iodesc *newfd, *currfd;
- register char *cp, *ncp;
- register int c;
- char namebuf[NFS_MAXPATHLEN + 1];
+ char namebuf[NFS_MAXPATHLEN + 1], *cp, *ncp;
char linkbuf[NFS_MAXPATHLEN + 1];
- int nlinks = 0;
- int error = 0;
+ int nlinks = 0, error = 0, c;
#ifdef NFS_DEBUG
if (debug)
@@ -428,7 +408,7 @@ nfs_open(path, f)
* Get next component of path name.
*/
{
- register int len = 0;
+ int len = 0;
ncp = cp;
while ((c = *cp) != '\0' && c != '/') {
@@ -460,8 +440,8 @@ nfs_open(path, f)
link_len = strlen(linkbuf);
len = strlen(cp);
- if (link_len + len > MAXPATHLEN
- || ++nlinks > MAXSYMLINKS) {
+ if (link_len + len > MAXPATHLEN ||
+ ++nlinks > MAXSYMLINKS) {
error = ENOENT;
goto out;
}
@@ -514,10 +494,9 @@ out:
}
int
-nfs_close(f)
- struct open_file *f;
+nfs_close(struct open_file *f)
{
- register struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
+ struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
#ifdef NFS_DEBUG
if (debug)
@@ -535,15 +514,11 @@ nfs_close(f)
* read a portion of a file
*/
int
-nfs_read(f, buf, size, resid)
- struct open_file *f;
- void *buf;
- size_t size;
- size_t *resid; /* out */
+nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
- register struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
- register ssize_t cc;
- register char *addr = buf;
+ struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
+ ssize_t cc;
+ char *addr = buf;
#ifdef NFS_DEBUG
if (debug)
@@ -580,22 +555,15 @@ ret:
* Not implemented.
*/
int
-nfs_write(f, buf, size, resid)
- struct open_file *f;
- void *buf;
- size_t size;
- size_t *resid; /* out */
+nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid)
{
return (EROFS);
}
off_t
-nfs_seek(f, offset, where)
- struct open_file *f;
- off_t offset;
- int where;
+nfs_seek(struct open_file *f, off_t offset, int where)
{
- register struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata;
+ struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata;
n_long size = ntohl(d->fa.fa_size);
switch (where) {
@@ -620,12 +588,10 @@ int nfs_stat_types[8] = {
0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 };
int
-nfs_stat(f, sb)
- struct open_file *f;
- struct stat *sb;
+nfs_stat(struct open_file *f, struct stat *sb)
{
struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata;
- register n_long ftype, mode;
+ n_long ftype, mode;
ftype = ntohl(fp->fa.fa_type);
mode = ntohl(fp->fa.fa_mode);
@@ -645,9 +611,7 @@ nfs_stat(f, sb)
*/
#ifndef NO_READDIR
int
-nfs_readdir(f, name)
- struct open_file *f;
- char *name;
+nfs_readdir(struct open_file *f, char *name)
{
return (EROFS);
}
diff --git a/sys/lib/libsa/nullfs.c b/sys/lib/libsa/nullfs.c
index 4b4ba3a1b4e..6c6324bbc9f 100644
--- a/sys/lib/libsa/nullfs.c
+++ b/sys/lib/libsa/nullfs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nullfs.c,v 1.6 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: nullfs.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: open.c,v 1.9 1995/09/19 09:16:52 thorpej Exp $ */
/*-
@@ -67,7 +67,7 @@
* Null filesystem
*/
int
-null_open (char *path, struct open_file *f)
+null_open(char *path, struct open_file *f)
{
return EIO;
}
@@ -79,33 +79,33 @@ null_close(struct open_file *f)
}
ssize_t
-null_read (struct open_file *f, void *buf, size_t size, size_t *resid)
+null_read(struct open_file *f, void *buf, size_t size, size_t *resid)
{
return EIO;
}
ssize_t
-null_write (struct open_file *f, void *buf, size_t size, size_t *resid)
+null_write(struct open_file *f, void *buf, size_t size, size_t *resid)
{
return EIO;
}
off_t
-null_seek (struct open_file *f, off_t offset, int where)
+null_seek(struct open_file *f, off_t offset, int where)
{
errno = EIO;
return -1;
}
int
-null_stat (struct open_file *f, struct stat *sb)
+null_stat(struct open_file *f, struct stat *sb)
{
return EIO;
}
#ifndef NO_READDIR
int
-null_readdir (struct open_file *f, char *name)
+null_readdir(struct open_file *f, char *name)
{
return EIO;
}
diff --git a/sys/lib/libsa/open.c b/sys/lib/libsa/open.c
index d692b855015..46bba1a42be 100644
--- a/sys/lib/libsa/open.c
+++ b/sys/lib/libsa/open.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: open.c,v 1.9 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: open.c,v 1.10 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: open.c,v 1.12 1996/09/30 16:01:21 ws Exp $ */
/*-
@@ -71,15 +71,13 @@ struct open_file files[SOPEN_MAX];
int
#ifndef __INTERNAL_LIBSA_CREAD
-open(fname, mode)
+open(const char *fname, int mode)
#else
-oopen(fname, mode)
+oopen(const char *fname, int mode)
#endif
- const char *fname;
- int mode;
{
- register struct open_file *f;
- register int fd, i, error;
+ struct open_file *f;
+ int fd, i, error;
char *file;
/* find a free file descriptor */
diff --git a/sys/lib/libsa/printf.c b/sys/lib/libsa/printf.c
index 61587f2307c..2abd62aa1f2 100644
--- a/sys/lib/libsa/printf.c
+++ b/sys/lib/libsa/printf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: printf.c,v 1.20 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: printf.c,v 1.21 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: printf.c,v 1.10 1996/11/30 04:19:21 gwr Exp $ */
/*-
@@ -81,14 +81,11 @@ vprintf(const char *fmt, va_list ap)
}
void
-kdoprnt(put, fmt, ap)
- void (*put)(int);
- const char *fmt;
- va_list ap;
+kdoprnt(void (*put)(int), const char *fmt, va_list ap)
{
- char *p;
unsigned long ul;
int ch, lflag;
+ char *p;
for (;;) {
while ((ch = *fmt++) != '%') {
@@ -105,6 +102,7 @@ reswitch: switch (ch = *fmt++) {
case 'b':
{
int set, n;
+
ul = va_arg(ap, int);
p = va_arg(ap, char *);
kprintn(put, ul, *p++);
@@ -119,7 +117,8 @@ reswitch: switch (ch = *fmt++) {
put(n);
set = 1;
} else
- for (; *p > ' '; ++p);
+ for (; *p > ' '; ++p)
+ ;
}
if (set)
put('>');
@@ -128,7 +127,7 @@ reswitch: switch (ch = *fmt++) {
#endif
case 'c':
ch = va_arg(ap, int);
- put(ch & 0x7f);
+ put(ch & 0x7f);
break;
case 's':
p = va_arg(ap, char *);
@@ -174,12 +173,9 @@ reswitch: switch (ch = *fmt++) {
}
void
-kprintn(put, ul, base)
- void (*put)(int);
- unsigned long ul;
- int base;
+kprintn(void (*put)(int), unsigned long ul, int base)
{
- /* hold a long in base 8 */
+ /* hold a long in base 8 */
char *p, buf[(sizeof(long) * NBBY / 3) + 1];
p = buf;
@@ -194,7 +190,7 @@ kprintn(put, ul, base)
int donottwiddle = 0;
void
-twiddle()
+twiddle(void)
{
static int pos;
diff --git a/sys/lib/libsa/rarp.c b/sys/lib/libsa/rarp.c
index 225f6e96e54..b21152bc0a1 100644
--- a/sys/lib/libsa/rarp.c
+++ b/sys/lib/libsa/rarp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rarp.c,v 1.9 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: rarp.c,v 1.10 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: rarp.c,v 1.13 1996/10/13 02:29:05 christos Exp $ */
/*
@@ -58,11 +58,10 @@ static ssize_t rarprecv(struct iodesc *, void *, size_t, time_t);
* Ethernet (Reverse) Address Resolution Protocol (see RFC 903, and 826).
*/
int
-rarp_getipaddress(sock)
- int sock;
+rarp_getipaddress(int sock)
{
struct iodesc *d;
- register struct ether_arp *ap;
+ struct ether_arp *ap;
struct {
u_char header[ETHER_SIZE];
struct {
@@ -132,10 +131,7 @@ rarp_getipaddress(sock)
* Broadcast a RARP request (i.e. who knows who I am)
*/
static ssize_t
-rarpsend(d, pkt, len)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
+rarpsend(struct iodesc *d, void *pkt, size_t len)
{
#ifdef RARP_DEBUG
@@ -151,14 +147,10 @@ rarpsend(d, pkt, len)
* else -1 (and errno == 0)
*/
static ssize_t
-rarprecv(d, pkt, len, tleft)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
- time_t tleft;
+rarprecv(struct iodesc *d, void *pkt, size_t len, time_t tleft)
{
- register ssize_t n;
- register struct ether_arp *ap;
+ ssize_t n;
+ struct ether_arp *ap;
u_int16_t etype; /* host order */
#ifdef RARP_DEBUG
diff --git a/sys/lib/libsa/read.c b/sys/lib/libsa/read.c
index 14dc4508be9..763db895b98 100644
--- a/sys/lib/libsa/read.c
+++ b/sys/lib/libsa/read.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: read.c,v 1.6 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: read.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: read.c,v 1.7 1996/06/21 20:29:28 pk Exp $ */
/*-
@@ -66,15 +66,12 @@
ssize_t
#ifndef __INTERNAL_LIBSA_CREAD
-read(fd, dest, bcount)
+read(int fd, void *dest, size_t bcount)
#else
-oread(fd, dest, bcount)
+oread(int fd, void *dest, size_t bcount)
#endif
- int fd;
- void *dest;
- size_t bcount;
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
size_t resid;
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_READ)) {
diff --git a/sys/lib/libsa/readdir.c b/sys/lib/libsa/readdir.c
index e3e5a7bb4ba..cd2ccb50bba 100644
--- a/sys/lib/libsa/readdir.c
+++ b/sys/lib/libsa/readdir.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: readdir.c,v 1.6 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: readdir.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -38,11 +38,10 @@
int
-opendir(name)
- char *name;
+opendir(char *name)
{
- int fd;
struct stat sb;
+ int fd;
if (stat(name, &sb) < 0)
return -1;
@@ -65,11 +64,9 @@ opendir(name)
}
int
-readdir(fd, dest)
- int fd;
- char *dest;
+readdir(int fd, char *dest)
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
if (fd < 0 || fd >= SOPEN_MAX ||
!((f = &files[fd])->f_flags & F_READ)) {
@@ -88,8 +85,7 @@ readdir(fd, dest)
}
void
-closedir(fd)
- int fd;
+closedir(int fd)
{
#ifdef __INTERNAL_LIBSA_CREAD
oclose(fd);
diff --git a/sys/lib/libsa/rpc.c b/sys/lib/libsa/rpc.c
index 35b692bc38f..2e51b4f835c 100644
--- a/sys/lib/libsa/rpc.c
+++ b/sys/lib/libsa/rpc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc.c,v 1.12 2003/06/01 17:00:33 deraadt Exp $ */
+/* $OpenBSD: rpc.c,v 1.13 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: rpc.c,v 1.16 1996/10/13 02:29:06 christos Exp $ */
/*
@@ -108,15 +108,10 @@ int rpc_port = 0x400; /* predecrement */
* Note: Caller must leave room for headers.
*/
ssize_t
-rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
- register struct iodesc *d;
- register n_long prog, vers, proc;
- register void *sdata;
- register size_t slen;
- register void *rdata;
- register size_t rlen;
+rpc_call(struct iodesc *d, n_long prog, n_long vers, n_long proc, void *sdata,
+ size_t slen, void *rdata, size_t rlen)
{
- register ssize_t cc;
+ ssize_t cc;
struct auth_info *auth;
struct rpc_call *call;
struct rpc_reply *reply;
@@ -232,13 +227,9 @@ rpc_call(d, prog, vers, proc, sdata, slen, rdata, rlen)
* Remaining checks are done by callrpc
*/
static ssize_t
-recvrpc(d, pkt, len, tleft)
- register struct iodesc *d;
- register void *pkt;
- register size_t len;
- time_t tleft;
+recvrpc(struct iodesc *d, void *pkt, size_t len, time_t tleft)
{
- register struct rpc_reply *reply;
+ struct rpc_reply *reply;
ssize_t n;
int x;
@@ -288,10 +279,7 @@ recvrpc(d, pkt, len, tleft)
* dig out the IP address/port from the headers.
*/
void
-rpc_fromaddr(pkt, addr, port)
- void *pkt;
- struct in_addr *addr;
- u_short *port;
+rpc_fromaddr(void *pkt, struct in_addr *addr, u_short *port)
{
struct hackhdr {
/* Tail of IP header: just IP addresses */
@@ -326,29 +314,20 @@ struct pmap_list {
/* return port number in host order, or -1 */
int
-rpc_pmap_getcache(addr, prog, vers)
- struct in_addr addr; /* server, net order */
- u_int prog; /* host order */
- u_int vers; /* host order */
+rpc_pmap_getcache(struct in_addr addr, u_int prog, u_int vers)
{
struct pmap_list *pl;
for (pl = rpc_pmap_list; pl < &rpc_pmap_list[rpc_pmap_num]; pl++) {
if (pl->addr.s_addr == addr.s_addr &&
- pl->prog == prog && pl->vers == vers )
- {
+ pl->prog == prog && pl->vers == vers)
return (pl->port);
- }
}
return (-1);
}
void
-rpc_pmap_putcache(addr, prog, vers, port)
- struct in_addr addr; /* server, net order */
- u_int prog; /* host order */
- u_int vers; /* host order */
- int port; /* host order */
+rpc_pmap_putcache(struct in_addr addr, u_int prog, u_int vers, int port)
{
struct pmap_list *pl;
@@ -377,10 +356,7 @@ rpc_pmap_putcache(addr, prog, vers, port)
* Returns the port in host order.
*/
int
-rpc_getport(d, prog, vers)
- register struct iodesc *d;
- n_long prog; /* host order */
- n_long vers; /* host order */
+rpc_getport(struct iodesc *d, n_long prog, n_long vers)
{
struct args {
n_long prog; /* call program */
diff --git a/sys/lib/libsa/rpc.h b/sys/lib/libsa/rpc.h
index e16d654d8a6..724c3f801ef 100644
--- a/sys/lib/libsa/rpc.h
+++ b/sys/lib/libsa/rpc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: rpc.h,v 1.4 2002/03/14 01:27:07 millert Exp $ */
+/* $OpenBSD: rpc.h,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: rpc.h,v 1.8 1996/09/26 23:22:03 cgd Exp $ */
/*
@@ -51,7 +51,7 @@
/* RPC functions: */
ssize_t rpc_call(struct iodesc *, n_long, n_long, n_long,
- void *, size_t, void *, size_t);
+ void *, size_t, void *, size_t);
void rpc_fromaddr(void *, struct in_addr *, u_short *);
int rpc_pmap_getcache(struct in_addr, u_int, u_int);
void rpc_pmap_putcache(struct in_addr, u_int, u_int, int);
diff --git a/sys/lib/libsa/snprintf.c b/sys/lib/libsa/snprintf.c
index c936a63904c..df17463e084 100644
--- a/sys/lib/libsa/snprintf.c
+++ b/sys/lib/libsa/snprintf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: snprintf.c,v 1.2 2003/06/04 17:38:24 millert Exp $ */
+/* $OpenBSD: snprintf.c,v 1.3 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: printf.c,v 1.10 1996/11/30 04:19:21 gwr Exp $ */
/*-
@@ -48,8 +48,7 @@ static char *sbuf, *sbuf_end;
static size_t sbuf_len;
void
-sputchar(c)
- int c;
+sputchar(int c)
{
if (sbuf < sbuf_end)
*sbuf = c;
diff --git a/sys/lib/libsa/stand.h b/sys/lib/libsa/stand.h
index a36ec9653db..725a02abd77 100644
--- a/sys/lib/libsa/stand.h
+++ b/sys/lib/libsa/stand.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: stand.h,v 1.41 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: stand.h,v 1.42 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: stand.h,v 1.18 1996/11/30 04:35:51 gwr Exp $ */
/*-
@@ -63,9 +63,9 @@ struct fs_ops {
int (*open)(char *path, struct open_file *f);
int (*close)(struct open_file *f);
int (*read)(struct open_file *f, void *buf,
- size_t size, size_t *resid);
+ size_t size, size_t *resid);
int (*write)(struct open_file *f, void *buf,
- size_t size, size_t *resid);
+ size_t size, size_t *resid);
off_t (*seek)(struct open_file *f, off_t offset, int where);
int (*stat)(struct open_file *f, struct stat *sb);
int (*readdir)(struct open_file *f, char *);
@@ -191,6 +191,8 @@ u_int sleep(u_int);
void usleep(u_int);
char *ctime(const time_t *);
+int ioctl(int, u_long, char *);
+
void putchar(int);
int getchar(void);
diff --git a/sys/lib/libsa/stat.c b/sys/lib/libsa/stat.c
index c76066559eb..013dd06e263 100644
--- a/sys/lib/libsa/stat.c
+++ b/sys/lib/libsa/stat.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: stat.c,v 1.5 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: stat.c,v 1.6 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: stat.c,v 1.3 1994/10/26 05:45:07 cgd Exp $ */
/*-
@@ -35,9 +35,7 @@
#include "stand.h"
int
-stat(str, sb)
- const char *str;
- struct stat *sb;
+stat(const char *str, struct stat *sb)
{
int fd, rv;
diff --git a/sys/lib/libsa/strchr.c b/sys/lib/libsa/strchr.c
index c71d77fdc34..28891c699c0 100644
--- a/sys/lib/libsa/strchr.c
+++ b/sys/lib/libsa/strchr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strchr.c,v 1.3 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: strchr.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -30,7 +30,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char *rcsid = "$OpenBSD: strchr.c,v 1.3 2003/06/02 23:28:09 millert Exp $";
+static char *rcsid = "$OpenBSD: strchr.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
#ifndef _STANDALONE
@@ -40,8 +40,7 @@ static char *rcsid = "$OpenBSD: strchr.c,v 1.3 2003/06/02 23:28:09 millert Exp $
#endif
char *
-strchr(p, ch)
- register const char *p, ch;
+strchr(const char *p, int ch)
{
for (;; ++p) {
if (*p == ch)
diff --git a/sys/lib/libsa/strcmp.c b/sys/lib/libsa/strcmp.c
index a87ed838e81..856e6383cc4 100644
--- a/sys/lib/libsa/strcmp.c
+++ b/sys/lib/libsa/strcmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strcmp.c,v 1.4 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: strcmp.c,v 1.5 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1996 Michael Shalayeff
@@ -31,9 +31,7 @@
#include "stand.h"
int
-strcmp(s1, s2)
- register const char *s1;
- register const char *s2;
+strcmp(const char *s1, const char *s2)
{
while(*s1 && *s2 && *s1 == *s2)
s1++, s2++;
diff --git a/sys/lib/libsa/strerror.c b/sys/lib/libsa/strerror.c
index 245541b8bc9..c5677534c26 100644
--- a/sys/lib/libsa/strerror.c
+++ b/sys/lib/libsa/strerror.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strerror.c,v 1.7 2003/06/02 23:28:09 millert Exp $ */
+/* $OpenBSD: strerror.c,v 1.8 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: strerror.c,v 1.11 1996/10/13 02:29:08 christos Exp $ */
/*-
@@ -35,8 +35,7 @@
#include "stand.h"
char *
-strerror(err)
- int err;
+strerror(int err)
{
static char ebuf[64];
@@ -69,7 +68,6 @@ strerror(err)
return "Input/output error";
case EINVAL:
return "Invalid argument";
-
default:
snprintf(ebuf, sizeof ebuf, "Unknown error: code %d", err);
return ebuf;
diff --git a/sys/lib/libsa/strlen.c b/sys/lib/libsa/strlen.c
index 6be1dd2299a..3c37dd54d15 100644
--- a/sys/lib/libsa/strlen.c
+++ b/sys/lib/libsa/strlen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strlen.c,v 1.3 2003/06/02 23:28:10 millert Exp $ */
+/* $OpenBSD: strlen.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -36,12 +36,12 @@
#include "stand.h"
size_t
-strlen(str)
- const char *str;
+strlen(const char *str)
{
- register const char *s;
+ const char *s;
- for (s = str; *s; ++s);
- return(s - str);
+ for (s = str; *s; ++s)
+ ;
+ return (s - str);
}
diff --git a/sys/lib/libsa/strncmp.c b/sys/lib/libsa/strncmp.c
index f405e428378..48541b12afd 100644
--- a/sys/lib/libsa/strncmp.c
+++ b/sys/lib/libsa/strncmp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strncmp.c,v 1.3 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: strncmp.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1996 Michael Shalayeff
@@ -31,15 +31,12 @@
#include "stand.h"
int
-strncmp(s1, s2, len)
- register const char *s1;
- register const char *s2;
- register size_t len;
+strncmp(const char *s1, const char *s2, size_t len)
{
if (len-- == 0)
return 0;
- while(*s1 && *s2 && len-- && *s1 == *s2)
+ while (*s1 && *s2 && len-- && *s1 == *s2)
s1++, s2++;
return *s1 - *s2;
}
diff --git a/sys/lib/libsa/strncpy.c b/sys/lib/libsa/strncpy.c
index 1c9cc31bee3..d199c26e349 100644
--- a/sys/lib/libsa/strncpy.c
+++ b/sys/lib/libsa/strncpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strncpy.c,v 1.3 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: strncpy.c,v 1.4 2003/08/11 06:23:09 deraadt Exp $ */
/*-
* Copyright (c) 1996 Michael Shalayeff
@@ -31,13 +31,11 @@
#include "stand.h"
char *
-strncpy(s1, s2, n)
- char *s1;
- const char *s2;
- size_t n;
+strncpy(char *s1, const char *s2, size_t n)
{
char *p = s1;
- while(n-- && (*s1++ = *s2++) != '\0')
+
+ while (n-- && (*s1++ = *s2++) != '\0')
;
return p;
}
diff --git a/sys/lib/libsa/strtol.c b/sys/lib/libsa/strtol.c
index a7d786a628e..9924fe04499 100644
--- a/sys/lib/libsa/strtol.c
+++ b/sys/lib/libsa/strtol.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strtol.c,v 1.5 2003/07/05 17:03:07 deraadt Exp $ */
+/* $OpenBSD: strtol.c,v 1.6 2003/08/11 06:23:09 deraadt Exp $ */
/* Modified strtol() from stdlib */
/*-
* Copyright (c) 1990 The Regents of the University of California.
@@ -30,6 +30,7 @@
*/
#include <sys/param.h>
+#include "stand.h"
/*
* Convert a string to a long integer.
diff --git a/sys/lib/libsa/ufs.c b/sys/lib/libsa/ufs.c
index b9eb7ae8fe6..196b2f2f53c 100644
--- a/sys/lib/libsa/ufs.c
+++ b/sys/lib/libsa/ufs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ufs.c,v 1.15 2003/06/02 23:28:10 millert Exp $ */
+/* $OpenBSD: ufs.c,v 1.16 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: ufs.c,v 1.16 1996/09/30 16:01:22 ws Exp $ */
/*-
@@ -72,6 +72,7 @@
#include <lib/libkern/libkern.h>
#include "stand.h"
+#include "ufs.h"
/*
* In-core open file.
@@ -105,12 +106,10 @@ static void ffs_oldfscompat(struct fs *);
* Read a new inode into a file structure.
*/
static int
-read_inode(inumber, f)
- ino_t inumber;
- struct open_file *f;
+read_inode(ino_t inumber, struct open_file *f)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct fs *fs = fp->f_fs;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct fs *fs = fp->f_fs;
char *buf;
size_t rsize;
int rc;
@@ -131,7 +130,7 @@ read_inode(inumber, f)
}
{
- register struct dinode *dp;
+ struct dinode *dp;
dp = (struct dinode *)buf;
fp->f_di = dp[ino_to_fsbo(fs, inumber)];
@@ -141,7 +140,7 @@ read_inode(inumber, f)
* Clear out the old buffers
*/
{
- register int level;
+ int level;
for (level = 0; level < NIADDR; level++)
fp->f_blkno[level] = -1;
@@ -157,18 +156,12 @@ out:
* contains that block.
*/
static int
-block_map(f, file_block, disk_block_p)
- struct open_file *f;
- daddr_t file_block;
- daddr_t *disk_block_p; /* out */
+block_map(struct open_file *f, daddr_t file_block, daddr_t *disk_block_p)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct fs *fs = fp->f_fs;
- int level;
- int idx;
- daddr_t ind_block_num;
- daddr_t *ind_p;
- int rc;
+ struct file *fp = (struct file *)f->f_fsdata;
+ daddr_t ind_block_num, *ind_p;
+ struct fs *fs = fp->f_fs;
+ int level, idx, rc;
/*
* Index structure of an inode:
@@ -252,7 +245,6 @@ block_map(f, file_block, disk_block_p)
}
*disk_block_p = ind_block_num;
-
return (0);
}
@@ -261,17 +253,13 @@ block_map(f, file_block, disk_block_p)
* the location in the buffer and the amount in the buffer.
*/
static int
-buf_read_file(f, buf_p, size_p)
- struct open_file *f;
- char **buf_p; /* out */
- size_t *size_p; /* out */
+buf_read_file(struct open_file *f, char **buf_p, size_t *size_p)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct fs *fs = fp->f_fs;
- long off;
- register daddr_t file_block;
- daddr_t disk_block;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct fs *fs = fp->f_fs;
+ daddr_t file_block, disk_block;
size_t block_size;
+ long off;
int rc;
off = blkoff(fs, fp->f_seekp);
@@ -323,18 +311,13 @@ buf_read_file(f, buf_p, size_p)
* i_number.
*/
static int
-search_directory(name, f, inumber_p)
- char *name;
- struct open_file *f;
- ino_t *inumber_p; /* out */
+search_directory(char *name, struct open_file *f, ino_t *inumber_p)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register struct direct *dp;
- struct direct *edp;
- char *buf;
+ struct file *fp = (struct file *)f->f_fsdata;
+ int namlen, length, rc;
+ struct direct *dp, *edp;
size_t buf_size;
- int namlen, length;
- int rc;
+ char *buf;
length = strlen(name);
@@ -373,20 +356,14 @@ search_directory(name, f, inumber_p)
* Open a file.
*/
int
-ufs_open(path, f)
- char *path;
- struct open_file *f;
+ufs_open(char *path, struct open_file *f)
{
- register char *cp, *ncp;
- register int c;
+ char namebuf[MAXPATHLEN+1], *cp, *ncp, *buf = NULL;
ino_t inumber, parent_inumber;
+ int rc, c, nlinks = 0;
struct file *fp;
- struct fs *fs;
- int rc;
size_t buf_size;
- int nlinks = 0;
- char namebuf[MAXPATHLEN+1];
- char *buf = NULL;
+ struct fs *fs;
/* allocate file system specific data structure */
fp = alloc(sizeof(struct file));
@@ -415,8 +392,8 @@ ufs_open(path, f)
* Calculate indirect block levels.
*/
{
- register int mult;
- register int level;
+ int mult;
+ int level;
mult = 1;
for (level = 0; level < NIADDR; level++) {
@@ -452,7 +429,7 @@ ufs_open(path, f)
* Get next component of path name.
*/
{
- register int len = 0;
+ int len = 0;
ncp = cp;
while ((c = *cp) != '\0' && c != '/') {
@@ -508,7 +485,7 @@ ufs_open(path, f)
*/
size_t buf_size;
daddr_t disk_block;
- register struct fs *fs = fp->f_fs;
+ struct fs *fs = fp->f_fs;
if (!buf)
buf = alloc(fs->fs_bsize);
@@ -556,10 +533,9 @@ out:
}
int
-ufs_close(f)
- struct open_file *f;
+ufs_close(struct open_file *f)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
int level;
f->f_fsdata = (void *)0;
@@ -582,18 +558,12 @@ ufs_close(f)
* Cross block boundaries when necessary.
*/
int
-ufs_read(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid; /* out */
+ufs_read(struct open_file *f, void *start, size_t size, size_t *resid)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- register size_t csize;
- char *buf;
- size_t buf_size;
+ struct file *fp = (struct file *)f->f_fsdata;
+ char *buf, *addr = start;
+ size_t csize, buf_size;
int rc = 0;
- register char *addr = start;
while (size != 0) {
if (fp->f_seekp >= fp->f_di.di_size)
@@ -622,23 +592,16 @@ ufs_read(f, start, size, resid)
* Not implemented.
*/
int
-ufs_write(f, start, size, resid)
- struct open_file *f;
- void *start;
- size_t size;
- size_t *resid; /* out */
+ufs_write(struct open_file *f, void *start, size_t size, size_t *resid)
{
return (EROFS);
}
off_t
-ufs_seek(f, offset, where)
- struct open_file *f;
- off_t offset;
- int where;
+ufs_seek(struct open_file *f, off_t offset, int where)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
switch (where) {
case SEEK_SET:
@@ -657,11 +620,9 @@ ufs_seek(f, offset, where)
}
int
-ufs_stat(f, sb)
- struct open_file *f;
- struct stat *sb;
+ufs_stat(struct open_file *f, struct stat *sb)
{
- register struct file *fp = (struct file *)f->f_fsdata;
+ struct file *fp = (struct file *)f->f_fsdata;
/* only important stuff */
sb->st_mode = fp->f_di.di_mode;
@@ -673,15 +634,13 @@ ufs_stat(f, sb)
#ifndef NO_READDIR
int
-ufs_readdir(f, name)
- struct open_file *f;
- char *name;
+ufs_readdir(struct open_file *f, char *name)
{
- register struct file *fp = (struct file *)f->f_fsdata;
- char *buf;
+ struct file *fp = (struct file *)f->f_fsdata;
+ struct direct *dp, *edp;
size_t buf_size;
- register struct direct *dp, *edp;
int rc, namlen;
+ char *buf;
if (name == NULL)
fp->f_seekp = 0;
@@ -726,8 +685,7 @@ ufs_readdir(f, name)
* XXX - goes away some day.
*/
static void
-ffs_oldfscompat(fs)
- struct fs *fs;
+ffs_oldfscompat(struct fs *fs)
{
int i;
diff --git a/sys/lib/libsa/unixdev.c b/sys/lib/libsa/unixdev.c
index 63a8d4d275d..f3d63b3e73f 100644
--- a/sys/lib/libsa/unixdev.c
+++ b/sys/lib/libsa/unixdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unixdev.c,v 1.6 2003/06/02 20:20:53 mickey Exp $ */
+/* $OpenBSD: unixdev.c,v 1.7 2003/08/11 06:23:09 deraadt Exp $ */
/*
* Copyright (c) 1996-1998 Michael Shalayeff
@@ -39,13 +39,8 @@
#include <lib/libsa/unixdev.h>
int
-unixstrategy(devdata, rw, blk, size, buf, rsize)
- void *devdata;
- int rw;
- daddr_t blk;
- size_t size;
- void *buf;
- size_t *rsize;
+unixstrategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
+ size_t *rsize)
{
int rc = 0;
@@ -69,9 +64,9 @@ unixstrategy(devdata, rw, blk, size, buf, rsize)
int
unixopen(struct open_file *f, ...)
{
- register int fd;
- register va_list ap;
- register char **file, *p = NULL;
+ char **file, *p = NULL;
+ va_list ap;
+ int fd;
va_start(ap, f);
file = va_arg(ap, char **);
@@ -99,34 +94,26 @@ unixopen(struct open_file *f, ...)
}
int
-unixclose(f)
- struct open_file *f;
+unixclose(struct open_file *f)
{
return uclose((int)f->f_devdata);
}
int
-unixioctl(f, cmd, data)
- struct open_file *f;
- u_long cmd;
- void *data;
+unixioctl(struct open_file *f, u_long cmd, void *data)
{
return uioctl((int)f->f_devdata, cmd, data);
}
off_t
-ulseek( fd, off, wh)
- int fd;
- off_t off;
- int wh;
+ulseek(int fd, off_t off, int wh)
{
return __syscall((quad_t)SYS_lseek, fd, 0, off, wh);
}
void
-unix_probe(cn)
- struct consdev *cn;
+unix_probe(struct consdev *cn)
{
cn->cn_pri = CN_INTERNAL;
cn->cn_dev = makedev(0,0);
@@ -134,22 +121,18 @@ unix_probe(cn)
}
void
-unix_init(cn)
- struct consdev *cn;
+unix_init(struct consdev *cn)
{
}
void
-unix_putc(dev, c)
- dev_t dev;
- int c;
+unix_putc(dev_t dev, int c)
{
uwrite(1, &c, 1);
}
int
-unix_getc(dev)
- dev_t dev;
+unix_getc(dev_t dev)
{
if (dev & 0x80) {
struct timeval tv;
@@ -173,31 +156,28 @@ unix_getc(dev)
}
time_t
-getsecs()
+getsecs(void)
{
return 1;
}
void
-time_print()
+time_print(void)
{
}
void
-atexit()
+atexit(void)
{
}
int
-cnspeed(dev, sp)
- dev_t dev;
- int sp;
+cnspeed(dev_t dev, int sp)
{
return 9600;
}
void
-__main()
+__main(void)
{
}
-
diff --git a/sys/lib/libsa/write.c b/sys/lib/libsa/write.c
index 3d98e25805a..82524f3b024 100644
--- a/sys/lib/libsa/write.c
+++ b/sys/lib/libsa/write.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: write.c,v 1.5 2003/06/02 23:28:10 millert Exp $ */
+/* $OpenBSD: write.c,v 1.6 2003/08/11 06:23:09 deraadt Exp $ */
/* $NetBSD: write.c,v 1.7 1996/06/21 20:29:30 pk Exp $ */
/*-
@@ -65,12 +65,9 @@
#include "stand.h"
ssize_t
-write(fd, dest, bcount)
- int fd;
- void *dest;
- size_t bcount;
+write(int fd, void *dest, size_t bcount)
{
- register struct open_file *f = &files[fd];
+ struct open_file *f = &files[fd];
size_t resid;
if ((unsigned)fd >= SOPEN_MAX || !(f->f_flags & F_WRITE)) {