summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ifstated
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2014-11-03 18:44:36 +0000
committerbluhm <bluhm@openbsd.org>2014-11-03 18:44:36 +0000
commite3490c9c4aa8f2d09e0fe4b782680bc11e6d8d35 (patch)
tree6ffe1fef1cc3ab995166b2f558dd9d0be2d082f2 /usr.sbin/ifstated
parentConvert the logic in yyerror(). Instead of creating a temporary (diff)
downloadwireguard-openbsd-e3490c9c4aa8f2d09e0fe4b782680bc11e6d8d35.tar.xz
wireguard-openbsd-e3490c9c4aa8f2d09e0fe4b782680bc11e6d8d35.zip
Convert the logic in yyerror(). Instead of creating a temporary
format string, create a temporary message. OK claudio@
Diffstat (limited to 'usr.sbin/ifstated')
-rw-r--r--usr.sbin/ifstated/ifstated.h3
-rw-r--r--usr.sbin/ifstated/parse.y12
2 files changed, 8 insertions, 7 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);
}