Re: [PATCH 5/5] sim/iq2000: silence pointer-sign warnings

Mike Frysinger via Gdb-patches
2022-10-26T10:06:47Z

[-- Attachment #1: Type: text/plain, Size: 1821 bytes --]

On 24 Oct 2022 16:45, Andrew Burgess wrote:
> Mike Frysinger <vapier@gentoo.org> writes:
>
> > On 12 Oct 2022 13:38, Andrew Burgess via Gdb-patches wrote:
> >> When building the iq2000 simulator I see a few warnings like this:
> >>
> >> /tmp/build/sim/../../src/sim/iq2000/iq2000.c: In function ‘fetch_str’:
> >> /tmp/build/sim/../../src/sim/iq2000/iq2000.c:50:54: error: pointer targets in passing argument 3 of ‘sim_read’ differ in signedness [-Werror=pointer-sign]
> >> 50 | sim_read (CPU_STATE (current_cpu), CPU2DATA(addr), buf, nr);
> >> | ^~~
> >> | |
> >> | char *
> >>
> >> I've silenced these warnings by casting buf to 'unsigned char *'.
> >> With this change I now see no warnings when compiling iq2000.c, so
> >> I've removed the line from Makefile.in that disables -Werror.
> >
> > i left this warning in place so someone would fix it properly rather than
> > just cast it away
>
> Sorry for not understanding that. If you'd like to expand on "properly"
> I'll take a pass at fixing it.

whatever doesn't require a lot of casting :). sprinkling casts around means
leaving landmines for ourselves in the future.

in this particular case, i think the only reasonable answer is to change the
sim_read & sim_write APIs to work on void* much like the C library funcs. i
get that void pointers are basically implicit casts, but i think that's still
the right way to go unless i'm forgetting something obvious.

i also vaguely recall that we really shouldn't be using sim_read & sim_write
in sim backends in the first place, but instead leaning on sim_core_* APIs.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]