From b8496badeab51219f7bc06b297a4449e5c0e5269 Mon Sep 17 00:00:00 2001 From: reyk <> Date: Sat, 19 Dec 2015 13:58:08 +0000 Subject: [PATCH] Move log_sockaddr() to from log.c to util.c as it is a local addition and actually not a "logging" function. No functional change. --- src/usr.sbin/ntpd/log.c | 18 ++++-------------- src/usr.sbin/ntpd/log.h | 3 +-- src/usr.sbin/ntpd/ntpd.h | 3 ++- src/usr.sbin/ntpd/util.c | 14 +++++++++++++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/usr.sbin/ntpd/log.c b/src/usr.sbin/ntpd/log.c index 1ce9a227..9108f25d 100644 --- a/src/usr.sbin/ntpd/log.c +++ b/src/usr.sbin/ntpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.11 2015/01/08 05:34:21 bcook Exp $ */ +/* $OpenBSD: log.c,v 1.12 2015/12/19 13:58:08 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -16,10 +16,12 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include +#include +#include #include #include -#include #include #include #include @@ -198,15 +200,3 @@ fatalx(const char *emsg, ...) va_end(ap); exit(1); } - -const char * -log_sockaddr(struct sockaddr *sa) -{ - static char buf[NI_MAXHOST]; - - if (getnameinfo(sa, SA_LEN(sa), buf, sizeof(buf), NULL, 0, - NI_NUMERICHOST)) - return ("(unknown)"); - else - return (buf); -} diff --git a/src/usr.sbin/ntpd/log.h b/src/usr.sbin/ntpd/log.h index a5854622..2e735b41 100644 --- a/src/usr.sbin/ntpd/log.h +++ b/src/usr.sbin/ntpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.1 2015/01/08 00:30:08 bcook Exp $ */ +/* $OpenBSD: log.h,v 1.2 2015/12/19 13:58:08 reyk Exp $ */ /* * Copyright (c) 2010 Gilles Chehade @@ -32,4 +32,3 @@ __dead void fatal(const char *, ...) __attribute__((format (printf, 1, 2))); __dead void fatalx(const char *, ...) __attribute__((format (printf, 1, 2))); -const char * log_sockaddr(struct sockaddr *sa); diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index 052907a4..af2ad9e4 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ntpd.h,v 1.125 2015/11/24 01:03:25 deraadt Exp $ */ +/* $OpenBSD: ntpd.h,v 1.126 2015/12/19 13:58:08 reyk Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -373,6 +373,7 @@ struct l_fixedpt d_to_lfp(double); double sfp_to_d(struct s_fixedpt); struct s_fixedpt d_to_sfp(double); char *print_rtable(int); +const char *log_sockaddr(struct sockaddr *); /* sensors.c */ void sensor_init(void); diff --git a/src/usr.sbin/ntpd/util.c b/src/usr.sbin/ntpd/util.c index 60ea5ac1..9f86f1df 100644 --- a/src/usr.sbin/ntpd/util.c +++ b/src/usr.sbin/ntpd/util.c @@ -1,4 +1,4 @@ -/* $OpenBSD: util.c,v 1.19 2015/03/28 03:49:01 bcook Exp $ */ +/* $OpenBSD: util.c,v 1.20 2015/12/19 13:58:08 reyk Exp $ */ /* * Copyright (c) 2004 Alexander Guy @@ -139,3 +139,15 @@ print_rtable(int r) return (b); } + +const char * +log_sockaddr(struct sockaddr *sa) +{ + static char buf[NI_MAXHOST]; + + if (getnameinfo(sa, SA_LEN(sa), buf, sizeof(buf), NULL, 0, + NI_NUMERICHOST)) + return ("(unknown)"); + else + return (buf); +}