From owner-p4-projects@FreeBSD.ORG Thu Aug 21 21:40:12 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 14C671065673; Thu, 21 Aug 2008 21:40:12 +0000 (UTC) Delivered-To: perforce@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CBE2A1065684 for ; Thu, 21 Aug 2008 21:40:11 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id B7E688FC1C for ; Thu, 21 Aug 2008 21:40:11 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.2/8.14.2) with ESMTP id m7LLeBoZ024379 for ; Thu, 21 Aug 2008 21:40:11 GMT (envelope-from ed@FreeBSD.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.2/8.14.1/Submit) id m7LLeBjN024377 for perforce@freebsd.org; Thu, 21 Aug 2008 21:40:11 GMT (envelope-from ed@FreeBSD.org) Date: Thu, 21 Aug 2008 21:40:11 GMT Message-Id: <200808212140.m7LLeBjN024377@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to ed@FreeBSD.org using -f From: Ed Schouten To: Perforce Change Reviews Cc: Subject: PERFORCE change 148055 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Aug 2008 21:40:12 -0000 http://perforce.freebsd.org/chv.cgi?CH=148055 Change 148055 by ed@ed_flippo on 2008/08/21 21:40:09 Even though I hate preprocessor-abuse, I think it's a lot easier if we create a fancy macro to test if a hook is currently in place. Affected files ... .. //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#14 edit .. //depot/projects/mpsafetty/sys/sys/ttyhook.h#4 edit Differences ... ==== //depot/projects/mpsafetty/sys/kern/tty_ttydisc.c#14 (text+ko) ==== @@ -1085,7 +1085,7 @@ len = ttyoutq_read(&tp->t_outq, buf, len); /* Invoke TTY hooks. XXX: ttyhook_getc_capture()? */ - if (tp->t_hook != NULL && tp->t_hook->th_getc_capture != NULL) + if (ttyhook_hashook(tp, getc_capture)) tp->t_hook->th_getc_capture(tp, buf, len); ttydisc_wakeup_watermark(tp); @@ -1112,7 +1112,7 @@ * copying to userspace. We just simulate it by copying data to * a shadow buffer. */ - if (tp->t_hook != NULL && tp->t_hook->th_getc_capture != NULL) { + if (ttyhook_hashook(tp, getc_capture)) { while (uio->uio_resid > 0) { /* Read to shadow buffer. */ len = ttyoutq_read(&tp->t_outq, buf, @@ -1121,8 +1121,7 @@ break; /* Process with hook. Handle sudden removal. */ - if (tp->t_hook != NULL && - tp->t_hook->th_getc_capture != NULL) + if (ttyhook_hashook(tp, getc_capture)) tp->t_hook->th_getc_capture(tp, buf, len); /* Copy to userspace. */ ==== //depot/projects/mpsafetty/sys/sys/ttyhook.h#4 (text+ko) ==== @@ -48,6 +48,8 @@ int ttyhook_register(struct tty **, struct thread *, int, struct ttyhook *, void *); void ttyhook_unregister(struct tty *); -#define ttyhook_softc(tp) ((tp)->t_hooksoftc) +#define ttyhook_softc(tp) ((tp)->t_hooksoftc) +#define ttyhook_hashook(tp,hook) ((tp)->t_hook != NULL && \ + (tp)->t_hook->th_ ## hook != NULL) #endif /* !_SYS_TTYHOOK_H_ */