summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sys/arch/aviion/dev/nvram.c24
-rw-r--r--sys/arch/aviion/dev/vme.c8
-rw-r--r--sys/arch/luna88k/dev/lcd.c13
3 files changed, 26 insertions, 19 deletions
diff --git a/sys/arch/aviion/dev/nvram.c b/sys/arch/aviion/dev/nvram.c
index d98c6806f8c..ffc7b946426 100644
--- a/sys/arch/aviion/dev/nvram.c
+++ b/sys/arch/aviion/dev/nvram.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: nvram.c,v 1.10 2015/02/10 21:56:09 miod Exp $ */
+/* $OpenBSD: nvram.c,v 1.11 2015/02/10 22:42:35 miod Exp $ */
/*
* Copyright (c) 1995 Theo de Raadt
@@ -68,7 +68,7 @@ struct cfdriver nvram_cd = {
};
time_t chiptotime(int, int, int, int, int, int);
-int nvramrw(caddr_t, int, struct uio *, int);
+int nvramrw(caddr_t, size_t, struct uio *, int);
int
nvrammatch(parent, vcf, args)
@@ -116,7 +116,7 @@ nvramattach(parent, self, args)
sc->sc_ioh = ioh;
- printf(": MK48T0%ld\n", sc->sc_len / 1024);
+ printf(": MK48T0%zu\n", sc->sc_len / 1024);
}
#define LEAPYEAR(y) (((y) & 3) == 0)
@@ -448,13 +448,16 @@ read_nvram(struct nvramsoftc *sc)
/*ARGSUSED*/
int
-nvramrw(caddr_t base, int len, struct uio *uio, int flags)
+nvramrw(caddr_t base, size_t len, struct uio *uio, int flags)
{
vaddr_t v;
- int c;
+ size_t c;
struct iovec *iov;
int error = 0;
+ if (uio->uio_offset < 0)
+ return EINVAL;
+
while (uio->uio_resid > 0 && error == 0) {
iov = uio->uio_iov;
if (iov->iov_len == 0) {
@@ -468,12 +471,15 @@ nvramrw(caddr_t base, int len, struct uio *uio, int flags)
}
v = uio->uio_offset;
- c = min(iov->iov_len, MAXPHYS);
- if (v + c > len)
- c = len - v; /* till end of dev */
+ if (v <= len) {
+ c = ulmin(iov->iov_len, MAXPHYS);
+ if (c > len - v)
+ c = len - v; /* till end of dev */
+ } else
+ c = 0;
if (c == 0)
return (0);
- error = uiomovei(base + v, c, uio);
+ error = uiomove(base + v, c, uio);
}
return (error);
}
diff --git a/sys/arch/aviion/dev/vme.c b/sys/arch/aviion/dev/vme.c
index 2f9b0f1f6b9..229849f86be 100644
--- a/sys/arch/aviion/dev/vme.c
+++ b/sys/arch/aviion/dev/vme.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vme.c,v 1.17 2015/02/10 21:56:09 miod Exp $ */
+/* $OpenBSD: vme.c,v 1.18 2015/02/10 22:42:35 miod Exp $ */
/*
* Copyright (c) 2006, 2007, 2010 Miodrag Vallat.
*
@@ -944,8 +944,8 @@ vmerw(struct vme_softc *sc, int awidth, int dwidth, struct uio *uio, int flags)
}
delta = uio->uio_offset & PAGE_MASK;
- len = min(uio->uio_resid, PAGE_SIZE - delta);
- /* len = min(len, (off_t)r->vr_end - uio->uio_offset); */
+ len = ulmin(uio->uio_resid, PAGE_SIZE - delta);
+ /* len = ulmin(len, (off_t)r->vr_end - uio->uio_offset); */
rc = vme_map_r(r, trunc_page(uio->uio_offset), PAGE_SIZE, 0,
uio->uio_rw == UIO_READ ? PROT_READ : PROT_READ | PROT_WRITE,
@@ -954,7 +954,7 @@ vmerw(struct vme_softc *sc, int awidth, int dwidth, struct uio *uio, int flags)
break;
/* XXX wrap this because of dwidth */
- rc = uiomovei((caddr_t)vmepg + delta, len, uio);
+ rc = uiomove((caddr_t)vmepg + delta, len, uio);
/* inline vme_unmap */
pmap_kremove(vmepg, PAGE_SIZE);
diff --git a/sys/arch/luna88k/dev/lcd.c b/sys/arch/luna88k/dev/lcd.c
index 3fd535a7a44..bec431b990d 100644
--- a/sys/arch/luna88k/dev/lcd.c
+++ b/sys/arch/luna88k/dev/lcd.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lcd.c,v 1.6 2015/02/10 21:56:09 miod Exp $ */
+/* $OpenBSD: lcd.c,v 1.7 2015/02/10 22:42:35 miod Exp $ */
/* $NetBSD: lcd.c,v 1.2 2000/01/07 05:13:08 nisimura Exp $ */
/*-
@@ -162,23 +162,24 @@ lcdclose(dev_t dev, int flags, int fmt, struct proc *p)
int
lcdwrite(dev_t dev, struct uio *uio, int flag)
{
- int error, len;
- int i, n;
+ int error;
+ size_t len;
+ size_t i, n;
char buf[LCD_MAXBUFLEN];
len = n = uio->uio_resid;
- if ((len < 0) || (len > LCD_MAXBUFLEN))
+ if (len > LCD_MAXBUFLEN)
return EIO;
while (n > 0) {
- error = uiomovei(buf, n, uio);
+ error = uiomove(buf, n, uio);
if (error)
return EIO;
n = uio->uio_resid;
}
- for(i = 0; i < len; i++) {
+ for (i = 0; i < len; i++) {
lcdput((int)buf[i]);
}