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
This commit is contained in:
Edward Tomasz Napierala 2018-02-21 15:57:24 +00:00
parent a9cf54b0c9
commit 18587b84c5
4 changed files with 24 additions and 26 deletions

View File

@ -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>

View File

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

View File

@ -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];
/*

View File

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