Browse Source

Stop accessing verbose and debug variables from log.c directly.

This replaces log_verbose() and "extern int verbose" with the two functions
log_setverbose() and log_getverbose().
Pointed out by benno@
OK krw@ eric@ gilles@ (OK gilles@ for the snmpd bits as well)
OPENBSD_6_1
reyk 7 years ago
parent
commit
99d11625c1
3 changed files with 19 additions and 11 deletions
  1. +12
    -5
      src/usr.sbin/ntpd/log.c
  2. +4
    -4
      src/usr.sbin/ntpd/ntpd.c
  3. +3
    -2
      src/usr.sbin/ntpd/ntpd.h

+ 12
- 5
src/usr.sbin/ntpd/log.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.15 2017/01/08 20:31:03 reyk Exp $ */
/* $OpenBSD: log.c,v 1.16 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -24,13 +24,14 @@
#include <errno.h>
#include <time.h>
int debug;
int verbose;
static int debug;
static int verbose;
const char *log_procname;
void log_init(int, int);
void log_procinit(const char *);
void log_verbose(int);
void log_setverbose(int);
int log_getverbose(void);
void log_warn(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void log_warnx(const char *, ...)
@ -71,11 +72,17 @@ log_procinit(const char *procname)
}
void
log_verbose(int v)
log_setverbose(int v)
{
verbose = v;
}
int
log_getverbose(void)
{
return (verbose);
}
void
logit(int pri, const char *fmt, ...)
{


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.c,v 1.112 2016/12/01 16:24:48 mestre Exp $ */
/* $OpenBSD: ntpd.c,v 1.113 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -209,7 +209,7 @@ main(int argc, char *argv[])
reset_adjtime();
if (!lconf.settime) {
log_init(lconf.debug, LOG_DAEMON);
log_verbose(lconf.verbose);
log_setverbose(lconf.verbose);
if (!lconf.debug)
if (daemon(1, 0))
fatal("daemon");
@ -284,7 +284,7 @@ main(int argc, char *argv[])
lconf.settime = 0;
timeout = INFTIM;
log_init(lconf.debug, LOG_DAEMON);
log_verbose(lconf.verbose);
log_setverbose(lconf.verbose);
log_warnx("no reply received in time, skipping initial "
"time setting");
if (!lconf.debug)
@ -384,7 +384,7 @@ dispatch_imsg(struct ntpd_conf *lconf, int argc, char **argv)
if (!lconf->settime)
break;
log_init(lconf->debug, LOG_DAEMON);
log_verbose(lconf->verbose);
log_setverbose(lconf->verbose);
memcpy(&d, imsg.data, sizeof(d));
ntpd_settime(d);
/* daemonize now */


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.133 2016/09/26 17:17:01 rzalamena Exp $ */
/* $OpenBSD: ntpd.h,v 1.134 2017/01/09 14:49:22 reyk Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -408,7 +408,8 @@ void build_show_sensor(struct ctl_show_sensor *,
/* log.c */
void log_init(int, int);
void log_procinit(const char *);
void log_verbose(int);
void log_setverbose(int);
int log_getverbose(void);
void log_warn(const char *, ...)
__attribute__((__format__ (printf, 1, 2)));
void log_warnx(const char *, ...)


Loading…
Cancel
Save