summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/dev/usb/ugen.c5
-rw-r--r--sys/dev/usb/uhid.c8
-rw-r--r--sys/kern/tty.c23
-rw-r--r--sys/kern/tty_subr.c26
-rw-r--r--sys/net/if_sl.c8
-rw-r--r--sys/net/if_strip.c8
-rw-r--r--sys/sys/tty.h4
7 files changed, 33 insertions, 49 deletions
diff --git a/sys/dev/usb/ugen.c b/sys/dev/usb/ugen.c
index 09bda694e12..ce917b43ba5 100644
--- a/sys/dev/usb/ugen.c
+++ b/sys/dev/usb/ugen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ugen.c,v 1.57 2009/06/05 20:18:03 yuo Exp $ */
+/* $OpenBSD: ugen.c,v 1.58 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: ugen.c,v 1.63 2002/11/26 18:49:48 christos Exp $ */
/* $FreeBSD: src/sys/dev/usb/ugen.c,v 1.26 1999/11/17 22:33:41 n_hibma Exp $ */
@@ -323,8 +323,7 @@ ugenopen(dev_t dev, int flag, int mode, struct proc *p)
sce->ibuf = malloc(isize, M_USBDEV, M_WAITOK);
DPRINTFN(5, ("ugenopen: intr endpt=%d,isize=%d\n",
endpt, isize));
- if (clalloc(&sce->q, UGEN_IBSIZE, 0) == -1)
- return (ENOMEM);
+ clalloc(&sce->q, UGEN_IBSIZE, 0);
err = usbd_open_pipe_intr(sce->iface,
edesc->bEndpointAddress,
USBD_SHORT_XFER_OK, &sce->pipeh, sce,
diff --git a/sys/dev/usb/uhid.c b/sys/dev/usb/uhid.c
index 1ca438f34a6..57716e16a6f 100644
--- a/sys/dev/usb/uhid.c
+++ b/sys/dev/usb/uhid.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uhid.c,v 1.42 2008/06/26 05:42:18 ray Exp $ */
+/* $OpenBSD: uhid.c,v 1.43 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: uhid.c,v 1.57 2003/03/11 16:44:00 augustss Exp $ */
/*
@@ -261,10 +261,8 @@ uhidopen(dev_t dev, int flag, int mode, struct proc *p)
if (error)
return (error);
- if (clalloc(&sc->sc_q, UHID_BSIZE, 0) == -1) {
- uhidev_close(&sc->sc_hdev);
- return (ENOMEM);
- }
+ clalloc(&sc->sc_q, UHID_BSIZE, 0);
+
sc->sc_obuf = malloc(sc->sc_osize, M_USBDEV, M_WAITOK);
sc->sc_state &= ~UHID_IMMED;
sc->sc_async = NULL;
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index c31ce53cb65..378a801f594 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.c,v 1.79 2008/12/24 11:20:31 kettenis Exp $ */
+/* $OpenBSD: tty.c,v 1.80 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: tty.c,v 1.68.4.2 1996/06/06 16:04:52 thorpej Exp $ */
/*-
@@ -75,7 +75,7 @@ int filt_ttyread(struct knote *kn, long hint);
void filt_ttyrdetach(struct knote *kn);
int filt_ttywrite(struct knote *kn, long hint);
void filt_ttywdetach(struct knote *kn);
-int ttystats_init(void);
+void ttystats_init(struct itty **);
/* Symbolic sleep message strings. */
char ttclos[] = "ttycls";
@@ -2284,17 +2284,15 @@ ttyfree(struct tty *tp)
free(tp, M_TTYS);
}
-struct itty *ttystats;
-
-int
-ttystats_init(void)
+void
+ttystats_init(struct itty **ttystats)
{
struct itty *itp;
struct tty *tp;
- ttystats = malloc(tty_count * sizeof(struct itty),
+ *ttystats = malloc(tty_count * sizeof(struct itty),
M_SYSCTL, M_WAITOK);
- for (tp = TAILQ_FIRST(&ttylist), itp = ttystats; tp;
+ for (tp = TAILQ_FIRST(&ttylist), itp = *ttystats; tp;
tp = TAILQ_NEXT(tp, tty_link), itp++) {
itp->t_dev = tp->t_dev;
itp->t_rawq_c_cc = tp->t_rawq.c_cc;
@@ -2311,7 +2309,6 @@ ttystats_init(void)
itp->t_pgrp_pg_id = 0;
itp->t_line = tp->t_line;
}
- return (0);
}
/*
@@ -2336,13 +2333,15 @@ sysctl_tty(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp,
case KERN_TTY_TKCANCC:
return (sysctl_rdquad(oldp, oldlenp, newp, tk_cancc));
case KERN_TTY_INFO:
- err = ttystats_init();
- if (err)
- return (err);
+ {
+ struct itty *ttystats;
+
+ ttystats_init(&ttystats);
err = sysctl_rdstruct(oldp, oldlenp, newp, ttystats,
tty_count * sizeof(struct itty));
free(ttystats, M_SYSCTL);
return (err);
+ }
default:
#if NPTY > 0
return (sysctl_pty(name, namelen, oldp, oldlenp, newp, newlen));
diff --git a/sys/kern/tty_subr.c b/sys/kern/tty_subr.c
index 216c65528a6..e14e5bef642 100644
--- a/sys/kern/tty_subr.c
+++ b/sys/kern/tty_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty_subr.c,v 1.20 2008/03/31 22:40:34 deraadt Exp $ */
+/* $OpenBSD: tty_subr.c,v 1.21 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: tty_subr.c,v 1.13 1996/02/09 19:00:43 christos Exp $ */
/*
@@ -60,7 +60,7 @@ cinit(void)
* Initialize a particular clist. Ok, they are really ring buffers,
* of the specified length, with/without quoting support.
*/
-int
+void
clalloc(struct clist *clp, int size, int quot)
{
@@ -69,13 +69,12 @@ clalloc(struct clist *clp, int size, int quot)
if (quot)
clp->c_cq = malloc(QMEM(size), M_TTYS, M_WAITOK|M_ZERO);
else
- clp->c_cq = (u_char *)0;
+ clp->c_cq = NULL;
- clp->c_cf = clp->c_cl = (u_char *)0;
+ clp->c_cf = clp->c_cl = NULL;
clp->c_ce = clp->c_cs + size;
clp->c_cn = size;
clp->c_cc = 0;
- return (0);
}
void
@@ -89,7 +88,7 @@ clfree(struct clist *clp)
bzero(clp->c_cq, QMEM(clp->c_cn));
free(clp->c_cq, M_TTYS);
}
- clp->c_cs = clp->c_cq = (u_char *)0;
+ clp->c_cs = clp->c_cq = NULL;
}
@@ -245,19 +244,17 @@ putc(int c, struct clist *clp)
int s;
s = spltty();
- if (clp->c_cc == clp->c_cn)
- goto out;
+ if (clp->c_cc == clp->c_cn) {
+ splx(s);
+ return -1;
+ }
if (clp->c_cc == 0) {
if (!clp->c_cs) {
#if defined(DIAGNOSTIC) || 1
printf("putc: required clalloc\n");
#endif
- if (clalloc(clp, 1024, 1)) {
-out:
- splx(s);
- return -1;
- }
+ clalloc(clp, 1024, 1);
}
clp->c_cf = clp->c_cl = clp->c_cs;
}
@@ -338,8 +335,7 @@ b_to_q(u_char *cp, int count, struct clist *clp)
#if defined(DIAGNOSTIC) || 1
printf("b_to_q: required clalloc\n");
#endif
- if (clalloc(clp, 1024, 1))
- goto out;
+ clalloc(clp, 1024, 1);
}
clp->c_cf = clp->c_cl = clp->c_cs;
}
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 200e0c210ae..3d45a60b39d 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_sl.c,v 1.37 2009/07/08 15:01:50 claudio Exp $ */
+/* $OpenBSD: if_sl.c,v 1.38 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: if_sl.c,v 1.39.4.1 1996/06/02 16:26:31 thorpej Exp $ */
/*
@@ -325,11 +325,7 @@ slopen(dev, tp)
sc->sc_oldbufquot = tp->t_outq.c_cq != 0;
clfree(&tp->t_outq);
- error = clalloc(&tp->t_outq, 3*SLMTU, 0);
- if (error) {
- splx(s);
- return (error);
- }
+ clalloc(&tp->t_outq, 3*SLMTU, 0);
} else
sc->sc_oldbufsize = sc->sc_oldbufquot = 0;
splx(s);
diff --git a/sys/net/if_strip.c b/sys/net/if_strip.c
index f6febb012b3..5f612f0cccc 100644
--- a/sys/net/if_strip.c
+++ b/sys/net/if_strip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_strip.c,v 1.35 2008/10/22 23:04:45 mpf Exp $ */
+/* $OpenBSD: if_strip.c,v 1.36 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: if_strip.c,v 1.2.4.3 1996/08/03 00:58:32 jtc Exp $ */
/* from: NetBSD: if_sl.c,v 1.38 1996/02/13 22:00:23 christos Exp $ */
@@ -473,11 +473,7 @@ stripopen(dev, tp)
sc->sc_oldbufquot = tp->t_outq.c_cq != 0;
clfree(&tp->t_outq);
- error = clalloc(&tp->t_outq, 3*SLMTU, 0);
- if (error) {
- splx(s);
- return (error);
- }
+ clalloc(&tp->t_outq, 3*SLMTU, 0);
} else
sc->sc_oldbufsize = sc->sc_oldbufquot = 0;
splx(s);
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 806586a1868..704c2e7ec56 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: tty.h,v 1.22 2006/08/17 06:27:05 miod Exp $ */
+/* $OpenBSD: tty.h,v 1.23 2009/07/19 08:16:06 blambert Exp $ */
/* $NetBSD: tty.h,v 1.30.4.1 1996/06/02 09:08:13 mrg Exp $ */
/*-
@@ -305,7 +305,7 @@ int cttywrite(dev_t, struct uio *, int);
int cttyioctl(dev_t, u_long, caddr_t, int, struct proc *);
int cttypoll(dev_t, int, struct proc *);
-int clalloc(struct clist *, int, int);
+void clalloc(struct clist *, int, int);
void clfree(struct clist *);
#if defined(COMPAT_43) || defined(COMPAT_SUNOS) || defined(COMPAT_SVR4) || \