File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 6
6
/* shrink a bignum */
7
7
mp_err mp_shrink (mp_int * a )
8
8
{
9
- static int static_check [- (MP_PREC < MP_MIN_PREC )];
10
9
mp_digit * tmp ;
11
10
int alloc = MP_MAX (MP_MIN_PREC , a -> used );
12
- (void )static_check ;
13
11
if (a -> alloc != alloc ) {
14
12
if ((tmp = (mp_digit * ) MP_REALLOC (a -> dp ,
15
13
(size_t )a -> alloc * sizeof (mp_digit ),
Original file line number Diff line number Diff line change @@ -151,6 +151,9 @@ typedef private_mp_word mp_word;
151
151
#define MP_MIN (x , y ) (((x) < (y)) ? (x) : (y))
152
152
#define MP_MAX (x , y ) (((x) > (y)) ? (x) : (y))
153
153
154
+ /* Static assertion */
155
+ #define MP_STATIC_ASSERT (msg , cond ) typedef char mp_static_assert_##msg[-(!(cond))];
156
+
154
157
/* ---> Basic Manipulations <--- */
155
158
#define MP_IS_ZERO (a ) ((a)->used == 0)
156
159
#define MP_IS_EVEN (a ) (((a)->used == 0) || (((a)->dp[0] & 1u) == 0u))
@@ -162,6 +165,8 @@ typedef private_mp_word mp_word;
162
165
/* Minimum number of available digits in mp_int, MP_PREC >= MP_MIN_PREC */
163
166
#define MP_MIN_PREC ((((CHAR_BIT * (int)sizeof(long long)) + MP_DIGIT_BIT) - 1) / MP_DIGIT_BIT)
164
167
168
+ MP_STATIC_ASSERT (prec_geq_min_prec , MP_PREC >= MP_MIN_PREC )
169
+
165
170
/* random number source */
166
171
extern MP_PRIVATE mp_err (* s_mp_rand_source )(void * out , size_t size );
167
172
You can’t perform that action at this time.
0 commit comments