lib/mpi: mpi_write_sgl(): fix style issue with lzero decrement
authorNicolai Stange <nicstange@gmail.com>
Tue, 22 Mar 2016 12:12:36 +0000 (13:12 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Tue, 5 Apr 2016 12:35:46 +0000 (20:35 +0800)
Within the copying loop in mpi_write_sgl(), we have

  if (lzeros > 0) {
    ...
    lzeros -= sizeof(alimb);
  }

However, at this point, lzeros < sizeof(alimb) holds. Make this fact
explicit by rewriting the above to

  if (lzeros) {
    ...
    lzeros = 0;
  }

Signed-off-by: Nicolai Stange <nicstange@gmail.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
lib/mpi/mpicoder.c

index 6bb52beb06b03e9a9d706704e0e1f033ed1174da..d8b372b9cc11025355f71123ad436e7cb99679f3 100644 (file)
@@ -402,14 +402,14 @@ int mpi_write_to_sgl(MPI a, struct scatterlist *sgl, unsigned *nbytes,
 #else
 #error please implement for this limb size.
 #endif
-               if (lzeros > 0) {
+               if (lzeros) {
                        mpi_limb_t *limb1 = (void *)p - sizeof(alimb);
                        mpi_limb_t *limb2 = (void *)p - sizeof(alimb)
                                + lzeros;
                        *limb1 = *limb2;
                        p -= lzeros;
                        y = lzeros;
-                       lzeros -= sizeof(alimb);
+                       lzeros = 0;
                }
 
                p = p - (sizeof(alimb) - y);