From owner-svn-src-head@freebsd.org Wed Feb 21 15:57:25 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 818FFF0FFCD; Wed, 21 Feb 2018 15:57:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0E71682F53; Wed, 21 Feb 2018 15:57:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 04BD31A992; Wed, 21 Feb 2018 15:57:25 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1LFvOiU043304; Wed, 21 Feb 2018 15:57:24 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1LFvOhQ043300; Wed, 21 Feb 2018 15:57:24 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201802211557.w1LFvOhQ043300@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Wed, 21 Feb 2018 15:57:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329724 - head/libexec/getty X-SVN-Group: head X-SVN-Commit-Author: trasz X-SVN-Commit-Paths: head/libexec/getty X-SVN-Commit-Revision: 329724 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Feb 2018 15:57:25 -0000 Author: trasz Date: Wed Feb 21 15:57:24 2018 New Revision: 329724 URL: https://svnweb.freebsd.org/changeset/base/329724 Log: Build getty(8) with WARNS=6. Reviewed by: imp@ MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D14197 Modified: head/libexec/getty/Makefile head/libexec/getty/chat.c head/libexec/getty/main.c head/libexec/getty/subr.c Modified: head/libexec/getty/Makefile ============================================================================== --- head/libexec/getty/Makefile Wed Feb 21 15:54:23 2018 (r329723) +++ head/libexec/getty/Makefile Wed Feb 21 15:57:24 2018 (r329724) @@ -6,7 +6,7 @@ SRCS= main.c init.c subr.c chat.c LIBADD= util MAN= gettytab.5 ttys.5 getty.8 -WARNS?= 1 +WARNS?= 6 WFORMAT=0 .include Modified: head/libexec/getty/chat.c ============================================================================== --- head/libexec/getty/chat.c Wed Feb 21 15:54:23 2018 (r329723) +++ head/libexec/getty/chat.c Wed Feb 21 15:57:24 2018 (r329724) @@ -62,7 +62,7 @@ static int chat_unalarm(void); static int getdigit(unsigned char **, int, int); static char **read_chat(char **); static char *cleanchr(char **, unsigned char); -static char *cleanstr(const unsigned char *, int); +static const char *cleanstr(const unsigned char *, int); static const char *result(int); static int chat_expect(const char *); static int chat_send(char const *); @@ -270,7 +270,7 @@ cleanchr(char **buf, unsigned char ch) * clean a string for display (ctrl/meta characters) */ -static char * +static const char * cleanstr(const unsigned char *s, int l) { static unsigned char * tmp = NULL; @@ -281,7 +281,7 @@ cleanstr(const unsigned char *s, int l) if (tmp == NULL) { tmplen = 0; - return (char *)"(mem alloc error)"; + return "(mem alloc error)"; } else { int i = 0; char * p = tmp; Modified: head/libexec/getty/main.c ============================================================================== --- head/libexec/getty/main.c Wed Feb 21 15:54:23 2018 (r329723) +++ head/libexec/getty/main.c Wed Feb 21 15:57:24 2018 (r329724) @@ -252,14 +252,15 @@ main(int argc, char *argv[]) } if (AC) { - int i, rfds; + fd_set rfds; struct timeval to; + int i; - rfds = 1 << 0; /* FD_SET */ + FD_ZERO(&rfds); + FD_SET(0, &rfds); to.tv_sec = RT; to.tv_usec = 0; - i = select(32, (fd_set*)&rfds, (fd_set*)NULL, - (fd_set*)NULL, RT ? &to : NULL); + i = select(32, &rfds, NULL, NULL, RT ? &to : NULL); if (i < 0) { syslog(LOG_ERR, "select %s: %m", ttyn); } else if (i == 0) { @@ -708,7 +709,7 @@ prompt(void) static char * get_line(int fd) { - int i = 0; + size_t i = 0; static char linebuf[512]; /* Modified: head/libexec/getty/subr.c ============================================================================== --- head/libexec/getty/subr.c Wed Feb 21 15:54:23 2018 (r329723) +++ head/libexec/getty/subr.c Wed Feb 21 15:57:24 2018 (r329724) @@ -68,12 +68,13 @@ gettable(const char *name, char *buf) long n; int l; char *p; - char *msg = NULL; - const char *dba[2]; + static char path_gettytab[PATH_MAX]; + char *dba[2]; static int firsttime = 1; - dba[0] = _PATH_GETTYTAB; + strlcpy(path_gettytab, _PATH_GETTYTAB, sizeof(path_gettytab)); + dba[0] = path_gettytab; dba[1] = NULL; if (firsttime) { @@ -101,27 +102,23 @@ gettable(const char *name, char *buf) firsttime = 0; } - switch (cgetent(&buf, (char **)dba, name)) { + switch (cgetent(&buf, dba, name)) { case 1: - msg = "%s: couldn't resolve 'tc=' in gettytab '%s'"; + syslog(LOG_ERR, "getty: couldn't resolve 'tc=' in gettytab '%s'", name); + return; case 0: break; case -1: - msg = "%s: unknown gettytab entry '%s'"; - break; + syslog(LOG_ERR, "getty: unknown gettytab entry '%s'", name); + return; case -2: - msg = "%s: retrieving gettytab entry '%s': %m"; - break; + syslog(LOG_ERR, "getty: retrieving gettytab entry '%s': %m", name); + return; case -3: - msg = "%s: recursive 'tc=' reference gettytab entry '%s'"; - break; + syslog(LOG_ERR, "getty: recursive 'tc=' reference gettytab entry '%s'", name); + return; default: - msg = "%s: unexpected cgetent() error for entry '%s'"; - break; - } - - if (msg != NULL) { - syslog(LOG_ERR, msg, "getty", name); + syslog(LOG_ERR, "getty: unexpected cgetent() error for entry '%s'", name); return; }