On Fri, Jul 8, 2011 at 11:43 AM, Drasko DRASKOVIC
<drasko.drasko...@gmail.com> wrote:
> On Thu, Jul 7, 2011 at 11:58 AM, Øyvind Harboe <oyvind.har...@zylin.com> 
> 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 *.

-- 
Øyvind Harboe - Can Zylin Consulting help on your project?
US toll free 1-866-980-3434 / International +47 51 87 40 27
http://www.zylin.com/
_______________________________________________
Openocd-development mailing list
Openocd-development@lists.berlios.de
https://lists.berlios.de/mailman/listinfo/openocd-development

Reply via email to