diff options
author | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-11-03 16:56:00 +0000 |
---|---|---|
committer | Alexander Bluhm <bluhm@cvs.openbsd.org> | 2014-11-03 16:56:00 +0000 |
commit | 054c4539411911be51bd4b436759f03d8023baea (patch) | |
tree | a9a7015f81045d8febf00e4cd45d6b00ecb10a21 | |
parent | e89c4773678d25885dd8624ae40ab7c1c4c49288 (diff) |
Convert the logic in yyerror(). Instead of creating a temporary
format string, create a temporary message.
OK benno@ doug@ claudio@
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/parse.y | 12 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/log.c | 4 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/log.h | 3 | ||||
-rw-r--r-- | usr.sbin/dvmrpd/parse.y | 12 |
6 files changed, 18 insertions, 20 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index b213e871951..9f469cb798d 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.281 2013/11/13 09:14:48 florian Exp $ */ +/* $OpenBSD: bgpd.h,v 1.282 2014/11/03 16:55:59 bluhm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -957,6 +957,7 @@ struct in6_addr *prefixlen2mask6(u_int8_t prefixlen); /* log.c */ void log_init(int); void log_verbose(int); +void logit(int, const char *, ...); void vlog(int, const char *, va_list); void log_peer_warn(const struct peer_config *, const char *, ...); void log_peer_warnx(const struct peer_config *, const char *, ...); diff --git a/usr.sbin/bgpd/log.c b/usr.sbin/bgpd/log.c index 0273113e778..3ce9df6615b 100644 --- a/usr.sbin/bgpd/log.c +++ b/usr.sbin/bgpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.57 2013/01/10 09:56:57 sthen Exp $ */ +/* $OpenBSD: log.c,v 1.58 2014/11/03 16:55:59 bluhm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -34,8 +34,6 @@ int debug; int verbose; -void logit(int, const char *, ...); - char * log_fmt_peer(const struct peer_config *peer) { diff --git a/usr.sbin/bgpd/parse.y b/usr.sbin/bgpd/parse.y index ad1a0bcbc22..e0b06f8d6a1 100644 --- a/usr.sbin/bgpd/parse.y +++ b/usr.sbin/bgpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.273 2014/11/02 00:30:41 doug Exp $ */ +/* $OpenBSD: parse.y,v 1.274 2014/11/03 16:55:59 bluhm Exp $ */ /* * Copyright (c) 2002, 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2099,15 +2099,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/dvmrpd/log.c b/usr.sbin/dvmrpd/log.c index 782a8f85d55..daabb5f6053 100644 --- a/usr.sbin/dvmrpd/log.c +++ b/usr.sbin/dvmrpd/log.c @@ -1,4 +1,4 @@ -/* $OpenBSD: log.c,v 1.3 2011/08/20 19:02:28 sthen Exp $ */ +/* $OpenBSD: log.c,v 1.4 2014/11/03 16:55:59 bluhm Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -37,8 +37,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/dvmrpd/log.h b/usr.sbin/dvmrpd/log.h index 33e4dbf60d8..100dcc3bae6 100644 --- a/usr.sbin/dvmrpd/log.h +++ b/usr.sbin/dvmrpd/log.h @@ -1,4 +1,4 @@ -/* $OpenBSD: log.h,v 1.2 2009/11/02 20:31:50 claudio Exp $ */ +/* $OpenBSD: log.h,v 1.3 2014/11/03 16:55:59 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/dvmrpd/parse.y b/usr.sbin/dvmrpd/parse.y index be48ffaed8f..2d987ac8ada 100644 --- a/usr.sbin/dvmrpd/parse.y +++ b/usr.sbin/dvmrpd/parse.y @@ -1,4 +1,4 @@ -/* $OpenBSD: parse.y,v 1.26 2014/01/22 00:21:16 henning Exp $ */ +/* $OpenBSD: parse.y,v 1.27 2014/11/03 16:55:59 bluhm Exp $ */ /* * Copyright (c) 2004, 2005, 2006 Esben Norby <norby@openbsd.org> @@ -359,15 +359,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); } |