diff options
author | dd <dd@FreeBSD.org> | 2001-06-03 05:17:39 +0000 |
---|---|---|
committer | dd <dd@FreeBSD.org> | 2001-06-03 05:17:39 +0000 |
commit | eaa7d6fe18902356cefd477140607552e8a1e5a7 (patch) | |
tree | 5cef740085c0b053b51f2b13e549c4aa1735107f /sys/dev/snp | |
parent | e9e92e57f1837e7d5219b2b4c7000bf903f6a000 (diff) | |
download | FreeBSD-src-eaa7d6fe18902356cefd477140607552e8a1e5a7.zip FreeBSD-src-eaa7d6fe18902356cefd477140607552e8a1e5a7.tar.gz |
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
Diffstat (limited to 'sys/dev/snp')
-rw-r--r-- | sys/dev/snp/snp.c | 34 |
1 files changed, 8 insertions, 26 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c index 8019418..3882b67 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; |