summaryrefslogtreecommitdiffstats
path: root/usr.bin/dtc
diff options
context:
space:
mode:
authortheraven <theraven@FreeBSD.org>2013-12-12 08:55:24 +0000
committertheraven <theraven@FreeBSD.org>2013-12-12 08:55:24 +0000
commitade78829a0b8ff766c53fbf136a30ca65a311a1a (patch)
tree0b4b608f8e69a388d979d1fab6434ea812b58e09 /usr.bin/dtc
parentb1e0fad8f80fb355067c46b298bfe63d92936871 (diff)
downloadFreeBSD-src-ade78829a0b8ff766c53fbf136a30ca65a311a1a.zip
FreeBSD-src-ade78829a0b8ff766c53fbf136a30ca65a311a1a.tar.gz
Some more cleanups and bug fixes in dtc for property printing / parsing.
Submitted by: Patrick Wildt
Diffstat (limited to 'usr.bin/dtc')
-rw-r--r--usr.bin/dtc/fdt.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/usr.bin/dtc/fdt.cc b/usr.bin/dtc/fdt.cc
index b2405ef..0599d55 100644
--- a/usr.bin/dtc/fdt.cc
+++ b/usr.bin/dtc/fdt.cc
@@ -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 *file)
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, input_buffer &strings)
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;
OpenPOWER on IntegriCloud