Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-16 Thread David Brownell
On Monday 16 November 2009, Zach Welch wrote: > > > Fine with me.  If I can persuade you to do those > > three cleanups, I'd be happier.  ;) > > I've posted my series to do this, now it's your turn. :) OK; I committed a minor doxygen fix for your series of five ... ;) > Remove the 'extern' in

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-16 Thread Zach Welch
On Sun, 2009-11-15 at 16:11 -0700, David Brownell wrote: > On Sunday 15 November 2009, Zach Welch wrote: > > > > > > I'd be happier if it were called DIV_ROUND_UP() like a > > > certain OS kernel I could mention ... not as cryptic. > > > > I agree that the current name stands to be improved. > >

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-15 Thread Zach Welch
On Sun, 2009-11-15 at 16:12 -0700, David Brownell wrote: > On Sunday 15 November 2009, Zach Welch wrote: > > > > > > Or maybe I was. Given that it copies everything, why > > > is there code *after* the copy mangling the last byte? > > > Wouldn't that only be correct when the code copied > > > all

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-15 Thread David Brownell
On Sunday 15 November 2009, Zach Welch wrote: > > > > Or maybe I was.  Given that it copies everything, why > > is there code *after* the copy mangling the last byte? > > Wouldn't that only be correct when the code copied > > all but the trailing partial byte? > > It masks the last byte, ensuring

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-15 Thread David Brownell
On Sunday 15 November 2009, Zach Welch wrote: > > > > I'd be happier if it were called DIV_ROUND_UP() like a > > certain OS kernel I could mention ... not as cryptic. > > I agree that the current name stands to be improved. > > > (Likewise, there's a DIM which is used for ARRAY_SIZE. > > And lot

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-15 Thread Zach Welch
On Sat, 2009-11-14 at 19:59 -0700, David Brownell wrote: > On Saturday 14 November 2009, Zach Welch wrote: > > On Sat, 2009-11-14 at 12:56 -0700, David Brownell wrote: > > > On Saturday 14 November 2009, Zachary T Welch wrote: > > > > - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-14 Thread David Brownell
On Saturday 14 November 2009, Zach Welch wrote: > On Sat, 2009-11-14 at 12:56 -0700, David Brownell wrote: > > On Saturday 14 November 2009, Zachary T Welch wrote: > > > - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; > > > i++) > > > - to[i] = from[i]; > > > +

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-14 Thread Zach Welch
On Sat, 2009-11-14 at 12:56 -0700, David Brownell wrote: > On Saturday 14 November 2009, Zachary T Welch wrote: > > - for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) > > - to[i] = from[i]; > > + // copy entire buffer > > + memcpy(_to, from, CEIL(s

Re: [Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-14 Thread David Brownell
On Saturday 14 November 2009, Zachary T Welch wrote: > -   for (unsigned i = 0, num_bytes = CEIL(size, 8); i < num_bytes; i++) > -   to[i] = from[i]; > +   // copy entire buffer > +   memcpy(_to, from, CEIL(size, 8)); Comment is wrong: copies all but trailing partial byte.

[Openocd-development] [PATCH 08/11] improve buf_cpy helper

2009-11-14 Thread Zachary T Welch
Use memcpy for bulk of copy, improve final byte handling. Improve types by using void * for buffers and unsigned for size. Signed-off-by: Zachary T Welch --- src/helper/binarybuffer.c | 17 + src/helper/binarybuffer.h |3 ++- 2 files changed, 11 insertions(+), 9 deletions(-