diff options
author | Simon Glass <sjg@chromium.org> | 2018-06-12 23:24:11 -0600 |
---|---|---|
committer | David Gibson <david@gibson.dropbear.id.au> | 2018-06-13 16:32:55 +1000 |
commit | 49d32ce40bb44a35536326236c4f82ca6848b0f0 (patch) | |
tree | 0287065fdb69a1fdb31abff0f728b030006972b5 /pylibfdt | |
parent | 481246a0c13a364081579c97fc4efbba5213cac1 (diff) | |
download | dtc-49d32ce40bb44a35536326236c4f82ca6848b0f0.zip dtc-49d32ce40bb44a35536326236c4f82ca6848b0f0.tar.gz dtc-49d32ce40bb44a35536326236c4f82ca6848b0f0.tar.bz2 |
pylibfdt: Use an unsigned type for fdt32_t
The members of struct fdt_header are declared as fdt32_t which is a
32-bit, big-endian, unsigned integer. These fields are accessed by macros
in libfdt.h so no return type is declared. But the correct return type is
uint32_t, not fdt32_t, since the endianness conversion is done within the
macro before returning the value.
The macros are re-declared as normal functions in pylibfdt since swig does
not support macros. The return type is currently int. Change it to
uint32_t, which allows us to drop the work-around mask in Fdt.magic().
Also change the typedef for fdt32_t to uint32_t. The currently has no
obvious effect, since use of big-endian values should always be internal
to pylibfdt, but it is more correct.
Signed-off-by: Simon Glass <sjg@chromium.org>
Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'pylibfdt')
-rw-r--r-- | pylibfdt/libfdt.i | 29 |
1 files changed, 16 insertions, 13 deletions
diff --git a/pylibfdt/libfdt.i b/pylibfdt/libfdt.i index 3abcf32..520911e 100644 --- a/pylibfdt/libfdt.i +++ b/pylibfdt/libfdt.i @@ -240,8 +240,7 @@ class Fdt: Returns: Magic word """ - # Use a mask to ensure that this does not return a -ve number - return fdt_magic(self._fdt) & 0xffffffff + return fdt_magic(self._fdt) def totalsize(self): """Return the total size of the device tree @@ -628,7 +627,11 @@ class Property(bytearray): %rename(fdt_property) fdt_property_func; -typedef int fdt32_t; +/* + * fdt32_t is a big-endian 32-bit value defined to uint32_t in libfdt_env.h + * so use the same type here. + */ +typedef uint32_t fdt32_t; %include "libfdt/fdt.h" @@ -716,15 +719,15 @@ typedef int fdt32_t; %warnfilter(302) fdt_property; /* These are macros in the header so have to be redefined here */ -int fdt_magic(const void *fdt); -int fdt_totalsize(const void *fdt); -int fdt_off_dt_struct(const void *fdt); -int fdt_off_dt_strings(const void *fdt); -int fdt_off_mem_rsvmap(const void *fdt); -int fdt_version(const void *fdt); -int fdt_last_comp_version(const void *fdt); -int fdt_boot_cpuid_phys(const void *fdt); -int fdt_size_dt_strings(const void *fdt); -int fdt_size_dt_struct(const void *fdt); +uint32_t fdt_magic(const void *fdt); +uint32_t fdt_totalsize(const void *fdt); +uint32_t fdt_off_dt_struct(const void *fdt); +uint32_t fdt_off_dt_strings(const void *fdt); +uint32_t fdt_off_mem_rsvmap(const void *fdt); +uint32_t fdt_version(const void *fdt); +uint32_t fdt_last_comp_version(const void *fdt); +uint32_t fdt_boot_cpuid_phys(const void *fdt); +uint32_t fdt_size_dt_strings(const void *fdt); +uint32_t fdt_size_dt_struct(const void *fdt); %include <../libfdt/libfdt.h> |