svn commit: r348801 - head/sys/dev/sdhci

Bjoern A. Zeeb bz at FreeBSD.org
Sat Jun 8 15:24:04 UTC 2019


Author: bz
Date: Sat Jun  8 15:24:03 2019
New Revision: 348801
URL: https://svnweb.freebsd.org/changeset/base/348801

Log:
  Improve sdhci slot_printf() debug printing.
  
  Currently slot_printf() uses two printf() calls to print the
  device-slot name, and actual message. When other printf()s are
  ongoing in parallel this can lead to interleaved message on the console,
  which is especially unhelpful for debugging or error messages.
  
  Take a hit on the stack and vsnprintf() the message to the buffer.
  This way it can be printed along with the device-slot name in one go
  avoiding console gibberish.
  
  Reviewed by:	marius
  MFC after:	2 weeks
  Sponsored by:	The FreeBSD Foundation
  Differential Revision:	https://reviews.freebsd.org/D19747

Modified:
  head/sys/dev/sdhci/sdhci.c

Modified: head/sys/dev/sdhci/sdhci.c
==============================================================================
--- head/sys/dev/sdhci/sdhci.c	Sat Jun  8 15:19:50 2019	(r348800)
+++ head/sys/dev/sdhci/sdhci.c	Sat Jun  8 15:24:03 2019	(r348801)
@@ -185,15 +185,20 @@ sdhci_getaddr(void *arg, bus_dma_segment_t *segs, int 
 static int
 slot_printf(const struct sdhci_slot *slot, const char * fmt, ...)
 {
+	char buf[128];
 	va_list ap;
 	int retval;
 
-	retval = printf("%s-slot%d: ",
-	    device_get_nameunit(slot->bus), slot->num);
-
+	/*
+	 * Make sure we print a single line all together rather than in two
+	 * halves to avoid console gibberish bingo.
+	 */
 	va_start(ap, fmt);
-	retval += vprintf(fmt, ap);
+	retval = vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
+
+	retval += printf("%s-slot%d: %s",
+	    device_get_nameunit(slot->bus), slot->num, buf);
 	return (retval);
 }
 


More information about the svn-src-head mailing list