Fix wrong use of uLL suffix
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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
diff --git a/demo/test.c b/demo/test.c
index f153509..1c86429 100644
--- a/demo/test.c
+++ b/demo/test.c
@@ -223,9 +223,9 @@ static int test_mp_get_set_i64(void)
DOR(mp_init(&a));
- check_get_set_i64(&a, 0LL);
- check_get_set_i64(&a, -1LL);
- check_get_set_i64(&a, 1LL);
+ check_get_set_i64(&a, (int64_t)0);
+ check_get_set_i64(&a, (int64_t)-1);
+ check_get_set_i64(&a, (int64_t)1);
check_get_set_i64(&a, INT64_MIN);
check_get_set_i64(&a, INT64_MAX);
@@ -683,26 +683,26 @@ LBL_ERR:
static int test_mp_get_u64(void)
{
- unsigned long long q, r;
+ uint64_t q, r;
int i;
mp_int a, b;
DOR(mp_init_multi(&a, &b, NULL));
- for (i = 0; i < (int)(MP_SIZEOF_BITS(unsigned long long) - 1); ++i) {
- r = (1ULL << (i+1)) - 1;
+ for (i = 0; i < (int)(MP_SIZEOF_BITS(uint64_t) - 1); ++i) {
+ r = (UINT64_C(1) << (i+1)) - 1;
if (!r)
- r = ~0ULL;
- printf(" r = 0x%llx i = %d\r", r, i);
+ r = UINT64_MAX;
+ printf(" r = 0x%" PRIx64 " i = %d\r", r, i);
do {
mp_set_u64(&a, r);
q = mp_get_u64(&a);
if (q != r) {
- printf("\nmp_get_u64() bad result! 0x%llx != 0x%llx", q, r);
+ printf("\nmp_get_u64() bad result! 0x%" PRIx64 " != 0x%" PRIx64, q, r);
goto LBL_ERR;
}
r <<= 1;
- } while (r != 0uLL);
+ } while (r != 0u);
}
mp_clear_multi(&a, &b, NULL);
@@ -2177,7 +2177,7 @@ static int test_mp_read_write_ubin(void)
size = mp_ubin_size(&a);
printf("mp_to_ubin_size %zu - ", size);
- buf = malloc(sizeof(*buf) * size);
+ buf = (unsigned char *)malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (u) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2215,7 +2215,7 @@ static int test_mp_read_write_sbin(void)
size = mp_sbin_size(&a);
printf("mp_to_sbin_size %zu - ", size);
- buf = malloc(sizeof(*buf) * size);
+ buf = (unsigned char *)malloc(sizeof(*buf) * size);
if (buf == NULL) {
fprintf(stderr, "test_read_write_binaries (s) failed to allocate %zu bytes\n",
sizeof(*buf) * size);
@@ -2255,7 +2255,7 @@ static int test_mp_pack_unpack(void)
count = mp_pack_count(&a, 0uL, 1uL);
- buf = malloc(count);
+ buf = (unsigned char *)malloc(count);
if (buf == NULL) {
fprintf(stderr, "test_pack_unpack failed to allocate\n");
goto LBL_ERR;
@@ -2346,7 +2346,7 @@ static int unit_tests(int argc, char **argv)
ok = fail = nop = 0;
t = (uint64_t)time(NULL);
- printf("SEED: 0x%"PRIx64"\n\n", t);
+ printf("SEED: 0x%" PRIx64 "\n\n", t);
s_mp_rand_jenkins_init(t);
mp_rand_source(s_mp_rand_jenkins);
diff --git a/etc/tune.c b/etc/tune.c
index 0b73734..9c41e39 100644
--- a/etc/tune.c
+++ b/etc/tune.c
@@ -93,7 +93,7 @@ static uint64_t s_time_mul(int size)
}
if (mp_cmp(&c, &d) != MP_EQ) {
/* Time of 0 cannot happen (famous last words?) */
- t1 = 0uLL;
+ t1 = 0u;
goto LBL_ERR;
}
}
@@ -134,7 +134,7 @@ static uint64_t s_time_sqr(int size)
goto LBL_ERR;
}
if (mp_cmp(&c, &b) != MP_EQ) {
- t1 = 0uLL;
+ t1 = 0u;
goto LBL_ERR;
}
}
@@ -166,16 +166,16 @@ static void s_run(const char *name, uint64_t (*op)(int size), int *cutoff)
for (x = 8; x < args.upper_limit_print; x += args.increment_print) {
*cutoff = INT_MAX;
t1 = op(x);
- if ((t1 == 0uLL) || (t1 == UINT64_MAX)) {
+ if ((t1 == 0u) || (t1 == UINT64_MAX)) {
fprintf(stderr,"%s failed at x = INT_MAX (%s)\n", name,
- (t1 == 0uLL)?"wrong result":"internal error");
+ (t1 == 0u)?"wrong result":"internal error");
exit(EXIT_FAILURE);
}
*cutoff = x;
t2 = op(x);
- if ((t2 == 0uLL) || (t2 == UINT64_MAX)) {
+ if ((t2 == 0u) || (t2 == UINT64_MAX)) {
fprintf(stderr,"%s failed (%s)\n", name,
- (t2 == 0uLL)?"wrong result":"internal error");
+ (t2 == 0u)?"wrong result":"internal error");
exit(EXIT_FAILURE);
}
if (args.verbose == 1) {
diff --git a/makefile b/makefile
index 1ce63ee..f0ff233 100644
--- a/makefile
+++ b/makefile
@@ -162,8 +162,8 @@ c89:
-e 's/bool/mp_bool/g' \
-e 's/true/MP_YES/g' \
-e 's/false/MP_NO/g' \
- -e 's/UINT32_MAX/0xFFFFFFFFU/g' \
- -e 's/UINT64_MAX/0xFFFFFFFFFFFFFFFFULL/g' \
+ -e 's/UINT32_MAX/0xFFFFFFFFu/g' \
+ -e 's/UINT64_MAX/0xFFFFFFFFFFFFFFFFuLL/g' \
-e 's/INT32_MAX/2147483647/g' \
-e 's/INT32_MIN/(-2147483647-1)/g' \
-e 's/INT64_MAX/((mp_i64)9223372036854775807LL)/g' \
@@ -184,8 +184,8 @@ c99:
-e 's/MP_YES/true/g' \
-e 's/MP_NO/false/g' \
-e 's/false_/MP_NO_/g' \
- -e 's/0xFFFFFFFFU/UINT32_MAX/g' \
- -e 's/0xFFFFFFFFFFFFFFFFULL/UINT64_MAX/g' \
+ -e 's/0xFFFFFFFFu/UINT32_MAX/g' \
+ -e 's/0xFFFFFFFFFFFFFFFFuLL/UINT64_MAX/g' \
-e 's/(-2147483647-1)/INT32_MIN/g' \
-e 's/2147483647/INT32_MAX/g' \
-e 's/((mp_i64)-9223372036854775807LL-1)/INT64_MIN/g' \
diff --git a/mp_set_double.c b/mp_set_double.c
index 467d7fd..ca46083 100644
--- a/mp_set_double.c
+++ b/mp_set_double.c
@@ -16,7 +16,7 @@ mp_err mp_set_double(mp_int *a, double b)
cast.dbl = b;
exp = (int)((unsigned)(cast.bits >> 52) & 0x7FFu);
- frac = (cast.bits & ((1uLL << 52) - 1uLL)) | (1uLL << 52);
+ frac = (cast.bits & ((UINT64_C(1) << 52) - UINT64_C(1))) | (UINT64_C(1) << 52);
if (exp == 0x7FF) { /* +-inf, NaN */
return MP_VAL;
@@ -30,7 +30,7 @@ mp_err mp_set_double(mp_int *a, double b)
return err;
}
- if (((cast.bits >> 63) != 0uLL) && !mp_iszero(a)) {
+ if (((cast.bits >> 63) != 0u) && !mp_iszero(a)) {
a->sign = MP_NEG;
}
diff --git a/s_mp_rand_jenkins.c b/s_mp_rand_jenkins.c
index 3a905ba..4bb520c 100644
--- a/s_mp_rand_jenkins.c
+++ b/s_mp_rand_jenkins.c
@@ -28,7 +28,7 @@ static uint64_t s_rand_jenkins_val(void)
void s_mp_rand_jenkins_init(uint64_t seed)
{
int i;
- jenkins_x.a = 0xF1EA5EEDuLL;
+ jenkins_x.a = (uint64_t)0xF1EA5EEDuL;
jenkins_x.b = jenkins_x.c = jenkins_x.d = seed;
for (i = 0; i < 20; ++i) {
(void)s_rand_jenkins_val();
@@ -42,7 +42,7 @@ mp_err s_mp_rand_jenkins(void *p, size_t n)
int i;
uint64_t x = s_rand_jenkins_val();
for (i = 0; (i < 8) && (n > 0u); ++i, --n) {
- *q++ = (char)(x & 0xFFuLL);
+ *q++ = (char)(x & (uint64_t)0xFFu);
x >>= 8;
}
}