diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-11-03 18:44:37 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-11-03 18:44:37 +0000 |
commit | 8ea2a5a0b2d8e733282ef401e29a2948a893a4ff (patch) | |
tree | e5dfc43d628d79409ada47a927df3c4150e17f57 | |
parent | 66d10cf9cb5e8e2fe0dc8d1999882d724d4b0d34 (diff) |
Convert the logic in yyerror(). Instead of creating a temporary
format string, create a temporary message.
OK claudio@
-rw-r--r-- | usr.sbin/ifstated/ifstated.h | 3 | ||||
-rw-r--r-- | usr.sbin/ifstated/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/ldapd/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/ldpd/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/ldpd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/ldpd/parse.y | 12 |
6 files changed, 23 insertions, 23 deletions
diff --git a/usr.sbin/ifstated/ifstated.h b/usr.sbin/ifstated/ifstated.h index 78f67c000c0..de32109e0ef 100644 --- a/usr.sbin/ifstated/ifstated.h +++ b/usr.sbin/ifstated/ifstated.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ifstated.h,v 1.7 2013/03/06 21:42:40 sthen Exp $ */ +/* $OpenBSD: ifstated.h,v 1.8 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2004 Ryan McBride @@ -143,5 +143,6 @@ void log_warnx(const char *, ...); void log_info(const char *, ...); void log_debug(const char *, ...); void vlog(int, const char *, va_list); +void logit(int, const char *, ...); __dead void fatal(const char *); __dead void fatalx(const char *); diff --git a/usr.sbin/ifstated/parse.y b/usr.sbin/ifstated/parse.y index 7dddd59465a..6ffa2098ad6 100644 --- a/usr.sbin/ifstated/parse.y +++ b/usr.sbin/ifstated/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.34 2014/11/03 03:42:11 doug Exp $ */ +/* $OpenBSD: parse.y,v 1.35 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2004 Ryan McBride <mcbride@openbsd.org> @@ -357,15 +357,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); } diff --git a/usr.sbin/ldapd/parse.y b/usr.sbin/ldapd/parse.y index 589b041cb32..825e2938018 100644 --- a/usr.sbin/ldapd/parse.y +++ b/usr.sbin/ldapd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.13 2014/09/21 05:33:49 daniel Exp $ */ +/* $OpenBSD: parse.y,v 1.14 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2009, 2010 Martin Hedenfalk <martinh@openbsd.org> @@ -383,15 +383,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); } diff --git a/usr.sbin/ldpd/log.c b/usr.sbin/ldpd/log.c index 4ef03995d5a..f0a8dd28a74 100644 --- a/usr.sbin/ldpd/log.c +++ b/usr.sbin/ldpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.12 2013/06/04 02:25:28 claudio Exp $ */ +/* $OpenBSD: log.c,v 1.13 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -41,8 +41,6 @@ static const char * const procnames[] = { int debug; int verbose; -void logit(int, const char *, ...); - void log_init(int n_debug) { diff --git a/usr.sbin/ldpd/log.h b/usr.sbin/ldpd/log.h index d53d15fe3b2..ba10c360c8c 100644 --- a/usr.sbin/ldpd/log.h +++ b/usr.sbin/ldpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.4 2013/06/01 20:13:04 claudio Exp $ */ +/* $OpenBSD: log.h,v 1.5 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -23,6 +23,7 @@ void log_init(int); void log_verbose(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/usr.sbin/ldpd/parse.y b/usr.sbin/ldpd/parse.y index 443e12671b1..19e06effaee 100644 --- a/usr.sbin/ldpd/parse.y +++ b/usr.sbin/ldpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.20 2014/01/22 00:21:16 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.21 2014/11/03 18:44:36 bluhm Exp $ */ /* * Copyright (c) 2004, 2005, 2008 Esben Norby <norby@openbsd.org> @@ -373,15 +373,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); } |