Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/openpam/dist/lib Reverse the order of printf fo...
details: https://anonhg.NetBSD.org/src/rev/7402d8c37d83
branches: trunk
changeset: 772298:7402d8c37d83
user: christos <christos%NetBSD.org@localhost>
date: Wed Dec 28 14:53:38 2011 +0000
description:
Reverse the order of printf formatting to make it easier for compilers to
check printf arguments.
>From joerg@
diffstat:
external/bsd/openpam/dist/lib/openpam_log.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diffs (45 lines):
diff -r 52f223689047 -r 7402d8c37d83 external/bsd/openpam/dist/lib/openpam_log.c
--- a/external/bsd/openpam/dist/lib/openpam_log.c Wed Dec 28 14:52:56 2011 +0000
+++ b/external/bsd/openpam/dist/lib/openpam_log.c Wed Dec 28 14:53:38 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: openpam_log.c,v 1.2 2011/12/25 22:27:55 christos Exp $ */
+/* $NetBSD: openpam_log.c,v 1.3 2011/12/28 14:53:38 christos Exp $ */
/*-
* Copyright (c) 2002-2003 Networks Associates Technology, Inc.
@@ -100,8 +100,8 @@
_openpam_log(int level, const char *func, const char *fmt, ...)
{
va_list ap;
- char *format;
- int priority;
+ char *msg;
+ int priority, rv;
switch (level) {
case PAM_LOG_DEBUG:
@@ -120,14 +120,18 @@
priority = LOG_ERR;
break;
}
+
va_start(ap, fmt);
- if (asprintf(&format, "in %s(): %s", func, fmt) > 0) {
- vsyslog(priority, format, ap);
- FREE(format);
- } else {
- vsyslog(priority, fmt, ap);
+ rv = vasprintf(&msg, fmt, ap);
+ va_end(ap);
+
+ if (rv < 0) {
+ syslog(priority, "Can't format message from %s: %s (%m)",
+ func, fmt);
+ return;
}
- va_end(ap);
+ syslog(priority, "in %s(): %s", func, msg);
+ FREE(msg);
}
#endif
Home |
Main Index |
Thread Index |
Old Index