Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern ttycheckoutq(9): wait is always 0. Assert it; prun...



details:   https://anonhg.NetBSD.org/src/rev/63cf3cabbcc6
branches:  trunk
changeset: 373563:63cf3cabbcc6
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Fri Feb 17 23:13:01 2023 +0000

description:
ttycheckoutq(9): wait is always 0.  Assert it; prune dead branches.

There appear to have been no callers with wait=1 since NetBSD 1.0
from a cursory search.  Let's nix the parameter altogether on the
next kernel revbump.  This logic is probably broken anyway in the
presence of ttycancel, which is necessary for, e.g., yanking USB
serial adapters.

diffstat:

 sys/kern/tty.c |  16 +++++++---------
 1 files changed, 7 insertions(+), 9 deletions(-)

diffs (43 lines):

diff -r 60a87a9da5af -r 63cf3cabbcc6 sys/kern/tty.c
--- a/sys/kern/tty.c    Fri Feb 17 21:50:13 2023 +0000
+++ b/sys/kern/tty.c    Fri Feb 17 23:13:01 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tty.c,v 1.307 2022/10/26 23:41:49 riastradh Exp $      */
+/*     $NetBSD: tty.c,v 1.308 2023/02/17 23:13:01 riastradh Exp $      */
 
 /*-
  * Copyright (c) 2008, 2020 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.307 2022/10/26 23:41:49 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty.c,v 1.308 2023/02/17 23:13:01 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_compat_netbsd.h"
@@ -2195,19 +2195,17 @@
 static int
 ttycheckoutq_wlock(struct tty *tp, int wait)
 {
-       int     hiwat, error;
+       int     hiwat;
 
        KASSERT(mutex_owned(&tty_lock));
 
+       KASSERT(wait == 0);
+
        hiwat = tp->t_hiwat;
        if (tp->t_outq.c_cc > hiwat + 200)
-               while (tp->t_outq.c_cc > hiwat) {
+               if (tp->t_outq.c_cc > hiwat) {
                        ttstart(tp);
-                       if (wait == 0)
-                               return (0);
-                       error = ttysleep(tp, &tp->t_outcv, true, hz);
-                       if (error == EINTR)
-                               wait = 0;
+                       return (0);
                }
 
        return (1);



Home | Main Index | Thread Index | Old Index