svn commit: r255351 - in head/sys: kern sys

Navdeep Parhar np at FreeBSD.org
Sat Sep 7 07:53:22 UTC 2013


Author: np
Date: Sat Sep  7 07:53:21 2013
New Revision: 255351
URL: http://svnweb.freebsd.org/changeset/base/255351

Log:
  Add a vtprintf.  It is to tprintf what vprintf is to printf.
  
  Reviewed by:	kib

Modified:
  head/sys/kern/subr_prf.c
  head/sys/sys/systm.h

Modified: head/sys/kern/subr_prf.c
==============================================================================
--- head/sys/kern/subr_prf.c	Sat Sep  7 07:39:24 2013	(r255350)
+++ head/sys/kern/subr_prf.c	Sat Sep  7 07:53:21 2013	(r255351)
@@ -175,15 +175,24 @@ out:
 }
 
 /*
- * tprintf prints on the controlling terminal associated with the given
- * session, possibly to the log as well.
+ * tprintf and vtprintf print on the controlling terminal associated with the
+ * given session, possibly to the log as well.
  */
 void
 tprintf(struct proc *p, int pri, const char *fmt, ...)
 {
+	va_list ap;
+
+	va_start(ap, fmt);
+	vtprintf(p, pri, fmt, ap);
+	va_end(ap);
+}
+
+void
+vtprintf(struct proc *p, int pri, const char *fmt, va_list ap)
+{
 	struct tty *tp = NULL;
 	int flags = 0;
-	va_list ap;
 	struct putchar_arg pca;
 	struct session *sess = NULL;
 
@@ -208,13 +217,11 @@ tprintf(struct proc *p, int pri, const c
 	pca.tty = tp;
 	pca.flags = flags;
 	pca.p_bufr = NULL;
-	va_start(ap, fmt);
 	if (pca.tty != NULL)
 		tty_lock(pca.tty);
 	kvprintf(fmt, putchar, &pca, 10, ap);
 	if (pca.tty != NULL)
 		tty_unlock(pca.tty);
-	va_end(ap);
 	if (sess != NULL)
 		sess_release(sess);
 	msgbuftrigger = 1;

Modified: head/sys/sys/systm.h
==============================================================================
--- head/sys/sys/systm.h	Sat Sep  7 07:39:24 2013	(r255350)
+++ head/sys/sys/systm.h	Sat Sep  7 07:53:21 2013	(r255351)
@@ -212,6 +212,7 @@ u_long	strtoul(const char *, char **, in
 quad_t	strtoq(const char *, char **, int) __nonnull(1);
 u_quad_t strtouq(const char *, char **, int) __nonnull(1);
 void	tprintf(struct proc *p, int pri, const char *, ...) __printflike(3, 4);
+void	vtprintf(struct proc *, int, const char *, __va_list) __printflike(3, 0);
 void	hexdump(const void *ptr, int length, const char *hdr, int flags);
 #define	HD_COLUMN_MASK	0xff
 #define	HD_DELIM_MASK	0xff00


More information about the svn-src-head mailing list