From: Luca Weiss <[email protected]>

Let the caller pick the initial buffer size, which also makes the
-NOSPACE retry path reachable from a test by passing a tiny hint.

This is a backport of dtc commit 3f29d6d85c24 ("pylibfdt: add size_hint
parameter for get_path").

Signed-off-by: Luca Weiss <[email protected]>
Signed-off-by: David Gibson <[email protected]>
[adapt to U-Boot]
Signed-off-by: Alexey Charkov <[email protected]>
---
 scripts/dtc/pylibfdt/libfdt.i_shipped | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped 
b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 2a7fdfb2af40..6a900265459d 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -447,11 +447,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
@@ -459,11 +460,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:

-- 
2.54.0

Reply via email to