Skip to content

Commit

Permalink
lib/mpi: mpi_write_sgl(): purge redundant pointer arithmetic
Browse files Browse the repository at this point in the history
Within the copying loop in mpi_write_sgl(), we have

  if (lzeros) {
    ...
    p -= lzeros;
    y = lzeros;
  }
  p = p - (sizeof(alimb) - y);

If lzeros == 0, then y == 0, too. Thus, lzeros gets subtracted and added
back again to p.

Purge this redundancy.

Signed-off-by: Nicolai Stange <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
nicstange authored and herbertx committed Apr 5, 2016
1 parent 654842e commit ea122be
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/mpi/mpicoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,12 +407,11 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes,
mpi_limb_t *limb2 = (void *)p - sizeof(alimb)
+ lzeros;
*limb1 = *limb2;
p -= lzeros;
y = lzeros;
lzeros = 0;
}

p = p - (sizeof(alimb) - y);
p = p - sizeof(alimb);

for (x = 0; x < sizeof(alimb) - y; x++) {
if (!buf_len) {
Expand Down

0 comments on commit ea122be

Please sign in to comment.