svn commit: r259250 - head/usr.bin/dtc

David Chisnall theraven at FreeBSD.org
Thu Dec 12 08:55:25 UTC 2013


Author: theraven
Date: Thu Dec 12 08:55:24 2013
New Revision: 259250
URL: http://svnweb.freebsd.org/changeset/base/259250

Log:
  Some more cleanups and bug fixes in dtc for property printing / parsing.
  
  Submitted by:	Patrick Wildt

Modified:
  head/usr.bin/dtc/fdt.cc

Modified: head/usr.bin/dtc/fdt.cc
==============================================================================
--- head/usr.bin/dtc/fdt.cc	Thu Dec 12 08:48:45 2013	(r259249)
+++ head/usr.bin/dtc/fdt.cc	Thu Dec 12 08:55:24 2013	(r259250)
@@ -137,7 +137,7 @@ property_value::resolve_type()
 				break;
 			}
 		}
-		if (is_all_printable && (bytes > nuls))
+		if ((is_all_printable && (bytes > nuls)) || bytes == 0)
 		{
 			type = STRING;
 			if (nuls > 0)
@@ -204,7 +204,7 @@ property_value::write_as_bytes(FILE *fil
 	putc('[', file);
 	for (byte_buffer::iterator i=byte_data.begin(), e=byte_data.end(); i!=e ; i++)
 	{
-		fprintf(file, "%hhx", *i);
+		fprintf(file, "%02hhx", *i);
 		if (i+1 != e)
 		{
 			putc(' ', file);
@@ -367,6 +367,11 @@ property::property(input_buffer &structs
 		return;
 	}
 	key = string(name_buffer);
+
+	// If we're empty, do not push anything as value.
+	if (!length)
+		return;
+
 	// Read the value
 	uint8_t byte;
 	property_value v;


More information about the svn-src-head mailing list