On Thu, 2009-05-21 at 01:22 -0700, David Brownell wrote:
> I've tripped across several bugs caused by bad printf format strings.
> This is foolish, since GCC will tell about them when functions have
> proper annotations.
> 
> This patch adds annotations to the key command_*() helper functions.
> And then fixes the bugs that turned up.  Test builds on Linux:
> 
>  - x86_64 with gcc 4.3.2
>  - x86_32 with gcc 4.3.3
>  - armel with gcc 4.3.2
> 
> Several of these bugs were from misuse of PRIi64; that's for 64-bit
> integers, NOT for "long long" or "u64" (which work best with %lld).
> 
> (NOTE that the armel build turned up *LOTS* of unrelated bugs, not fixed
> here.  Biggest:  abusing "u8 *ptr" by "*((u32 *)ptr) = ..." loses badly,
> since ARM doesn't guarantee unaligned reads work.  That idiom is used
> all over the place in JTAG buffer conversions.)

Yeah.  My effort to add warnings pointed these out to me, and I just
corrected those with calls to memcpy.  Clearly, this kind of work not
only needs to be done, but it almost begs to be encapsulated in a new
inline functions in src/helper/binarybuffer.[ch].... doesn't it?

Regardless, applied as r1873.  FWIW, r1874 fixes src/helper/ioutil.c.
That file is only built with --enable-ioutil, which mostly provides the
loadFile function (required by the --enable-httpd option).

Cheers,

Zach

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

Reply via email to