Browse Source

Convert the logic in yyerror(). Instead of creating a temporary

format string, create a temporary message.
OK claudio@
OPENBSD_5_7
bluhm 10 years ago
parent
commit
0f1121e6f9
3 changed files with 9 additions and 10 deletions
  1. +1
    -3
      src/usr.sbin/ntpd/log.c
  2. +2
    -1
      src/usr.sbin/ntpd/ntpd.h
  3. +6
    -6
      src/usr.sbin/ntpd/parse.y

+ 1
- 3
src/usr.sbin/ntpd/log.c View File

@ -1,4 +1,4 @@
/* $OpenBSD: log.c,v 1.8 2007/08/22 21:04:30 ckuethe Exp $ */
/* $OpenBSD: log.c,v 1.9 2014/11/03 20:15:30 bluhm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -29,8 +29,6 @@
int debug;
extern int debugsyslog;
void logit(int, const char *, ...);
void
log_init(int n_debug)
{


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

@ -1,4 +1,4 @@
/* $OpenBSD: ntpd.h,v 1.110 2014/10/25 03:23:49 lteo Exp $ */
/* $OpenBSD: ntpd.h,v 1.111 2014/11/03 20:15:30 bluhm Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -271,6 +271,7 @@ enum ctl_actions {
/* prototypes */
/* log.c */
void log_init(int);
void logit(int, const char *, ...);
void vlog(int, const char *, va_list);
void log_warn(const char *, ...);
void log_warnx(const char *, ...);


+ 6
- 6
src/usr.sbin/ntpd/parse.y View File

@ -1,4 +1,4 @@
/* $OpenBSD: parse.y,v 1.52 2013/11/25 12:58:42 benno Exp $ */
/* $OpenBSD: parse.y,v 1.53 2014/11/03 20:15:31 bluhm Exp $ */
/*
* Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org>
@ -339,15 +339,15 @@ int
yyerror(const char *fmt, ...)
{
va_list ap;
char *nfmt;
char *msg;
file->errors++;
va_start(ap, fmt);
if (asprintf(&nfmt, "%s:%d: %s", file->name, yylval.lineno, fmt) == -1)
fatalx("yyerror asprintf");
vlog(LOG_CRIT, nfmt, ap);
if (vasprintf(&msg, fmt, ap) == -1)
fatalx("yyerror vasprintf");
va_end(ap);
free(nfmt);
logit(LOG_CRIT, "%s:%d: %s", file->name, yylval.lineno, msg);
free(msg);
return (0);
}


Loading…
Cancel
Save