[PATCH 01/17] pylibfdt: Cast property length to Py_ssize_t
Alexey Charkov <[email protected]>
| Newsgroups | org.u-boot-project.lists.u-boot |
|---|---|
| Message-ID | <[email protected]> |
Commit 7d01bb1c5a1d ("libfdt: Fix build with python 3.10") took only half
of the upstream fix, dtc commit 383e148b70a4 ("pylibfdt: fix with Python
3.10"): it defines PY_SSIZE_T_CLEAN but leaves the length argument passed
to Py_BuildValue() as a plain int. With PY_SSIZE_T_CLEAN in effect the "y#"
and "s#" converters read a Py_ssize_t, so passing an int is undefined
behaviour that happens to work only where the two share a representation.
Take the remaining hunk so the typemap matches upstream and the subsequent
upstream imports apply verbatim.
Signed-off-by: Alexey Charkov <[email protected]>
---
scripts/dtc/pylibfdt/libfdt.i_shipped | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 326a15c7941e..eb075c0b92bf 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -1049,9 +1049,9 @@ typedef uint32_t fdt32_t;
$result = Py_None;
else
%#if PY_VERSION_HEX >= 0x03000000
- $result = Py_BuildValue("y#", $1, *arg4);
+ $result = Py_BuildValue("y#", $1, (Py_ssize_t)*arg4);
%#else
- $result = Py_BuildValue("s#", $1, *arg4);
+ $result = Py_BuildValue("s#", $1, (Py_ssize_t)*arg4);
%#endif
}
--
2.54.0