summaryrefslogtreecommitdiffstats
path: root/usr.sbin/syslogd
diff options
context:
space:
mode:
authorobrien <obrien@FreeBSD.org>2008-12-17 16:51:40 +0000
committerobrien <obrien@FreeBSD.org>2008-12-17 16:51:40 +0000
commit0ca2a78030c8d97f83c1266c27a283699e83e7a5 (patch)
tree0f7e8266ffebeb4b64a6cfacd4f09ae9f7fa90ec /usr.sbin/syslogd
parent4ad1824222695911748704cb2376acf956b727b3 (diff)
downloadFreeBSD-src-0ca2a78030c8d97f83c1266c27a283699e83e7a5.zip
FreeBSD-src-0ca2a78030c8d97f83c1266c27a283699e83e7a5.tar.gz
Rather than hardcode the 'struct iovec iov' array size, use a #define.
While I'm here bump WARNS to 3. Obtained from: Juniper Networks
Diffstat (limited to 'usr.sbin/syslogd')
-rw-r--r--usr.sbin/syslogd/Makefile2
-rw-r--r--usr.sbin/syslogd/syslogd.c22
2 files changed, 13 insertions, 11 deletions
diff --git a/usr.sbin/syslogd/Makefile b/usr.sbin/syslogd/Makefile
index 96d85c2..1682b49 100644
--- a/usr.sbin/syslogd/Makefile
+++ b/usr.sbin/syslogd/Makefile
@@ -12,7 +12,7 @@ SRCS= syslogd.c ttymsg.c
DPADD= ${LIBUTIL}
LDADD= -lutil
-WARNS?= 1
+WARNS?= 3
.if ${MK_INET6_SUPPORT} != "no"
CFLAGS+= -DINET6
diff --git a/usr.sbin/syslogd/syslogd.c b/usr.sbin/syslogd/syslogd.c
index a6940ac..d9aee33 100644
--- a/usr.sbin/syslogd/syslogd.c
+++ b/usr.sbin/syslogd/syslogd.c
@@ -331,7 +331,7 @@ static void reapchild(int);
static void usage(void);
static int validate(struct sockaddr *, const char *);
static void unmapped(struct sockaddr *);
-static void wallmsg(struct filed *, struct iovec *);
+static void wallmsg(struct filed *, struct iovec *, const int iovlen);
static int waitdaemon(int, int, int);
static void timedout(int);
static void double_rbuf(int);
@@ -1065,10 +1065,11 @@ dofsync(void)
}
}
+#define IOV_SIZE 7
static void
fprintlog(struct filed *f, int flags, const char *msg)
{
- struct iovec iov[7];
+ struct iovec iov[IOV_SIZE];
struct iovec *v;
struct addrinfo *r;
int i, l, lsent = 0;
@@ -1253,7 +1254,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
dprintf(" %s\n", f->f_un.f_fname);
v->iov_base = lf;
v->iov_len = 1;
- if (writev(f->f_file, iov, 7) < 0) {
+ if (writev(f->f_file, iov, IOV_SIZE) < 0) {
/*
* If writev(2) fails for potentially transient errors
* like the filesystem being full, ignore it.
@@ -1284,7 +1285,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
break;
}
}
- if (writev(f->f_file, iov, 7) < 0) {
+ if (writev(f->f_file, iov, IOV_SIZE) < 0) {
int e = errno;
(void)close(f->f_file);
if (f->f_un.f_pipe.f_pid > 0)
@@ -1309,7 +1310,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
v->iov_len = 2;
errno = 0; /* ttymsg() only sometimes returns an errno */
- if ((msgret = ttymsg(iov, 7, f->f_un.f_fname, 10))) {
+ if ((msgret = ttymsg(iov, IOV_SIZE, f->f_un.f_fname, 10))) {
f->f_type = F_UNUSED;
logerror(msgret);
}
@@ -1320,7 +1321,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
dprintf("\n");
v->iov_base = crlf;
v->iov_len = 2;
- wallmsg(f, iov);
+ wallmsg(f, iov, IOV_SIZE);
break;
}
f->f_prevcount = 0;
@@ -1334,7 +1335,7 @@ fprintlog(struct filed *f, int flags, const char *msg)
* world, or a list of approved users.
*/
static void
-wallmsg(struct filed *f, struct iovec *iov)
+wallmsg(struct filed *f, struct iovec *iov, const int iovlen)
{
static int reenter; /* avoid calling ourselves */
FILE *uf;
@@ -1358,7 +1359,8 @@ wallmsg(struct filed *f, struct iovec *iov)
strncpy(line, ut.ut_line, sizeof(line) - 1);
line[sizeof(line) - 1] = '\0';
if (f->f_type == F_WALL) {
- if ((p = ttymsg(iov, 7, line, TTYMSGTIME)) != NULL) {
+ if ((p = ttymsg(iov, iovlen, line, TTYMSGTIME)) !=
+ NULL) {
errno = 0; /* already in msg */
logerror(p);
}
@@ -1370,8 +1372,8 @@ wallmsg(struct filed *f, struct iovec *iov)
break;
if (!strncmp(f->f_un.f_uname[i], ut.ut_name,
UT_NAMESIZE)) {
- if ((p = ttymsg(iov, 7, line, TTYMSGTIME))
- != NULL) {
+ if ((p = ttymsg(iov, IOV_SIZE, line,
+ TTYMSGTIME)) != NULL) {
errno = 0; /* already in msg */
logerror(p);
}
OpenPOWER on IntegriCloud