summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/rcsparse.c
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2014-11-16 19:14:34 +0000
committerbluhm <bluhm@openbsd.org>2014-11-16 19:14:34 +0000
commit029d28555be2a2d1abd9625f8fe423f4e2ce252d (patch)
tree1361bebd34b1c4e742d25782552e7634d51fdcb1 /usr.bin/cvs/rcsparse.c
parentConvert the logic in yyerror(). Instead of creating a temporary (diff)
downloadwireguard-openbsd-029d28555be2a2d1abd9625f8fe423f4e2ce252d.tar.xz
wireguard-openbsd-029d28555be2a2d1abd9625f8fe423f4e2ce252d.zip
Convert the logic in rcsparse_warnx(). Instead of creating a
temporary format string, create a temporary message. If there is not enough memory to log the error, just log this second error. The double error path gets never tested, so it should be simple. Make it work like the other places. OK doug@
Diffstat (limited to 'usr.bin/cvs/rcsparse.c')
-rw-r--r--usr.bin/cvs/rcsparse.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/usr.bin/cvs/rcsparse.c b/usr.bin/cvs/rcsparse.c
index 4c73f384386..0c615eef0ce 100644
--- a/usr.bin/cvs/rcsparse.c
+++ b/usr.bin/cvs/rcsparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rcsparse.c,v 1.7 2013/06/03 17:04:35 jcs Exp $ */
+/* $OpenBSD: rcsparse.c,v 1.8 2014/11/16 19:14:34 bluhm Exp $ */
/*
* Copyright (c) 2010 Tobias Stoeckmann <tobias@openbsd.org>
*
@@ -1259,15 +1259,16 @@ rcsparse_warnx(RCSFILE *rfp, char *fmt, ...)
{
struct rcs_pdata *pdp;
va_list ap;
- char *nfmt;
+ char *msg;
pdp = (struct rcs_pdata *)rfp->rf_pdata;
va_start(ap, fmt);
- if (asprintf(&nfmt, "%s:%d: %s", rfp->rf_path, pdp->rp_msglineno, fmt)
- == -1)
- nfmt = fmt;
- cvs_vlog(LP_ERR, nfmt, ap);
+ if (vasprintf(&msg, fmt, ap) == -1) {
+ cvs_log(LP_ERRNO, "vasprintf");
+ va_end(ap);
+ return;
+ }
va_end(ap);
- if (nfmt != fmt)
- free(nfmt);
+ cvs_log(LP_ERR, "%s:%d: %s", rfp->rf_path, pdp->rp_msglineno, msg);
+ free(msg);
}