Jim Meyering wrote:
> +  set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
> +  set_uint32 (r + 1 * sizeof ctx->B, SWAP (ctx->B));
> +  set_uint32 (r + 2 * sizeof ctx->C, SWAP (ctx->C));
> +  set_uint32 (r + 3 * sizeof ctx->D, SWAP (ctx->D));

Now this is confusing. If you assume that A, B, C, D all have the same
size, then it's simpler (more symmetry) to write:

     set_uint32 (r + 0 * sizeof ctx->A, SWAP (ctx->A));
     set_uint32 (r + 1 * sizeof ctx->A, SWAP (ctx->B));
     set_uint32 (r + 2 * sizeof ctx->A, SWAP (ctx->C));
     set_uint32 (r + 3 * sizeof ctx->A, SWAP (ctx->D));

If you don't want to assume this, then the code above is incorrect (it
stores the second element at offset sizeof(B) but should store it at the
offset sizeof(A), etc.) and should be corrected like this:

     set_uint32 (r, SWAP (ctx->A));
     set_uint32 (r + sizeof ctx->A, SWAP (ctx->B));
     set_uint32 (r + sizeof ctx->A + sizeof ctx->B, SWAP (ctx->C));
     set_uint32 (r + sizeof ctx->A + sizeof ctx->B + sizeof ctx->C, SWAP 
(ctx->D));

Bruno



Reply via email to