From 0f1121e6f91869a68daed0639afc9ae4b1306859 Mon Sep 17 00:00:00 2001 From: bluhm <> Date: Mon, 3 Nov 2014 20:15:31 +0000 Subject: [PATCH] Convert the logic in yyerror(). Instead of creating a temporary format string, create a temporary message. OK claudio@ --- src/usr.sbin/ntpd/log.c | 4 +--- src/usr.sbin/ntpd/ntpd.h | 3 ++- src/usr.sbin/ntpd/parse.y | 12 ++++++------ 3 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/usr.sbin/ntpd/log.c b/src/usr.sbin/ntpd/log.c index c297efe7..0db0245c 100644 --- a/src/usr.sbin/ntpd/log.c +++ b/src/usr.sbin/ntpd/log.c @@ -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 @@ -29,8 +29,6 @@ int debug; extern int debugsyslog; -void logit(int, const char *, ...); - void log_init(int n_debug) { diff --git a/src/usr.sbin/ntpd/ntpd.h b/src/usr.sbin/ntpd/ntpd.h index f1c540b9..be15ea0e 100644 --- a/src/usr.sbin/ntpd/ntpd.h +++ b/src/usr.sbin/ntpd/ntpd.h @@ -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 @@ -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 *, ...); diff --git a/src/usr.sbin/ntpd/parse.y b/src/usr.sbin/ntpd/parse.y index 90d4bed2..67683a1c 100644 --- a/src/usr.sbin/ntpd/parse.y +++ b/src/usr.sbin/ntpd/parse.y @@ -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 @@ -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); }