aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/snp/snp.c
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-06-03 05:17:39 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-06-03 05:17:39 +0000
commit87826386e0046e51b3dcf42969394c3cea3e3194 (patch)
treeb5c4bbdede0c8e3cd8b2a347124b0b0b6b112e23 /sys/dev/snp/snp.c
parentb8edb44cc349331b8ac053aea7b35a5822294e5f (diff)
downloadsrc-87826386e0046e51b3dcf42969394c3cea3e3194.tar.gz
src-87826386e0046e51b3dcf42969394c3cea3e3194.zip
Remove unused includes, use *min() inline functions rather than a
home-grown macro, rewrite a confusing conditional in snpdevtotty(), and change ibuf to 512 bytes instead of 1024 bytes in dsnwrite(). Reviewed by: bde
Notes
Notes: svn path=/head/; revision=77648
Diffstat (limited to 'sys/dev/snp/snp.c')
-rw-r--r--sys/dev/snp/snp.c34
1 files changed, 8 insertions, 26 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index 8019418d4808..3882b67d02cc 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -18,9 +18,6 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/filio.h>
-#if defined(COMPAT_43) || defined(COMPAT_SUNOS)
-#include <sys/ioctl_compat.h>
-#endif
#include <sys/malloc.h>
#include <sys/tty.h>
#include <sys/conf.h>
@@ -28,7 +25,6 @@
#include <sys/kernel.h>
#include <sys/snoop.h>
#include <sys/vnode.h>
-#include <sys/conf.h>
static d_open_t snpopen;
static d_close_t snpclose;
@@ -55,10 +51,6 @@ static struct cdevsw snp_cdevsw = {
};
-#ifndef MIN
-#define MIN(a,b) (((a)<(b))?(a):(b))
-#endif
-
static MALLOC_DEFINE(M_SNP, "snp", "Snoop device data");
#define ttytosnp(t) (struct snoop *)(t)->t_sc
@@ -76,13 +68,13 @@ dsnwrite(struct tty *tp, struct uio *uio, int flag)
{
struct snoop *snp = ttytosnp(tp);
int error = 0;
- char ibuf[1024];
+ char ibuf[512];
int ilen;
struct iovec iov;
struct uio uio2;
- while (uio->uio_resid) {
- ilen = MIN(sizeof(ibuf), uio->uio_resid);
+ while (uio->uio_resid > 0) {
+ ilen = imin(sizeof(ibuf), uio->uio_resid);
error = uiomove(ibuf, ilen, uio);
if (error)
break;
@@ -125,9 +117,9 @@ snpdevtotty (dev)
struct cdevsw *cdp;
cdp = devsw(dev);
- if (cdp && cdp->d_flags & D_TTY)
- return (dev->si_tty);
- return (NULL);
+ if (cdp == NULL || (cdp->d_flags & D_TTY) == 0)
+ return (NULL);
+ return (dev->si_tty);
}
#define SNP_INPUT_BUF 5 /* This is even too much, the maximal
@@ -163,7 +155,7 @@ tty_input:
return (EIO);
while (uio->uio_resid > 0) {
- len = MIN(uio->uio_resid, SNP_INPUT_BUF);
+ len = imin(uio->uio_resid, SNP_INPUT_BUF);
if ((error = uiomove(c, len, uio)) != 0)
return (error);
for (i=0; i < len; i++) {
@@ -207,7 +199,7 @@ snpread(dev, uio, flag)
n = snp->snp_len;
while (snp->snp_len > 0 && uio->uio_resid > 0 && error == 0) {
- len = MIN(uio->uio_resid, snp->snp_len);
+ len = min((unsigned)uio->uio_resid, snp->snp_len);
from = (caddr_t)(snp->snp_buf + snp->snp_base);
if (len == 0)
break;
@@ -238,16 +230,6 @@ snpread(dev, uio, flag)
}
int
-snpinc(struct snoop *snp, char c)
-{
- char buf;
-
- buf = c;
- return (snpin(snp, &buf, 1));
-}
-
-
-int
snpin(snp, buf, n)
struct snoop *snp;
char *buf;