fix type & cast
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
diff --git a/demo/demo.c b/demo/demo.c
index 357d26e..4f32072 100644
--- a/demo/demo.c
+++ b/demo/demo.c
@@ -264,7 +264,7 @@ int main(void)
// test mp_get_int
printf("\n\nTesting: mp_get_int");
for (i = 0; i < 1000; ++i) {
- t = ((unsigned long) rand() * rand() + 1) & 0xFFFFFFFFuL;
+ t = (unsigned long)(rand() * rand() + 1) & 0xFFFFFFFFuL;
mp_set_int(&a, t);
if (t != mp_get_int(&a)) {
printf("\nmp_get_int() bad result!");
diff --git a/demo/timing.c b/demo/timing.c
index 2b4f30f..d22e471 100644
--- a/demo/timing.c
+++ b/demo/timing.c
@@ -34,14 +34,14 @@ static void draw(mp_int *a)
static unsigned long lfsr = 0xAAAAAAAAuL;
-static int lbit(void)
+static unsigned int lbit(void)
{
if ((lfsr & 0x80000000uL) != 0uL) {
lfsr = ((lfsr << 1) ^ 0x8000001BuL) & 0xFFFFFFFFuL;
- return 1;
+ return 1u;
} else {
lfsr <<= 1;
- return 0;
+ return 0u;
}
}
diff --git a/etc/2kprime.c b/etc/2kprime.c
index 803ece7..a43e1b4 100644
--- a/etc/2kprime.c
+++ b/etc/2kprime.c
@@ -7,7 +7,8 @@ static int sizes[] = {256, 512, 768, 1024, 1536, 2048, 3072, 4096};
int main(void)
{
char buf[2000];
- int x, y;
+ size_t x;
+ int y;
mp_int q, p;
FILE *out;
clock_t t1;
@@ -17,7 +18,7 @@ int main(void)
out = fopen("2kprime.1", "w");
if (out != NULL) {
- for (x = 0; x < (int)(sizeof(sizes) / sizeof(sizes[0])); x++) {
+ for (x = 0; x < (sizeof(sizes) / sizeof(sizes[0])); x++) {
top:
mp_2expt(&q, sizes[x]);
mp_add_d(&q, 3uL, &q);
diff --git a/etc/mersenne.c b/etc/mersenne.c
index 6e4759b..23420fd 100644
--- a/etc/mersenne.c
+++ b/etc/mersenne.c
@@ -21,7 +21,7 @@ static int is_mersenne(long s, int *pp)
}
/* n = 2^s - 1 */
- if ((res = mp_2expt(&n, s)) != MP_OKAY) {
+ if ((res = mp_2expt(&n, (int)s)) != MP_OKAY) {
goto LBL_MU;
}
if ((res = mp_sub_d(&n, 1uL, &n)) != MP_OKAY) {
diff --git a/etc/mont.c b/etc/mont.c
index 97b36e1..eb1a714 100644
--- a/etc/mont.c
+++ b/etc/mont.c
@@ -6,14 +6,14 @@ int main(void)
{
mp_int modulus, R, p, pp;
mp_digit mp;
- long x, y;
+ int x, y;
srand(time(NULL));
mp_init_multi(&modulus, &R, &p, &pp, NULL);
/* loop through various sizes */
for (x = 4; x < 256; x++) {
- printf("DIGITS == %3ld...", x);
+ printf("DIGITS == %3d...", x);
fflush(stdout);
/* make up the odd modulus */