use strchr/strrchr/memset/memmove instead of index/rindex/bzero/bcopy
This commit is contained in:
parent
14de140085
commit
dd30ff553b
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: bpf.c,v 1.8 1997/07/28 05:39:17 thorpej Exp $ */
|
||||
/* $NetBSD: bpf.c,v 1.9 1997/10/18 11:23:03 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1992 The University of Utah and the Center
|
||||
|
@ -51,7 +51,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)bpf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: bpf.c,v 1.8 1997/07/28 05:39:17 thorpej Exp $");
|
||||
__RCSID("$NetBSD: bpf.c,v 1.9 1997/10/18 11:23:03 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -151,7 +151,8 @@ BpfOpen()
|
|||
ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2;
|
||||
#endif
|
||||
ifr.ifr_addr.sa_family = AF_UNSPEC;
|
||||
bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN);
|
||||
memmove((char *)&ifr.ifr_addr.sa_data[0], &RmpMcastAddr[0],
|
||||
RMP_ADDRLEN);
|
||||
if (ioctl(BpfFd, BIOCPROMISC, (caddr_t)0) < 0) {
|
||||
syslog(LOG_ERR, "bpf: can't set promiscuous mode: %m");
|
||||
Exit(0);
|
||||
|
@ -313,7 +314,7 @@ BpfRead(rconn, doread)
|
|||
RMPCONN *rconn;
|
||||
int doread;
|
||||
{
|
||||
register int datlen, caplen, hdrlen;
|
||||
int datlen, caplen, hdrlen;
|
||||
static u_int8_t *bp = NULL, *ep = NULL;
|
||||
int cc;
|
||||
|
||||
|
@ -350,9 +351,10 @@ BpfRead(rconn, doread)
|
|||
caplen);
|
||||
else {
|
||||
rconn->rmplen = caplen;
|
||||
bcopy((char *)&bhp->bh_tstamp, (char *)&rconn->tstamp,
|
||||
sizeof(struct timeval));
|
||||
bcopy((char *)bp + hdrlen, (char *)&rconn->rmp, caplen);
|
||||
memmove((char *)&rconn->tstamp, (char *)&bhp->bh_tstamp,
|
||||
sizeof(struct timeval));
|
||||
memmove((char *)&rconn->rmp, (char *)bp + hdrlen,
|
||||
caplen);
|
||||
}
|
||||
bp += BPF_WORDALIGN(caplen + hdrlen);
|
||||
return(1);
|
||||
|
@ -415,7 +417,8 @@ BpfClose()
|
|||
ifr.ifr_addr.sa_len = RMP_ADDRLEN + 2;
|
||||
#endif
|
||||
ifr.ifr_addr.sa_family = AF_UNSPEC;
|
||||
bcopy(&RmpMcastAddr[0], (char *)&ifr.ifr_addr.sa_data[0], RMP_ADDRLEN);
|
||||
memmove((char *)&ifr.ifr_addr.sa_data[0], &RmpMcastAddr[0],
|
||||
RMP_ADDRLEN);
|
||||
if (ioctl(BpfFd, SIOCDELMULTI, (caddr_t)&ifr) < 0)
|
||||
(void) ioctl(BpfFd, BIOCPROMISC, (caddr_t)0);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: parseconf.c,v 1.5 1997/07/28 05:39:19 thorpej Exp $ */
|
||||
/* $NetBSD: parseconf.c,v 1.6 1997/10/18 11:23:07 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1992 The University of Utah and the Center
|
||||
|
@ -51,7 +51,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)parseconf.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: parseconf.c,v 1.5 1997/07/28 05:39:19 thorpej Exp $");
|
||||
__RCSID("$NetBSD: parseconf.c,v 1.6 1997/10/18 11:23:07 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -91,8 +91,8 @@ ParseConfig()
|
|||
CLIENT *client;
|
||||
u_int8_t *addr;
|
||||
char line[C_LINELEN];
|
||||
register char *cp, *bcp;
|
||||
register int i, j;
|
||||
char *cp, *bcp;
|
||||
int i, j;
|
||||
int omask, linecnt = 0;
|
||||
|
||||
if (BootAny) /* ignore config file */
|
||||
|
@ -134,7 +134,7 @@ ParseConfig()
|
|||
if (*line == '\0' || *line == '#') /* ignore comment */
|
||||
continue;
|
||||
|
||||
if ((cp = index(line,'#')) != NULL) /* trash comments */
|
||||
if ((cp = strchr(line,'#')) != NULL) /* trash comments */
|
||||
*cp = '\0';
|
||||
|
||||
cp = line; /* init `cp' */
|
||||
|
@ -254,11 +254,11 @@ ParseAddr(str)
|
|||
char *str;
|
||||
{
|
||||
static u_int8_t addr[RMP_ADDRLEN];
|
||||
register char *cp;
|
||||
register unsigned i;
|
||||
register int part, subpart;
|
||||
char *cp;
|
||||
unsigned i;
|
||||
int part, subpart;
|
||||
|
||||
bzero((char *)&addr[0], RMP_ADDRLEN); /* zero static buffer */
|
||||
memset((char *)&addr[0], 0, RMP_ADDRLEN); /* zero static buffer */
|
||||
|
||||
part = subpart = 0;
|
||||
for (cp = str; *cp; cp++) {
|
||||
|
@ -318,8 +318,8 @@ GetBootFiles()
|
|||
{
|
||||
DIR *dfd;
|
||||
struct stat statb;
|
||||
register struct dirent *dp;
|
||||
register int i;
|
||||
struct dirent *dp;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* Free the current list of boot files.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rbootd.c,v 1.7 1997/10/17 12:52:25 lukem Exp $ */
|
||||
/* $NetBSD: rbootd.c,v 1.8 1997/10/18 11:23:10 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1992 The University of Utah and the Center
|
||||
|
@ -57,7 +57,7 @@ __COPYRIGHT(
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rbootd.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rbootd.c,v 1.7 1997/10/17 12:52:25 lukem Exp $");
|
||||
__RCSID("$NetBSD: rbootd.c,v 1.8 1997/10/18 11:23:10 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -305,7 +305,7 @@ main(argc, argv)
|
|||
void
|
||||
DoTimeout()
|
||||
{
|
||||
register RMPCONN *rtmp;
|
||||
RMPCONN *rtmp;
|
||||
struct timeval now;
|
||||
|
||||
(void) gettimeofday(&now, (struct timezone *)0);
|
||||
|
@ -341,12 +341,12 @@ DoTimeout()
|
|||
|
||||
CLIENT *
|
||||
FindClient(rconn)
|
||||
register RMPCONN *rconn;
|
||||
RMPCONN *rconn;
|
||||
{
|
||||
register CLIENT *ctmp;
|
||||
CLIENT *ctmp;
|
||||
|
||||
for (ctmp = Clients; ctmp != NULL; ctmp = ctmp->next)
|
||||
if (bcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
|
||||
if (memcmp((char *)&rconn->rmp.hp_hdr.saddr[0],
|
||||
(char *)&ctmp->addr[0], RMP_ADDRLEN) == 0)
|
||||
break;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: rmpproto.c,v 1.9 1997/08/25 19:32:06 kleink Exp $ */
|
||||
/* $NetBSD: rmpproto.c,v 1.10 1997/10/18 11:23:16 lukem Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1988, 1992 The University of Utah and the Center
|
||||
|
@ -51,7 +51,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)rmpproto.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: rmpproto.c,v 1.9 1997/08/25 19:32:06 kleink Exp $");
|
||||
__RCSID("$NetBSD: rmpproto.c,v 1.10 1997/10/18 11:23:16 lukem Exp $");
|
||||
#endif
|
||||
#endif /* not lint */
|
||||
|
||||
|
@ -182,9 +182,9 @@ int
|
|||
SendServerID(rconn)
|
||||
RMPCONN *rconn;
|
||||
{
|
||||
register struct rmp_packet *rpl;
|
||||
register char *src, *dst;
|
||||
register u_int8_t *size;
|
||||
struct rmp_packet *rpl;
|
||||
char *src, *dst;
|
||||
u_int8_t *size;
|
||||
|
||||
rpl = &rconn->rmp; /* cache ptr to RMP packet */
|
||||
|
||||
|
@ -236,10 +236,10 @@ SendFileNo(req, rconn, filelist)
|
|||
RMPCONN *rconn;
|
||||
char *filelist[];
|
||||
{
|
||||
register struct rmp_packet *rpl;
|
||||
register char *src, *dst;
|
||||
register u_int8_t *size;
|
||||
register int i;
|
||||
struct rmp_packet *rpl;
|
||||
char *src, *dst;
|
||||
u_int8_t *size;
|
||||
int i;
|
||||
|
||||
GETWORD(req->r_brpl.rmp_seqno, i); /* SeqNo is really FileNo */
|
||||
rpl = &rconn->rmp; /* cache ptr to RMP packet */
|
||||
|
@ -302,9 +302,9 @@ SendBootRepl(req, rconn, filelist)
|
|||
int retval;
|
||||
char *filename, filepath[RMPBOOTDATA+1];
|
||||
RMPCONN *oldconn;
|
||||
register struct rmp_packet *rpl;
|
||||
register char *src, *dst1, *dst2;
|
||||
register u_int8_t i;
|
||||
struct rmp_packet *rpl;
|
||||
char *src, *dst1, *dst2;
|
||||
u_int8_t i;
|
||||
|
||||
/*
|
||||
* If another connection already exists, delete it since we
|
||||
|
@ -345,7 +345,7 @@ SendBootRepl(req, rconn, filelist)
|
|||
* stripped file name and spoof the client into thinking that it
|
||||
* really got what it wanted.
|
||||
*/
|
||||
filename = (filename = rindex(filepath,'/'))? ++filename: filepath;
|
||||
filename = (filename = strrchr(filepath,'/'))? ++filename: filepath;
|
||||
|
||||
/*
|
||||
* Check that this is a valid boot file name.
|
||||
|
@ -408,8 +408,8 @@ SendReadRepl(rconn)
|
|||
{
|
||||
int retval = 0;
|
||||
RMPCONN *oldconn;
|
||||
register struct rmp_packet *rpl, *req;
|
||||
register int size = 0;
|
||||
struct rmp_packet *rpl, *req;
|
||||
int size = 0;
|
||||
int madeconn = 0;
|
||||
|
||||
/*
|
||||
|
@ -570,14 +570,14 @@ BootDone(rconn)
|
|||
*/
|
||||
int
|
||||
SendPacket(rconn)
|
||||
register RMPCONN *rconn;
|
||||
RMPCONN *rconn;
|
||||
{
|
||||
/*
|
||||
* Set Ethernet Destination address to Source (BPF and the enet
|
||||
* driver will take care of getting our source address set).
|
||||
*/
|
||||
bcopy((char *)&rconn->rmp.hp_hdr.saddr[0],
|
||||
(char *)&rconn->rmp.hp_hdr.daddr[0], RMP_ADDRLEN);
|
||||
memmove((char *)&rconn->rmp.hp_hdr.daddr[0],
|
||||
(char *)&rconn->rmp.hp_hdr.saddr[0], RMP_ADDRLEN);
|
||||
#ifdef __FreeBSD__
|
||||
/* BPF (incorrectly) wants this in host order. */
|
||||
rconn->rmp.hp_hdr.len = rconn->rmplen - sizeof(struct hp_hdr);
|
||||
|
|
Loading…
Reference in New Issue