From d280fc84e3f11915535ced37f5f16f84d0af016d Mon Sep 17 00:00:00 2001 From: blambert Date: Sun, 19 Jul 2009 08:16:06 +0000 Subject: clalloc() can't fail, so there's no need to handle failure cases. Change to void function. Also, no need to have global tty stats pointer, so just return it from clalloc, as the caller frees it immediately anyway. ok miod@ --- sys/kern/tty.c | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'sys/kern/tty.c') 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)); -- cgit v1.2.3-59-g8ed1b