Source-Changes-HG archive

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

[src/trunk]: src/sbin/slattach attach tty line discipline by name, not by num...



details:   https://anonhg.NetBSD.org/src/rev/b63722a2084d
branches:  trunk
changeset: 790777:b63722a2084d
user:      mbalmer <mbalmer%NetBSD.org@localhost>
date:      Sun Oct 20 20:17:52 2013 +0000

description:
attach tty line discipline by name, not by number.  remove unused case value.  lgtm christos

diffstat:

 sbin/slattach/slattach.c |  30 +++++++-----------------------
 1 files changed, 7 insertions(+), 23 deletions(-)

diffs (75 lines):

diff -r 0bd8ea292c19 -r b63722a2084d sbin/slattach/slattach.c
--- a/sbin/slattach/slattach.c  Sun Oct 20 19:47:28 2013 +0000
+++ b/sbin/slattach/slattach.c  Sun Oct 20 20:17:52 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: slattach.c,v 1.32 2011/12/30 03:19:36 christos Exp $   */
+/*     $NetBSD: slattach.c,v 1.33 2013/10/20 20:17:52 mbalmer Exp $    */
 
 /*
  * Copyright (c) 1988, 1993
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)slattach.c 8.2 (Berkeley) 1/7/94";
 #else
-__RCSID("$NetBSD: slattach.c,v 1.32 2011/12/30 03:19:36 christos Exp $");
+__RCSID("$NetBSD: slattach.c,v 1.33 2013/10/20 20:17:52 mbalmer Exp $");
 #endif
 #endif /* not lint */
 
@@ -67,11 +67,10 @@
 #include <unistd.h>
 
 static int     speed = 9600;
-static int     slipdisc = SLIPDISC;
+static const char      *ldisc = "slip";
 
 static char    devicename[32];
 
-static int     ttydisc(char *);
 __dead static void     usage(void);
 
 int
@@ -105,8 +104,8 @@
                case 's':
                        speed = atoi(optarg);
                        break;
-               case 'r': case 't':
-                       slipdisc = ttydisc(optarg);
+               case 't':
+                       ldisc = optarg;
                        break;
                case '?':
                default:
@@ -138,8 +137,8 @@
                err(1, "tcsetattr");
        if (ioctl(fd, TIOCSDTR, 0) < 0 && errno != ENOTTY)
                err(1, "TIOCSDTR");
-       if (ioctl(fd, TIOCSETD, &slipdisc) < 0)
-               err(1, "TIOCSETD");
+       if (ioctl(fd, TIOCSLINED, ldisc) < 0)
+               err(1, "TIOCSLINED");
        if (opt_detach && daemon(0, 0) != 0)
                err(1, "couldn't detach");
        sigemptyset(&nsigset);
@@ -147,21 +146,6 @@
                sigsuspend(&nsigset);
 }
 
-static int
-ttydisc(char *name)
-{
-       if (strcmp(name, "slip") == 0)
-               return(SLIPDISC);
-#ifdef STRIPDISC
-       else if (strcmp(name, "strip") == 0)
-               return(STRIPDISC);
-#endif
-       else
-               usage();
-       /* NOTREACHED */
-       return -1;
-}
-
 static void
 usage(void)
 {



Home | Main Index | Thread Index | Old Index