On Fri, Jul 8, 2011 at 11:47 AM, Øyvind Harboe <[email protected]> wrote:
> On Fri, Jul 8, 2011 at 11:43 AM, Drasko DRASKOVIC
> <[email protected]> wrote:
>> On Thu, Jul 7, 2011 at 11:58 AM, Øyvind Harboe <[email protected]> 
>> wrote:
>>> Note that this problem has cropped up many places over the OpenOCD
>>> code. I'd like to get rid of it once and for all....
>>>
>>> I absolutely intend to fix it for MIPS, but I'd like a good long term 
>>> solution.
>>>
>>> With jtag queue callbacks, a user data pointer to the callback is cast to
>>> a void pointer, then cast back to e.g. uint32_t *. Casting to/from void *
>>> does not yield a warning(should not anyway, right?),
>> Why shouldn't it ? I mean, you can have unaligned acces by casting
>> void* to unaligned addr to uint32* and then reference, right ?
>
> Such warnings would be hopelessly noisy. A callback generally
> takes a pointer to *something* and then inside the callback you cast
> back the pointer to whatever you *know* you passed in.
>
> Of course C++ the whole casting business is much more advanced than
> i C.
>
>> From my point of view casting uint8_t* to uint32* is dangerous as
>> casting void* to uint32_t*. Isee no difference, as void* can point to
>> unaligned addr.
>
> There is no difference in danger, but what the compiler is telling
> you is that if you do need to have a generic pointer, then use void *,
> not uint8_t *.

OK, I am starting to get this... Thanks  Øyvind.

But looking from to the code, I see no explicit casting uint8_t* to
uint32_t in mips_pracc code. Where did you exactly run into compiler
warning ?

BR,
Drasko
_______________________________________________
Openocd-development mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to