Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 1 Feb 2012 21:11:09 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r230885 - stable/8/sys/dev/ofw
Message-ID:  <201202012111.q11LB9EU005032@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: marius
Date: Wed Feb  1 21:11:09 2012
New Revision: 230885
URL: http://svn.freebsd.org/changeset/base/230885

Log:
  MFC: r230631
  
  Implement OF_printf() using kvprintf() directly, avoiding to use a
  buffer and allowing to handle newlines properly.

Modified:
  stable/8/sys/dev/ofw/openfirm.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/e1000/   (props changed)

Modified: stable/8/sys/dev/ofw/openfirm.c
==============================================================================
--- stable/8/sys/dev/ofw/openfirm.c	Wed Feb  1 21:11:06 2012	(r230884)
+++ stable/8/sys/dev/ofw/openfirm.c	Wed Feb  1 21:11:09 2012	(r230885)
@@ -70,6 +70,8 @@ __FBSDID("$FreeBSD$");
 
 #include "ofw_if.h"
 
+static void OF_putchar(int c, void *arg);
+
 MALLOC_DEFINE(M_OFWPROP, "openfirm", "Open Firmware properties");
 
 static ihandle_t stdout;
@@ -80,7 +82,7 @@ static struct ofw_kobj	ofw_kernel_obj;
 static struct kobj_ops	ofw_kernel_kops;
 
 /*
- * OFW install routines. Highest priority wins, equal priority also
+ * OFW install routines.  Highest priority wins, equal priority also
  * overrides allowing last-set to win.
  */
 SET_DECLARE(ofw_set, ofw_def_t);
@@ -131,15 +133,27 @@ OF_init(void *cookie)
 		stdout = -1;
 }
 
+static void
+OF_putchar(int c, void *arg __unused)
+{
+	char cbuf;
+
+	if (c == '\n') {
+		cbuf = '\r';
+		OF_write(stdout, &cbuf, 1);
+	}
+
+	cbuf = c;
+	OF_write(stdout, &cbuf, 1);
+}
+
 void
 OF_printf(const char *fmt, ...)
 {
 	va_list	va;
-	char buf[1024];
 
 	va_start(va, fmt);
-	vsprintf(buf, fmt, va);
-	OF_write(stdout, buf, strlen(buf));
+	(void)kvprintf(fmt, OF_putchar, NULL, 10, va);
 	va_end(va);
 }
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201202012111.q11LB9EU005032>