aboutsummaryrefslogtreecommitdiff
path: root/pylibfdt
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-06-13 05:38:23 -0600
committerDavid Gibson <david@gibson.dropbear.id.au>2018-06-13 22:02:06 +1000
commit354d3dc55939499954b5e1f4948517da24591cd2 (patch)
treed5d7b67c89c2af81e1f4560a3097f791818d7018 /pylibfdt
parent3c374d46accee1911f5679ccb131d1404abbdbbf (diff)
downloaddtc-354d3dc55939499954b5e1f4948517da24591cd2.zip
dtc-354d3dc55939499954b5e1f4948517da24591cd2.tar.gz
dtc-354d3dc55939499954b5e1f4948517da24591cd2.tar.bz2
pylibfdt: Update the bytearray size with pack()
At present pack() calls fdt_pack() which may well reduce the size of the device-tree data. However this does not currently update the size of the bytearray to take account of any reduction. This means that there may be unused data at the end of the bytearray and any users of as_bytearray() will see this extra data. Fix this by resizing the bytearray after packing. Signed-off-by: Simon Glass <sjg@chromium.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pylibfdt')
-rw-r--r--pylibfdt/libfdt.i9
1 files changed, 8 insertions, 1 deletions
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i
index adb4ee8..c0a2191 100644
--- a/pylibfdt/libfdt.i
+++ b/pylibfdt/libfdt.i
@@ -474,10 +474,17 @@ class Fdt:
Args:
quiet: Errors to ignore (empty to raise on all errors)
+ Returns:
+ Error code, or 0 if OK
+
Raises:
FdtException if any error occurs
"""
- return check_err(fdt_pack(self._fdt), quiet)
+ err = check_err(fdt_pack(self._fdt), quiet)
+ if err:
+ return err
+ del self._fdt[self.totalsize():]
+ return err
def getprop(self, nodeoffset, prop_name, quiet=()):
"""Get a property from a node