Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Feb 2018 15:57:24 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329724 - head/libexec/getty
Message-ID:  <201802211557.w1LFvOhQ043300@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <bsd.prog.mk>

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;
 	}
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802211557.w1LFvOhQ043300>