aboutsummaryrefslogtreecommitdiff
path: root/sim/ppc/hw_opic.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-05-19 12:46:47 +0200
committerMike Frysinger <vapier@gentoo.org>2021-09-08 23:33:25 -0400
commit81f839676d98024f6c0a6609866bfa81b5f35325 (patch)
tree56d5d325eb60adb1e831e9918b36e04db26ba788 /sim/ppc/hw_opic.c
parent0c320e1bdcb45e0d46f69a1567a06be326529c34 (diff)
downloadgdb-81f839676d98024f6c0a6609866bfa81b5f35325.zip
gdb-81f839676d98024f6c0a6609866bfa81b5f35325.tar.gz
gdb-81f839676d98024f6c0a6609866bfa81b5f35325.tar.bz2
sim: ppc: enable -Wpointer-sign warnings
When compiling with --enable-werror and CFLAGS="-O0 -g -Wall", we run into: ... src/sim/ppc/hw_memory.c: In function 'hw_memory_init_address': src/sim/ppc/hw_memory.c:204:7: error: pointer targets in passing argument 4 \ of 'device_find_integer_array_property' differ in signedness \ [-Werror=pointer-sign] &new_chunk->size); ^ ... Fix these by adding an explicit pointer cast. It's a bit ugly to use APIs based on signed integers to read out unsigned values, but in practice, this is par for the course in the ppc code. We already use signed APIs and assign the result to unsigned values a lot: see how device_find_integer_property returns a signed integer (cell), but then assign it to unsigned types. The array APIs are not used that often which is why we don't see many warnings, and we disable warnings when we assign signed integers to unsigned integers in general. The dtc/libfdt project (which is the standard in other projects) processes the fdt blob as a series of bytes without any type information. Typing is left to the caller. They have core APIs that read/write bytes, and a few helper functions to cast/convert those bytes to the right value (e.g. u32). In this ppc sim code, the core APIs use signed integers, and the callers convert to unsigned, usually implicitly. We could add some core APIs to the ppc sim that deal with raw bytes and then add some helpers to convert to the right type, but that seems like a lot of lifting for what boils down to a cast, and is effectively equivalent to all the implicit assignments we use elsewhere. Long term, a lot of the ppc code should either get converted to existing sim common code, or we should stand up proper APIs in the common code first, or use standard libraries to do all the processing (e.g. libfdt). Either way, this device.c code would all get deleted, and callers (like these hw_*.c files) would get converted. Which is also why we go with a cast rather new (but largely unused) APIs.
Diffstat (limited to 'sim/ppc/hw_opic.c')
-rw-r--r--sim/ppc/hw_opic.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sim/ppc/hw_opic.c b/sim/ppc/hw_opic.c
index 8afe312..9404204 100644
--- a/sim/ppc/hw_opic.c
+++ b/sim/ppc/hw_opic.c
@@ -417,10 +417,12 @@ hw_opic_init_data(device *me)
}
if (!device_find_integer_array_property(me, "interrupt-ranges",
reg_nr * 2,
- &opic->isu_block[isb].int_number)
+ (signed_cell *)
+ &opic->isu_block[isb].int_number)
|| !device_find_integer_array_property(me, "interrupt-ranges",
reg_nr * 2 + 1,
- &opic->isu_block[isb].range))
+ (signed_cell *)
+ &opic->isu_block[isb].range))
device_error(me, "missing or invalid interrupt-ranges property entry %d", reg_nr);
/* first reg entry specifies the address of both the IDU and the
first set of ISU registers, adjust things accordingly */