Snowel Xue wrote:
> Hi
> I found there is one bug here:
> orignal code:
> /* Write a word at a time */
> data = 0;
> for (j = step; j > 0 && bc > 0; j--)
> {
> if (urj_big_endian)
> {
> data |= b[bidx++];
> data <<= 8;
> }
> else
> data |= (b[bidx++] << ((step - j) * 8));
> bc--;
> }
> it should move "data <<= 8;" before "data |= b[bidx++];", or else, it cause
> one byte overflow.
> the correct code should be:
>
> /* Write a word at a time */
> data = 0;
> for (j = step; j > 0 && bc > 0; j--)
> {
> if (urj_big_endian)
> {
> data <<= 8;
> data |= b[bidx++];
> }
> else
> data |= (b[bidx++] << ((step - j) * 8));
> bc--;
> }
Hmmm. I don't see the bug. After the loop, variable data points past the
array, but that is no problem because it is not accessed. In your fix,
the first byte of data is not written.
Rutger
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now. http://p.sf.net/sfu/bobj-july
_______________________________________________
UrJTAG-development mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/urjtag-development