mpilib: use DIV_ROUN_UP macro
PATCH 1/1 mpilib: use DIV_ROUN_UP macro
And remove MIN, MAX and ABS macros that are duplicates kernel's native implementation.
Signed-off-by Andy Shevchenko <[email protected]>
--- lib/digsig.c | 3 ++- lib/mpi/mpi-internal.h | 4 ---- lib/mpi/mpicoder.c | 4 ++-- 3 files changed, 4 insertions(+), 7 deletions(-)
lib/digsig.c +2 -1
@@ -27,6 +27,7 @@#include <keys/user-type.h> #include <linux/mpi.h> #include <linux/digsig.h> +#include <linux/kernel.h> static struct crypto_shash *shash;
@@ -120,7 +121,7 @@ static int digsig_verify_rsa(struct key *key, } mblen =mpi_get_nbits (pkey[0 ]); - mlen = (mblen +7 )/8 ; + mlen =DIV_ROUND_UP (mblen,8 );if (mlen ==0 ) goto err;
lib/mpi/mpi-internal.h +0 -4
@@ -65,10 +65,6 @@typedef mpi_limb_t *mpi_ptr_t ;/* pointer to a limb */ typedef int mpi_size_t ;/* (must be a signed type) */ -#define ABS (x) (x >= 0 ? x : -x) -#define MIN (l, o) ((l) < (o) ? (l) : (o)) -#define MAX (h, i) ((h) > (i) ? (h) : (i)) -static inline int RESIZE_IF_NEEDED (MPI a,unsigned b) {if (a->alloced < b)
lib/mpi/mpicoder.c +2 -2
@@ -41,8 +41,8 @@ MPI mpi_read_from_buffer(const void *xbuffer, unsigned *ret_nread) buffer +=2 ; nread =2 ; - nbytes = (nbits +7 ) /8 ; - nlimbs = (nbytes +BYTES_PER_MPI_LIMB -1 ) /BYTES_PER_MPI_LIMB ; + nbytes =DIV_ROUND_UP (nbits,8 ); + nlimbs =DIV_ROUND_UP (nbytes,BYTES_PER_MPI_LIMB ); val =mpi_alloc (nlimbs);if (!val)return NULL ;
Signature · 1 line
1.7.10