Author: marius
Date: Fri Jan 27 22:29:29 2012
New Revision: 230631
URL: http://svn.freebsd.org/changeset/base/230631

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

Modified:
  head/sys/dev/ofw/openfirm.c

Modified: head/sys/dev/ofw/openfirm.c
==============================================================================
--- head/sys/dev/ofw/openfirm.c Fri Jan 27 22:25:46 2012        (r230630)
+++ head/sys/dev/ofw/openfirm.c Fri Jan 27 22:29:29 2012        (r230631)
@@ -72,6 +72,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;
@@ -82,7 +84,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);
@@ -138,15 +140,27 @@ OF_init(void *cookie)
        return (rv);
 }
 
+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);
 }
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to