[PATCH 07/17] pylibfdt: Work-around SWIG limitations with flexible arrays

Alexey Charkov <[email protected]>
Newsgroups org.u-boot-project.lists.u-boot
Message-ID <[email protected]>
From: Rob Herring <[email protected]>

SWIG cannot generate setters for a struct's flexible array member and
emits C that does not compile:

./pylibfdt/libfdt_wrap.c: In function '_wrap_fdt_node_header_name_set':
./pylibfdt/libfdt_wrap.c:4350:18: error: cast specifies array type
./pylibfdt/libfdt_wrap.c:4350:16: error: invalid use of flexible array member
./pylibfdt/libfdt_wrap.c:4613:18: error: cast specifies array type
./pylibfdt/libfdt_wrap.c:4613:16: error: invalid use of flexible array member

Turns out this is a known issue with SWIG:
https://github.com/swig/swig/issues/1699

Implement the work-around to ignore the flexible array member. U-Boot's
copy of fdt.h still declares those members as zero-length arrays, so
nothing breaks today, but carrying the work-around now keeps the shipped
file in step with upstream and avoids the failure when the C libfdt is
next resynced.

This is a backport of dtc commit abbd523bae6e ("pylibfdt: Work-around
SWIG limitations with flexible arrays").

Signed-off-by: Rob Herring <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
Tested-by: Simon Glass <[email protected]>
Signed-off-by: David Gibson <[email protected]>
[adapted to U-Boot]
Signed-off-by: Alexey Charkov <[email protected]>
---
 scripts/dtc/pylibfdt/libfdt.i_shipped | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/scripts/dtc/pylibfdt/libfdt.i_shipped b/scripts/dtc/pylibfdt/libfdt.i_shipped
index 634ccd2a829a..2a7fdfb2af40 100644
--- a/scripts/dtc/pylibfdt/libfdt.i_shipped
+++ b/scripts/dtc/pylibfdt/libfdt.i_shipped
@@ -1041,6 +1041,9 @@ class NodeAdder():
 
 %rename(fdt_property) fdt_property_func;
 
+%immutable fdt_property::data;
+%immutable fdt_node_header::name;
+
 /*
  * fdt32_t is a big-endian 32-bit value defined to uint32_t in libfdt_env.h
  * so use the same type here.

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.