mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-11 09:50:12 +00:00
Avoid 64-bit divisions and modulos. Fixed related overflows for weird
args. This driver should not be used, since it calls uiomove() with interrupts disabled.
This commit is contained in:
parent
597035b4db
commit
26d7294956
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=36966
@ -8,7 +8,7 @@
|
||||
* of this software, nor does the author assume any responsibility
|
||||
* for damages incurred with its use.
|
||||
*
|
||||
* $Id: ctx.c,v 1.26 1998/01/24 02:54:17 eivind Exp $
|
||||
* $Id: ctx.c,v 1.27 1998/06/07 17:10:15 dfr Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -281,8 +281,13 @@ ctxwrite(dev_t dev, struct uio * uio, int ioflag)
|
||||
unit = UNIT(minor(dev));
|
||||
sr = &(ctx_sr[unit]);
|
||||
|
||||
page = uio->uio_offset / PAGESIZE;
|
||||
offset = uio->uio_offset % PAGESIZE;
|
||||
if (uio->uio_offset < 0)
|
||||
return (EINVAL);
|
||||
if (uio->uio_offset >= 4 * PAGESIZE)
|
||||
page = 4; /* EOF */
|
||||
else
|
||||
page = (u_int)uio->uio_offset / PAGESIZE;
|
||||
offset = (u_int)uio->uio_offset % PAGESIZE;
|
||||
count = min(uio->uio_resid, PAGESIZE - offset);
|
||||
while ((page >= 0) && (page <= 3) && (count > 0)) {
|
||||
sr->cp0 &= ~3;
|
||||
@ -306,8 +311,8 @@ ctxwrite(dev_t dev, struct uio * uio, int ioflag)
|
||||
outb(sr->iobase + ctx_cp1, sr->cp1);
|
||||
enable_intr();
|
||||
|
||||
page = uio->uio_offset / PAGESIZE;
|
||||
offset = uio->uio_offset % PAGESIZE;
|
||||
page = (u_int)uio->uio_offset / PAGESIZE;
|
||||
offset = (u_int)uio->uio_offset % PAGESIZE;
|
||||
count = min(uio->uio_resid, PAGESIZE - offset);
|
||||
}
|
||||
if (uio->uio_resid > 0)
|
||||
@ -326,8 +331,13 @@ ctxread(dev_t dev, struct uio * uio, int ioflag)
|
||||
unit = UNIT(minor(dev));
|
||||
sr = &(ctx_sr[unit]);
|
||||
|
||||
page = uio->uio_offset / PAGESIZE;
|
||||
offset = uio->uio_offset % PAGESIZE;
|
||||
if (uio->uio_offset < 0)
|
||||
return (EINVAL);
|
||||
if (uio->uio_offset >= 4 * PAGESIZE)
|
||||
page = 4; /* EOF */
|
||||
else
|
||||
page = (u_int)uio->uio_offset / PAGESIZE;
|
||||
offset = (u_int)uio->uio_offset % PAGESIZE;
|
||||
count = min(uio->uio_resid, PAGESIZE - offset);
|
||||
while ((page >= 0) && (page <= 3) && (count > 0)) {
|
||||
sr->cp0 &= ~3;
|
||||
@ -349,8 +359,8 @@ ctxread(dev_t dev, struct uio * uio, int ioflag)
|
||||
outb(sr->iobase + ctx_cp1, sr->cp1);
|
||||
enable_intr();
|
||||
|
||||
page = uio->uio_offset / PAGESIZE;
|
||||
offset = uio->uio_offset % PAGESIZE;
|
||||
page = (u_int)uio->uio_offset / PAGESIZE;
|
||||
offset = (u_int)uio->uio_offset % PAGESIZE;
|
||||
count = min(uio->uio_resid, PAGESIZE - offset);
|
||||
}
|
||||
if (uio->uio_resid > 0)
|
||||
|
Loading…
Reference in New Issue
Block a user