From 86c1eb6c1f6691386b81a09b5fec1cfe91ec5cd5 Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 4 Oct 2022 05:24:49 +0000 Subject: [PATCH 1/2] squash! constty(4): Make MP-safe. - Fix initialization of ok in cn_redirect. --- sys/dev/cons.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sys/dev/cons.c b/sys/dev/cons.c index f4f9a1602221..763c211538db 100644 --- a/sys/dev/cons.c +++ b/sys/dev/cons.c @@ -463,7 +463,7 @@ cn_redirect(dev_t *devp, int is_read, int *error, struct tty **ctpp) dev_t dev = *devp; struct tty *ctp; int s; - bool ok; + bool ok = false; *error = ENXIO; *ctpp = NULL; @@ -472,18 +472,16 @@ cn_redirect(dev_t *devp, int is_read, int *error, struct tty **ctpp) (cn_tab == NULL || (cn_tab->cn_pri != CN_REMOTE))) { if (is_read) { *error = 0; - ok = false; goto out; } tty_acquire(ctp); *ctpp = ctp; dev = ctp->t_dev; - } else if (cn_tab == NULL) { - ok = false; + } else if (cn_tab == NULL) goto out; - } else { + else dev = cn_tab->cn_dev; - } + ok = true; *devp = dev; out: pserialize_read_exit(s); return ok; From 0f058a0e89e3f545a9020a2fb79dadd7ad89029a Mon Sep 17 00:00:00 2001 From: Taylor R Campbell Date: Tue, 4 Oct 2022 05:48:39 +0000 Subject: [PATCH 2/2] squash! constty(4): Make MP-safe. - Fix reversed sense of conditional. --- sys/kern/subr_prf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index e87e6efc8501..53fb20c1d393 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -425,7 +425,7 @@ putone(int c, int flags, struct tty *tp) if ((flags & TOLOG) && c != '\0' && c != '\r' && c != 0177) logputchar(c); - if ((flags & TOCONS) && ctp != NULL && c != '\0') + if ((flags & TOCONS) && ctp == NULL && c != '\0') (*v_putc)(c); pserialize_read_exit(s);