Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/faithd KNF, pass lint.
details: https://anonhg.NetBSD.org/src/rev/7cad190d5ab2
branches: trunk
changeset: 759054:7cad190d5ab2
user: christos <christos%NetBSD.org@localhost>
date: Fri Nov 26 18:58:43 2010 +0000
description:
KNF, pass lint.
diffstat:
usr.sbin/faithd/Makefile | 4 +-
usr.sbin/faithd/faithd.c | 235 ++++++++++++++++----------------
usr.sbin/faithd/faithd.h | 14 +-
usr.sbin/faithd/ftp.c | 340 +++++++++++++++++-----------------------------
usr.sbin/faithd/prefix.c | 22 +-
usr.sbin/faithd/tcp.c | 46 +++--
6 files changed, 282 insertions(+), 379 deletions(-)
diffs (truncated from 1610 to 300 lines):
diff -r c6e0bfe7ff77 -r 7cad190d5ab2 usr.sbin/faithd/Makefile
--- a/usr.sbin/faithd/Makefile Fri Nov 26 18:51:19 2010 +0000
+++ b/usr.sbin/faithd/Makefile Fri Nov 26 18:58:43 2010 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.4 2007/05/28 12:06:34 tls Exp $
+# $NetBSD: Makefile,v 1.5 2010/11/26 18:58:43 christos Exp $
USE_FORT?= yes # network server
@@ -6,6 +6,6 @@
SRCS= faithd.c tcp.c ftp.c prefix.c
MAN= faithd.8
-#CFLAGS+= -DFAITH4
+#CPPFLAGS+= -DFAITH4
.include <bsd.prog.mk>
diff -r c6e0bfe7ff77 -r 7cad190d5ab2 usr.sbin/faithd/faithd.c
--- a/usr.sbin/faithd/faithd.c Fri Nov 26 18:51:19 2010 +0000
+++ b/usr.sbin/faithd/faithd.c Fri Nov 26 18:58:43 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: faithd.c,v 1.32 2007/12/15 16:32:07 perry Exp $ */
+/* $NetBSD: faithd.c,v 1.33 2010/11/26 18:58:43 christos Exp $ */
/* $KAME: faithd.c,v 1.62 2003/08/19 21:20:33 itojun Exp $ */
/*
@@ -77,7 +77,6 @@
char *serverpath = NULL;
char *serverarg[MAXARGV + 1];
-static char *faithdname = NULL;
char logname[BUFSIZ];
char procname[BUFSIZ];
struct myaddrs {
@@ -94,22 +93,21 @@
static int inetd = 0;
static char *configfile = NULL;
-int main __P((int, char **));
-static int inetd_main __P((int, char **));
-static int daemon_main __P((int, char **));
-static void play_service __P((int));
-static void play_child __P((int, struct sockaddr *));
-static int faith_prefix __P((struct sockaddr *));
-static int map6to4 __P((struct sockaddr_in6 *, struct sockaddr_in *));
-static void sig_child __P((int));
-static void sig_terminate __P((int));
-static void start_daemon __P((void));
-static void exit_stderr __P((const char *, ...))
+static int inetd_main(int, char **);
+static int daemon_main(int, char **);
+static void play_service(int);
+static void play_child(int, struct sockaddr *);
+static int faith_prefix(struct sockaddr *);
+static int map6to4(struct sockaddr_in6 *, struct sockaddr_in *);
+static void sig_child(int);
+static void sig_terminate(int);
+static void start_daemon(void);
+static void exit_stderr(const char *, ...)
__attribute__((__format__(__printf__, 1, 2)));
-static void grab_myaddrs __P((void));
-static void free_myaddrs __P((void));
-static void update_myaddrs __P((void));
-static void usage __P((void));
+static void grab_myaddrs(void);
+static void free_myaddrs(void);
+static void update_myaddrs(void);
+static void usage(void) __attribute__((__noreturn__));
int
main(int argc, char **argv)
@@ -119,13 +117,9 @@
* Initializing stuff
*/
- faithdname = strrchr(argv[0], '/');
- if (faithdname)
- faithdname++;
- else
- faithdname = argv[0];
+ setprogname(argv[0]);
- if (strcmp(faithdname, "faithd") != 0) {
+ if (strcmp(getprogname(), "faithd") != 0) {
inetd = 1;
return inetd_main(argc, argv);
} else
@@ -150,9 +144,10 @@
}
if (strrchr(argv[0], '/') == NULL)
- snprintf(path, sizeof(path), "%s/%s", DEFAULT_DIR, argv[0]);
+ (void)snprintf(path, sizeof(path), "%s/%s", DEFAULT_DIR,
+ argv[0]);
else
- snprintf(path, sizeof(path), "%s", argv[0]);
+ (void)snprintf(path, sizeof(path), "%s", argv[0]);
#ifdef USE_ROUTE
grab_myaddrs();
@@ -165,26 +160,26 @@
#endif
melen = sizeof(me);
- if (getsockname(STDIN_FILENO, (struct sockaddr *)&me, &melen) < 0) {
+ if (getsockname(STDIN_FILENO, (void *)&me, &melen) == -1) {
exit_failure("getsockname: %s", strerror(errno));
/*NOTREACHED*/
}
fromlen = sizeof(from);
- if (getpeername(STDIN_FILENO, (struct sockaddr *)&from, &fromlen) < 0) {
+ if (getpeername(STDIN_FILENO, (void *)&from, &fromlen) == -1) {
exit_failure("getpeername: %s", strerror(errno));
/*NOTREACHED*/
}
- if (getnameinfo((struct sockaddr *)&me, melen, NULL, 0,
- sbuf, sizeof(sbuf), NI_NUMERICHOST) == 0)
+ if (getnameinfo((void *)&me, melen, NULL, 0,
+ sbuf, (socklen_t)sizeof(sbuf), NI_NUMERICHOST) == 0)
service = sbuf;
else
service = DEFAULT_PORT_NAME;
- if (getnameinfo((struct sockaddr *)&me, melen, NULL, 0,
- snum, sizeof(snum), NI_NUMERICHOST) != 0)
- snprintf(snum, sizeof(snum), "?");
+ if (getnameinfo((void *)&me, melen, NULL, 0,
+ snum, (socklen_t)sizeof(snum), NI_NUMERICHOST) != 0)
+ (void)snprintf(snum, sizeof(snum), "?");
- snprintf(logname, sizeof(logname), "faithd %s", snum);
- snprintf(procname, sizeof(procname), "accepting port %s", snum);
+ (void)snprintf(logname, sizeof(logname), "faithd %s", snum);
+ (void)snprintf(procname, sizeof(procname), "accepting port %s", snum);
openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
if (argc >= MAXARGV) {
@@ -197,13 +192,13 @@
serverarg[i] = NULL;
error = setsockopt(STDIN_FILENO, SOL_SOCKET, SO_OOBINLINE, &on,
- sizeof(on));
+ (socklen_t)sizeof(on));
if (error < 0) {
exit_failure("setsockopt(SO_OOBINLINE): %s", strerror(errno));
/*NOTREACHED*/
}
- play_child(STDIN_FILENO, (struct sockaddr *)&from);
+ play_child(STDIN_FILENO, (void *)&from);
exit_failure("should not reach here");
return 0; /*dummy!*/
}
@@ -263,7 +258,7 @@
exit_stderr("not enough core");
}
serverarg[i] = NULL;
- /* fall throuth */
+ /*FALLTHROUGH*/
case 1: /* no local service */
service = argv[NUMPRT];
break;
@@ -290,23 +285,27 @@
#ifdef IPV6_FAITH
if (res->ai_family == AF_INET6) {
- error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_FAITH, &on, sizeof(on));
+ error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_FAITH, &on,
+ (socklen_t)sizeof(on));
if (error == -1)
exit_failure("setsockopt(IPV6_FAITH): %s",
strerror(errno));
}
#endif
- error = setsockopt(s_wld, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on));
+ error = setsockopt(s_wld, SOL_SOCKET, SO_REUSEADDR, &on,
+ (socklen_t)sizeof(on));
if (error == -1)
exit_failure("setsockopt(SO_REUSEADDR): %s", strerror(errno));
- error = setsockopt(s_wld, SOL_SOCKET, SO_OOBINLINE, &on, sizeof(on));
+ error = setsockopt(s_wld, SOL_SOCKET, SO_OOBINLINE, &on,
+ (socklen_t)sizeof(on));
if (error == -1)
exit_failure("setsockopt(SO_OOBINLINE): %s", strerror(errno));
#ifdef IPV6_V6ONLY
- error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on));
+ error = setsockopt(s_wld, IPPROTO_IPV6, IPV6_V6ONLY, &on,
+ (socklen_t)sizeof(on));
if (error == -1)
exit_failure("setsockopt(IPV6_V6ONLY): %s", strerror(errno));
#endif
@@ -331,14 +330,13 @@
* Everything is OK.
*/
- snprintf(logname, sizeof(logname), "faithd %s", service);
- snprintf(procname, sizeof(procname), "accepting port %s", service);
+ (void)snprintf(logname, sizeof(logname), "faithd %s", service);
+ (void)snprintf(procname, sizeof(procname), "accepting port %s", service);
openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
syslog(LOG_INFO, "Staring faith daemon for %s port", service);
play_service(s_wld);
- /* NOTREACHED */
- exit(1); /*pacify gcc*/
+ return 1;
}
static void
@@ -368,7 +366,7 @@
}
#endif
- error = poll(pfd, sizeof(pfd)/sizeof(pfd[0]), INFTIM);
+ error = poll(pfd, (unsigned int)(sizeof(pfd) / sizeof(pfd[0])), INFTIM);
if (error < 0) {
if (errno == EINTR)
goto again;
@@ -385,7 +383,7 @@
if (pfd[0].revents & POLLIN)
{
len = sizeof(srcaddr);
- s_src = accept(s_wld, (struct sockaddr *)&srcaddr, &len);
+ s_src = accept(s_wld, (void *)&srcaddr, &len);
if (s_src < 0) {
if (errno == ECONNABORTED)
goto again;
@@ -393,8 +391,8 @@
/*NOTREACHED*/
}
if (srcaddr.ss_family == AF_INET6 &&
- IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)&srcaddr)->sin6_addr)) {
- close(s_src);
+ IN6_IS_ADDR_V4MAPPED(&((struct sockaddr_in6 *)(void *)&srcaddr)->sin6_addr)) {
+ (void)close(s_src);
syslog(LOG_ERR, "connection from IPv4 mapped address?");
goto again;
}
@@ -403,15 +401,15 @@
if (child_pid == 0) {
/* child process */
- close(s_wld);
+ (void)close(s_wld);
closelog();
openlog(logname, LOG_PID | LOG_NOWAIT, LOG_DAEMON);
- play_child(s_src, (struct sockaddr *)&srcaddr);
+ play_child(s_src, (void *)&srcaddr);
exit_failure("should never reach here");
/*NOTREACHED*/
} else {
/* parent process */
- close(s_src);
+ (void)close(s_src);
if (child_pid == -1)
syslog(LOG_ERR, "can't fork");
}
@@ -436,38 +434,38 @@
tv.tv_sec = 1;
tv.tv_usec = 0;
- getnameinfo(srcaddr, srcaddr->sa_len,
- src, sizeof(src), NULL, 0, NI_NUMERICHOST);
+ (void)getnameinfo(srcaddr, (socklen_t)srcaddr->sa_len,
+ src, (socklen_t)sizeof(src), NULL, 0, NI_NUMERICHOST);
syslog(LOG_INFO, "accepted a client from %s", src);
- error = getsockname(s_src, (struct sockaddr *)&dstaddr6, &len);
+ error = getsockname(s_src, (void *)&dstaddr6, &len);
if (error == -1) {
exit_failure("getsockname: %s", strerror(errno));
/*NOTREACHED*/
}
- getnameinfo((struct sockaddr *)&dstaddr6, len,
- dst6, sizeof(dst6), NULL, 0, NI_NUMERICHOST);
+ (void)getnameinfo((void *)&dstaddr6, len,
+ dst6, (socklen_t)sizeof(dst6), NULL, 0, NI_NUMERICHOST);
syslog(LOG_INFO, "the client is connecting to %s", dst6);
- if (!faith_prefix((struct sockaddr *)&dstaddr6)) {
+ if (!faith_prefix((void *)&dstaddr6)) {
if (serverpath) {
/*
* Local service
*/
syslog(LOG_INFO, "executing local %s", serverpath);
if (!inetd) {
- dup2(s_src, 0);
- close(s_src);
- dup2(0, 1);
- dup2(0, 2);
+ (void)dup2(s_src, 0);
+ (void)close(s_src);
+ (void)dup2(0, 1);
+ (void)dup2(0, 2);
}
- execv(serverpath, serverarg);
Home |
Main Index |
Thread Index |
Old Index