Fix wrong use of uLL suffix

This commit is contained in:
Jan Nijtmans 2019-11-06 11:29:17 +01:00 committed by Steffen Jaeckel
parent 83b74bac6e
commit 02aa95c2b5
No known key found for this signature in database
GPG Key ID: AF0CB17621EDAD72
5 changed files with 28 additions and 28 deletions

View File

@ -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);

View File

@ -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) {

View File

@ -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' \

View File

@ -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;
}

View File

@ -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;
}
}