From 895d1eb539e81e7a14ef70bbfa740e90677f051d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Wed, 29 Mar 2017 18:07:03 +0200 Subject: [PATCH] Constify where possible. --- include/cryb/mpi.h | 16 ++++++++-------- lib/mpi/cryb_mpi_add.c | 2 +- lib/mpi/cryb_mpi_add_abs.c | 2 +- lib/mpi/cryb_mpi_cmp.c | 2 +- lib/mpi/cryb_mpi_cmp_abs.c | 2 +- lib/mpi/cryb_mpi_eq.c | 2 +- lib/mpi/cryb_mpi_eq_abs.c | 2 +- lib/mpi/cryb_mpi_sub.c | 2 +- lib/mpi/cryb_mpi_sub_abs.c | 4 ++-- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/include/cryb/mpi.h b/include/cryb/mpi.h index 9ef8147..84c7bf3 100644 --- a/include/cryb/mpi.h +++ b/include/cryb/mpi.h @@ -82,14 +82,14 @@ int mpi_load(cryb_mpi *, const uint8_t *, size_t); int mpi_set(cryb_mpi *, int32_t); int mpi_lshift(cryb_mpi *, unsigned int); int mpi_rshift(cryb_mpi *, unsigned int); -int mpi_add_abs(cryb_mpi *, cryb_mpi *, cryb_mpi *); -int mpi_add(cryb_mpi *, cryb_mpi *, cryb_mpi *); -int mpi_sub_abs(cryb_mpi *, cryb_mpi *, cryb_mpi *); -int mpi_sub(cryb_mpi *, cryb_mpi *, cryb_mpi *); -int mpi_cmp_abs(cryb_mpi *, cryb_mpi *); -int mpi_cmp(cryb_mpi *, cryb_mpi *); -int mpi_eq_abs(cryb_mpi *, cryb_mpi *); -int mpi_eq(cryb_mpi *, cryb_mpi *); +int mpi_add_abs(cryb_mpi *, const cryb_mpi *, const cryb_mpi *); +int mpi_add(cryb_mpi *, const cryb_mpi *, const cryb_mpi *); +int mpi_sub_abs(cryb_mpi *, const cryb_mpi *, const cryb_mpi *); +int mpi_sub(cryb_mpi *, const cryb_mpi *, const cryb_mpi *); +int mpi_cmp_abs(const cryb_mpi *, const cryb_mpi *); +int mpi_cmp(const cryb_mpi *, const cryb_mpi *); +int mpi_eq_abs(const cryb_mpi *, const cryb_mpi *); +int mpi_eq(const cryb_mpi *, const cryb_mpi *); CRYB_END diff --git a/lib/mpi/cryb_mpi_add.c b/lib/mpi/cryb_mpi_add.c index cb3e7c6..9cec071 100644 --- a/lib/mpi/cryb_mpi_add.c +++ b/lib/mpi/cryb_mpi_add.c @@ -40,7 +40,7 @@ * Add two numbers together. */ int -mpi_add(cryb_mpi *X, cryb_mpi *A, cryb_mpi *B) +mpi_add(cryb_mpi *X, const cryb_mpi *A, const cryb_mpi *B) { if (A->neg && B->neg) { diff --git a/lib/mpi/cryb_mpi_add_abs.c b/lib/mpi/cryb_mpi_add_abs.c index 5562264..3d3e2c1 100644 --- a/lib/mpi/cryb_mpi_add_abs.c +++ b/lib/mpi/cryb_mpi_add_abs.c @@ -40,7 +40,7 @@ * Store the sum of the absolutes values of A and B in X. */ int -mpi_add_abs(cryb_mpi *X, cryb_mpi *A, cryb_mpi *B) +mpi_add_abs(cryb_mpi *X, const cryb_mpi *A, const cryb_mpi *B) { unsigned int i; uint32_t c; diff --git a/lib/mpi/cryb_mpi_cmp.c b/lib/mpi/cryb_mpi_cmp.c index 9a20bff..3ce516b 100644 --- a/lib/mpi/cryb_mpi_cmp.c +++ b/lib/mpi/cryb_mpi_cmp.c @@ -41,7 +41,7 @@ * Compare signed values */ int -mpi_cmp(cryb_mpi *X, cryb_mpi *Y) +mpi_cmp(const cryb_mpi *X, const cryb_mpi *Y) { if (X->neg) { diff --git a/lib/mpi/cryb_mpi_cmp_abs.c b/lib/mpi/cryb_mpi_cmp_abs.c index 55fda43..58d0f9d 100644 --- a/lib/mpi/cryb_mpi_cmp_abs.c +++ b/lib/mpi/cryb_mpi_cmp_abs.c @@ -41,7 +41,7 @@ * Compare absolute values */ int -mpi_cmp_abs(cryb_mpi *X, cryb_mpi *Y) +mpi_cmp_abs(const cryb_mpi *X, const cryb_mpi *Y) { int i; diff --git a/lib/mpi/cryb_mpi_eq.c b/lib/mpi/cryb_mpi_eq.c index 07c784a..359447f 100644 --- a/lib/mpi/cryb_mpi_eq.c +++ b/lib/mpi/cryb_mpi_eq.c @@ -41,7 +41,7 @@ * Compare signed values for equality */ int -mpi_eq(cryb_mpi *A, cryb_mpi *B) +mpi_eq(const cryb_mpi *A, const cryb_mpi *B) { return (A->neg == B->neg && A->msb == B->msb && diff --git a/lib/mpi/cryb_mpi_eq_abs.c b/lib/mpi/cryb_mpi_eq_abs.c index 64b1c17..8f98935 100644 --- a/lib/mpi/cryb_mpi_eq_abs.c +++ b/lib/mpi/cryb_mpi_eq_abs.c @@ -41,7 +41,7 @@ * Compare absolute values for equality */ int -mpi_eq_abs(cryb_mpi *A, cryb_mpi *B) +mpi_eq_abs(const cryb_mpi *A, const cryb_mpi *B) { return (A->msb == B->msb && diff --git a/lib/mpi/cryb_mpi_sub.c b/lib/mpi/cryb_mpi_sub.c index 40074a6..88db1ba 100644 --- a/lib/mpi/cryb_mpi_sub.c +++ b/lib/mpi/cryb_mpi_sub.c @@ -40,7 +40,7 @@ * Subtract one number from another. */ int -mpi_sub(cryb_mpi *X, cryb_mpi *A, cryb_mpi *B) +mpi_sub(cryb_mpi *X, const cryb_mpi *A, const cryb_mpi *B) { if (A->neg && B->neg) { diff --git a/lib/mpi/cryb_mpi_sub_abs.c b/lib/mpi/cryb_mpi_sub_abs.c index 32d950f..7335be9 100644 --- a/lib/mpi/cryb_mpi_sub_abs.c +++ b/lib/mpi/cryb_mpi_sub_abs.c @@ -40,9 +40,9 @@ * Store the difference between the absolute values of A and B in X. */ int -mpi_sub_abs(cryb_mpi *X, cryb_mpi *A, cryb_mpi *B) +mpi_sub_abs(cryb_mpi *X, const cryb_mpi *A, const cryb_mpi *B) { - cryb_mpi *L, *G; + const cryb_mpi *L, *G; unsigned int i; uint32_t c, cn;