From fdf3f6d897ab8759fb7d7277ba5224beb4727d1d Mon Sep 17 00:00:00 2001 From: Simon Glass Date: Thu, 24 Oct 2019 19:02:26 -0600 Subject: [PATCH] pylibfdt: Correct the type for fdt_property_stub() This function should use a void * type, not char *. This causes an error: TypeError: in method 'fdt_property_stub', argument 3 of type 'char const *' Fix it and update the tests. Signed-off-by: Simon Glass Message-Id: <20191025010226.34378-1-sjg@chromium.org> Signed-off-by: David Gibson --- pylibfdt/libfdt.i | 6 +++--- tests/pylibfdt_tests.py | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index feb8c9c..3e09d3a 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -18,7 +18,7 @@ * a struct called fdt_property. That struct causes swig to create a class in * libfdt.py called fdt_property(), which confuses things. */ -static int fdt_property_stub(void *fdt, const char *name, const char *val, +static int fdt_property_stub(void *fdt, const char *name, const void *val, int len) { return fdt_property(fdt, name, val, len); @@ -930,7 +930,7 @@ class FdtSw(FdtRo): Args: name: Name of property to add - val: Value of property + val: Value of property (bytes) quiet: Errors to ignore (empty to raise on all errors) Raises: @@ -1113,6 +1113,6 @@ int fdt_property_cell(void *fdt, const char *name, uint32_t val); * This function has a stub since the name fdt_property is used for both a * function and a struct, which confuses SWIG. */ -int fdt_property_stub(void *fdt, const char *name, const char *val, int len); +int fdt_property_stub(void *fdt, const char *name, const void *val, int len); %include diff --git a/tests/pylibfdt_tests.py b/tests/pylibfdt_tests.py index 509cf14..021a5a8 100644 --- a/tests/pylibfdt_tests.py +++ b/tests/pylibfdt_tests.py @@ -522,8 +522,9 @@ class PyLibfdtSwTests(unittest.TestCase): sw.property_string('compatible', 'subnode1') sw.property_u32('reg', 1) sw.property_cell('prop-int', TEST_VALUE_1) + sw.property('data', b'\x00data\x01') sw.begin_node('subsubnode') - sw.property('compatible', 'subsubnode1\0subsubnode') + sw.property('compatible', b'subsubnode1\0subsubnode') sw.property_cell('prop-int', TEST_VALUE_1) sw.end_node() sw.begin_node('ss1') @@ -540,7 +541,7 @@ class PyLibfdtSwTests(unittest.TestCase): with sw.add_node('subsubnode@0'): sw.property_u32('reg', 0) sw.property_cell('phandle', PHANDLE_2) - sw.property('compatible', 'subsubnode2\0subsubnode') + sw.property('compatible', b'subsubnode2\0subsubnode') sw.property_cell('prop-int', TEST_VALUE_2) with sw.add_node('ss2'): pass