Skip to content

Commit

Permalink
lib/mpi: mpi_read_raw_from_sgl(): replace len argument by nbytes
Browse files Browse the repository at this point in the history
Currently, the nbytes local variable is calculated from the len argument
as follows:

  ... mpi_read_raw_from_sgl(..., unsigned int len)
  {
    unsigned nbytes;
    ...
    if (!ents)
      nbytes = 0;
    else
      nbytes = len - lzeros;
    ...
  }

Given that nbytes is derived from len in a trivial way and that the len
argument is shadowed by a local len variable in several loops, this is just
confusing.

Rename the len argument to nbytes and get rid of the nbytes local variable.
Do the nbytes calculation in place.

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 462696f commit b698538
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/mpi/mpicoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -418,15 +418,15 @@ EXPORT_SYMBOL_GPL(mpi_write_to_sgl);
* a new MPI and reads the content of the sgl to the MPI.
*
* @sgl: scatterlist to read from
* @len: number of bytes to read
* @nbytes: number of bytes to read
*
* Return: Pointer to a new MPI or NULL on error
*/
MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len)
MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int nbytes)
{
struct scatterlist *sg;
int x, i, j, z, lzeros, ents;
unsigned int nbits, nlimbs, nbytes;
unsigned int nbits, nlimbs;
mpi_limb_t a;
MPI val = NULL;

Expand Down Expand Up @@ -455,7 +455,7 @@ MPI mpi_read_raw_from_sgl(struct scatterlist *sgl, unsigned int len)
if (!ents)
nbytes = 0;
else
nbytes = len - lzeros;
nbytes -= lzeros;

nbits = nbytes * 8;
if (nbits > MAX_EXTERN_MPI_BITS) {
Expand Down

0 comments on commit b698538

Please sign in to comment.