Skip to content

Commit 0a1c5fb

Browse files
committed
fix some warnings
1 parent 65e3802 commit 0a1c5fb

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

fio-stl.h

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2768,23 +2768,23 @@ uint64_t fio___math_mod_expo(uint64_t base, uint64_t exp, uint64_t mod) {
27682768
return result;
27692769
}
27702770

2771-
#ifndef FIO_PRIME_TABLE_SIZE
2772-
#define FIO_PRIME_TABLE_SIZE 128
2771+
#ifndef FIO_PRIME_TABLE_LIMIT
2772+
#define FIO_PRIME_TABLE_LIMIT 1024
27732773
#endif
27742774
/* Perform sieve prime test - deterministic. */
27752775
FIO_SFUNC bool fio___is_prime_table(size_t n) {
2776-
FIO_ASSERT_DEBUG(n < (FIO_PRIME_TABLE_SIZE << 3));
2777-
uint64_t primes[(FIO_PRIME_TABLE_SIZE >> 3)];
2776+
FIO_ASSERT_DEBUG(n < FIO_PRIME_TABLE_LIMIT);
2777+
uint64_t primes[((FIO_PRIME_TABLE_LIMIT + 63) >> 6)];
27782778
for (size_t i = 0; i < (sizeof(primes) / sizeof(primes[0])); ++i)
27792779
primes[i] = ~(uint64_t)0;
27802780
fio_bit_unset(primes, 0);
2781-
for (size_t i = 2; i < (FIO_PRIME_TABLE_SIZE << 3); ++i) {
2781+
for (size_t i = 2; i < FIO_PRIME_TABLE_LIMIT; ++i) {
27822782
if (!fio_bit_get(primes, i))
27832783
continue;
2784-
for (size_t j = i * i; j < (FIO_PRIME_TABLE_SIZE << 3); j += i)
2784+
for (size_t j = i * i; j < FIO_PRIME_TABLE_LIMIT; j += i)
27852785
fio_bit_unset(primes, j);
27862786
}
2787-
return primes[n];
2787+
return fio_bit_get(primes, n);
27882788
}
27892789

27902790
/* Perform the Miller-Rabin test - probabilistic. */
@@ -2833,7 +2833,7 @@ FIO_SFUNC bool fio_math_is_uprime(uint64_t n) {
28332833
return 1; // 2 and 3 are prime
28342834
if (!(n & 1))
28352835
return 0; // even numbers other than 2 aren't primes
2836-
if (n < (FIO_PRIME_TABLE_SIZE << 3))
2836+
if (n < (FIO_PRIME_TABLE_LIMIT))
28372837
return fio___is_prime_table(n);
28382838
return fio___is_prime_maybe(n, 10);
28392839
}
@@ -2843,10 +2843,8 @@ FIO_SFUNC bool fio_math_is_uprime(uint64_t n) {
28432843
*
28442844
* For numbers up to 1023 this is deterministic.
28452845
*/
2846-
FIO_SFUNC bool fio_math_is_prime(int64_t n) {
2847-
if (n < 0)
2848-
return fio_math_is_uprime((uint64_t)(0LL - n));
2849-
return fio_math_is_uprime(n);
2846+
FIO_IFUNC bool fio_math_is_iprime(int64_t n) {
2847+
return fio_math_is_uprime((n < 0) ? (uint64_t)(0LL - n) : (uint64_t)n);
28502848
}
28512849

28522850
/* *****************************************************************************
@@ -30001,7 +29999,7 @@ FIO_IFUNC uint32_t FIO_NAME(FIO_MAP_NAME,
3000129999
reallocate_map:
3000230000
/* reallocate map */
3000330001
for (size_t i = 1; i < 3; ++i) {
30004-
if (FIO_NAME(FIO_MAP_NAME, __allocate_map)(&tmp, o->bits + i))
30002+
if (FIO_NAME(FIO_MAP_NAME, __allocate_map)(&tmp, (uint32_t)(o->bits + i)))
3000530003
goto no_memory;
3000630004
if (FIO_NAME(FIO_MAP_NAME, __move2map)(&tmp, o)) {
3000730005
FIO_NAME(FIO_MAP_NAME, __free_map)(&tmp, 0);
@@ -43757,7 +43755,7 @@ SFUNC int fio_http_cookie_set FIO_NOOP(fio_http_s *h,
4375743755
return -1;
4375843756
/* promises that some warnings print only once. */
4375943757
static unsigned int warn_illegal = 0;
43760-
unsigned int need2warn = 0;
43758+
size_t need2warn = 0;
4376143759

4376243760
/* valid / invalid characters in cookies, create with Ruby using:
4376343761
a = []

fio-stl/000 core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2807,7 +2807,7 @@ FIO_SFUNC bool fio_math_is_uprime(uint64_t n) {
28072807
* For numbers up to 1023 this is deterministic.
28082808
*/
28092809
FIO_IFUNC bool fio_math_is_iprime(int64_t n) {
2810-
return fio_math_is_uprime((n < 0) ? (uint64_t)(0LL - n) : n);
2810+
return fio_math_is_uprime((n < 0) ? (uint64_t)(0LL - n) : (uint64_t)n);
28112811
}
28122812

28132813
/* *****************************************************************************

fio-stl/210 map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@ FIO_IFUNC uint32_t FIO_NAME(FIO_MAP_NAME,
12851285
reallocate_map:
12861286
/* reallocate map */
12871287
for (size_t i = 1; i < 3; ++i) {
1288-
if (FIO_NAME(FIO_MAP_NAME, __allocate_map)(&tmp, o->bits + i))
1288+
if (FIO_NAME(FIO_MAP_NAME, __allocate_map)(&tmp, (uint32_t)(o->bits + i)))
12891289
goto no_memory;
12901290
if (FIO_NAME(FIO_MAP_NAME, __move2map)(&tmp, o)) {
12911291
FIO_NAME(FIO_MAP_NAME, __free_map)(&tmp, 0);

fio-stl/431 http handle.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1875,7 +1875,7 @@ SFUNC int fio_http_cookie_set FIO_NOOP(fio_http_s *h,
18751875
return -1;
18761876
/* promises that some warnings print only once. */
18771877
static unsigned int warn_illegal = 0;
1878-
unsigned int need2warn = 0;
1878+
size_t need2warn = 0;
18791879

18801880
/* valid / invalid characters in cookies, create with Ruby using:
18811881
a = []

0 commit comments

Comments
 (0)