Date: Thu, 21 Aug 2008 21:40:11 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 148055 for review Message-ID: <200808212140.m7LLeBjN024377@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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_ */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200808212140.m7LLeBjN024377>