Fix void * arithmetic.
This commit is contained in:
parent
ddb8209b40
commit
ae67dbc85d
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: copyinstr.c,v 1.1 1996/09/30 16:34:42 ws Exp $ */
|
||||
/* $NetBSD: copyinstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995 Wolfgang Solfrank.
|
||||
@ -32,23 +32,25 @@
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* Emulate copyinstr.
|
||||
*/
|
||||
int
|
||||
copyinstr(udaddr, kaddr, len, done)
|
||||
void *udaddr;
|
||||
const void *udaddr;
|
||||
void *kaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
int c;
|
||||
const u_char *up = udaddr;
|
||||
u_char *kp = kaddr;
|
||||
int l;
|
||||
|
||||
for (l = 0; len-- > 0; l++) {
|
||||
if ((c = fubyte(udaddr++)) < 0) {
|
||||
if ((c = fubyte(up++)) < 0) {
|
||||
*done = l;
|
||||
return EACCES;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: copyoutstr.c,v 1.1 1996/09/30 16:34:42 ws Exp $ */
|
||||
/* $NetBSD: copyoutstr.c,v 1.2 1999/01/10 10:24:16 tsubai Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (C) 1995 Wolfgang Solfrank.
|
||||
@ -32,22 +32,24 @@
|
||||
*/
|
||||
#include <sys/param.h>
|
||||
#include <sys/errno.h>
|
||||
#include <sys/systm.h>
|
||||
|
||||
/*
|
||||
* Emulate copyoutstr.
|
||||
*/
|
||||
int
|
||||
copyoutstr(kaddr, udaddr, len, done)
|
||||
void *kaddr;
|
||||
const void *kaddr;
|
||||
void *udaddr;
|
||||
size_t len;
|
||||
size_t *done;
|
||||
{
|
||||
u_char *kp = kaddr;
|
||||
const u_char *kp = kaddr;
|
||||
u_char *up = udaddr;
|
||||
int l;
|
||||
|
||||
for (l = 0; len-- > 0; l++) {
|
||||
if (subyte(udaddr++, *kp) < 0) {
|
||||
if (subyte(up++, *kp) < 0) {
|
||||
*done = l;
|
||||
return EACCES;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: openfirm.c,v 1.3 1998/11/15 19:53:25 tsubai Exp $ */
|
||||
/* $NetBSD: openfirm.c,v 1.4 1999/01/10 10:24:16 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -450,17 +450,18 @@ OF_read(handle, addr, len)
|
||||
1,
|
||||
};
|
||||
int l, act = 0;
|
||||
char *p = addr;
|
||||
|
||||
ofw_stack();
|
||||
args.ihandle = handle;
|
||||
args.addr = OF_buf;
|
||||
for (; len > 0; len -= l, addr += l) {
|
||||
for (; len > 0; len -= l, p += l) {
|
||||
l = min(NBPG, len);
|
||||
args.len = l;
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
if (args.actual > 0) {
|
||||
ofbcopy(OF_buf, addr, args.actual);
|
||||
ofbcopy(OF_buf, p, args.actual);
|
||||
act += args.actual;
|
||||
}
|
||||
if (args.actual < l)
|
||||
@ -492,13 +493,14 @@ OF_write(handle, addr, len)
|
||||
1,
|
||||
};
|
||||
int l, act = 0;
|
||||
char *p = addr;
|
||||
|
||||
ofw_stack();
|
||||
args.ihandle = handle;
|
||||
args.addr = OF_buf;
|
||||
for (; len > 0; len -= l, addr += l) {
|
||||
for (; len > 0; len -= l, p += l) {
|
||||
l = min(NBPG, len);
|
||||
ofbcopy(addr, OF_buf, l);
|
||||
ofbcopy(p, OF_buf, l);
|
||||
args.len = l;
|
||||
if (openfirmware(&args) == -1)
|
||||
return -1;
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: pmap.c,v 1.10 1998/10/13 11:30:47 tsubai Exp $ */
|
||||
/* $NetBSD: pmap.c,v 1.11 1999/01/10 10:24:17 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -395,7 +395,7 @@ pmap_bootstrap(kernelstart, kernelend)
|
||||
if (s < mp1->start)
|
||||
break;
|
||||
if (mp1 < mp) {
|
||||
bcopy(mp1, mp1 + 1, (void *)mp - (void *)mp1);
|
||||
bcopy(mp1, mp1 + 1, (char *)mp - (char *)mp1);
|
||||
mp1->start = s;
|
||||
mp1->size = sz;
|
||||
} else {
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: trap.c,v 1.14 1998/11/26 21:06:21 thorpej Exp $ */
|
||||
/* $NetBSD: trap.c,v 1.15 1999/01/10 10:24:17 tsubai Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (C) 1995, 1996 Wolfgang Solfrank.
|
||||
@ -396,21 +396,23 @@ copyin(udaddr, kaddr, len)
|
||||
void *kaddr;
|
||||
size_t len;
|
||||
{
|
||||
void *p;
|
||||
const char *up = udaddr;
|
||||
char *kp = kaddr;
|
||||
char *p;
|
||||
size_t l;
|
||||
faultbuf env;
|
||||
|
||||
if (setfault(env))
|
||||
return EFAULT;
|
||||
while (len > 0) {
|
||||
p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK);
|
||||
l = (USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK);
|
||||
l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
if (l > len)
|
||||
l = len;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(u_int)udaddr >> ADDR_SR_SHFT]);
|
||||
bcopy(p, kaddr, l);
|
||||
udaddr += l;
|
||||
kaddr += l;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]);
|
||||
bcopy(p, kp, l);
|
||||
up += l;
|
||||
kp += l;
|
||||
len -= l;
|
||||
}
|
||||
curpcb->pcb_onfault = 0;
|
||||
@ -423,21 +425,23 @@ copyout(kaddr, udaddr, len)
|
||||
void *udaddr;
|
||||
size_t len;
|
||||
{
|
||||
void *p;
|
||||
const char *kp = kaddr;
|
||||
char *up = udaddr;
|
||||
char *p;
|
||||
size_t l;
|
||||
faultbuf env;
|
||||
|
||||
if (setfault(env))
|
||||
return EFAULT;
|
||||
while (len > 0) {
|
||||
p = USER_ADDR + ((u_int)udaddr & ~SEGMENT_MASK);
|
||||
l = (USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
p = (char *)USER_ADDR + ((u_int)up & ~SEGMENT_MASK);
|
||||
l = ((char *)USER_ADDR + SEGMENT_LENGTH) - p;
|
||||
if (l > len)
|
||||
l = len;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(u_int)udaddr >> ADDR_SR_SHFT]);
|
||||
bcopy(kaddr, p, l);
|
||||
udaddr += l;
|
||||
kaddr += l;
|
||||
setusr(curpcb->pcb_pm->pm_sr[(u_int)up >> ADDR_SR_SHFT]);
|
||||
bcopy(kp, p, l);
|
||||
up += l;
|
||||
kp += l;
|
||||
len -= l;
|
||||
}
|
||||
curpcb->pcb_onfault = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user