Module Name: src Committed By: mbalmer Date: Sun Oct 20 20:17:52 UTC 2013
Modified Files: src/sbin/slattach: slattach.c Log Message: attach tty line discipline by name, not by number. remove unused case value. lgtm christos To generate a diff of this commit: cvs rdiff -u -r1.32 -r1.33 src/sbin/slattach/slattach.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/slattach/slattach.c diff -u src/sbin/slattach/slattach.c:1.32 src/sbin/slattach/slattach.c:1.33 --- src/sbin/slattach/slattach.c:1.32 Fri Dec 30 03:19:36 2011 +++ src/sbin/slattach/slattach.c Sun Oct 20 20:17:52 2013 @@ -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 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 19 #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 @@ __RCSID("$NetBSD: slattach.c,v 1.32 2011 #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 @@ main(int argc, char *argv[]) case 's': speed = atoi(optarg); break; - case 'r': case 't': - slipdisc = ttydisc(optarg); + case 't': + ldisc = optarg; break; case '?': default: @@ -138,8 +137,8 @@ main(int argc, char *argv[]) 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 @@ main(int argc, char *argv[]) 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) {