Browse Source

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.
OPENBSD_5_9
reyk 9 years ago
parent
commit
b8496badea
4 changed files with 20 additions and 18 deletions
  1. +4
    -14
      src/usr.sbin/ntpd/log.c
  2. +1
    -2
      src/usr.sbin/ntpd/log.h
  3. +2
    -1
      src/usr.sbin/ntpd/ntpd.h
  4. +13
    -1
      src/usr.sbin/ntpd/util.c

+ 4
- 14
src/usr.sbin/ntpd/log.c View File

@ -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 <henning@openbsd.org>
@ -16,10 +16,12 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <sys/queue.h>
#include <sys/tree.h>
#include <sys/socket.h>
#include <errno.h>
#include <netdb.h>
#include <pwd.h>
#include <stdarg.h>
#include <stdio.h>
@ -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);
}

+ 1
- 2
src/usr.sbin/ntpd/log.h View File

@ -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 <gilles@poolp.org>
@ -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);

+ 2
- 1
src/usr.sbin/ntpd/ntpd.h View File

@ -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 <henning@openbsd.org>
@ -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);


+ 13
- 1
src/usr.sbin/ntpd/util.c View File

@ -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 <alexander.guy@andern.org>
@ -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);
}

Loading…
Cancel
Save