From 3f29d6d85c244ad3a74f3b516075d52c0ff35ea6 Mon Sep 17 00:00:00 2001 From: Luca Weiss Date: Wed, 1 Feb 2023 19:11:13 +0100 Subject: pylibfdt: add size_hint parameter for get_path This also enables us to test the -NOSPACE condition by adding a test setting size_hint=1 so this path is taken. Message-Id: <20230201181112.1644842-1-luca@z3ntu.xyz> Signed-off-by: Luca Weiss Signed-off-by: David Gibson --- pylibfdt/libfdt.i | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'pylibfdt') diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index 987f7b9..2361e22 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -443,11 +443,12 @@ class FdtRo(object): """ return fdt_get_alias(self._fdt, name) - def get_path(self, nodeoffset, quiet=()): + def get_path(self, nodeoffset, size_hint=1024, quiet=()): """Get the full path of a node Args: nodeoffset: Node offset to check + size_hint: Hint for size of returned string Returns: Full path to the node @@ -455,11 +456,10 @@ class FdtRo(object): Raises: FdtException if an error occurs """ - size = 1024 while True: - ret, path = fdt_get_path(self._fdt, nodeoffset, size) + ret, path = fdt_get_path(self._fdt, nodeoffset, size_hint) if ret == -NOSPACE: - size = size * 2 + size_hint *= 2 continue err = check_err(ret, quiet) if err: -- cgit v1.1