Skip to content

Commit ce9568f

Browse files
committed
fix warnings and type concerns
1 parent 9ba7308 commit ce9568f

File tree

6 files changed

+56
-46
lines changed

6 files changed

+56
-46
lines changed

fio-stl.h

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,16 +1673,12 @@ FIO_IFUNC void fio_u2buf24_be(void *buf, uint32_t i) {
16731673
/** Converts an unaligned byte stream to a 24 bit number - local endieness. */
16741674
FIO_IFUNC uint32_t fio_buf2u24u(const void *c) { return fio_buf2u24_be(c); }
16751675
/** Writes a 24 bit number to an unaligned buffer - in local endieness. */
1676-
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) {
1677-
return fio_u2buf24_be(buf, i);
1678-
}
1676+
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) { fio_u2buf24_be(buf, i); }
16791677
#elif __LITTLE_ENDIAN__
16801678
/** Converts an unaligned byte stream to a 24 bit number - local endieness. */
16811679
FIO_IFUNC uint32_t fio_buf2u24u(const void *c) { return fio_buf2u24_le(c); }
16821680
/** Writes a 24 bit number to an unaligned buffer - in local endieness. */
1683-
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) {
1684-
return fio_u2buf24_le(buf, i);
1685-
}
1681+
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) { fio_u2buf24_le(buf, i); }
16861682
#else
16871683
#warning "Couldn't calculate local version for fio_buf2u24u and fio_u2buf24u"
16881684
#endif
@@ -16645,7 +16641,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout) {
1664516641
int active_count = epoll_wait(p->fds[0].fd, events, FIO_POLL_MAX_EVENTS, 0);
1664616642
if (active_count > 0) {
1664716643
/* TODO! fix error handling*/
16648-
for (size_t i = 0; i < active_count; i++) {
16644+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
1664916645
// errors are handled as disconnections (on_close) in the EPOLLIN queue
1665016646
// if no error, try an active event(s)
1665116647
if (events[i].events & EPOLLOUT)
@@ -16655,7 +16651,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout) {
1665516651
}
1665616652
active_count = epoll_wait(p->fds[1].fd, events, FIO_POLL_MAX_EVENTS, 0);
1665716653
if (active_count > 0) {
16658-
for (size_t i = 0; i < active_count; i++) {
16654+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
1665916655
// holds an active event(s)
1666016656
if (events[i].events & EPOLLIN)
1666116657
p->settings.on_data(events[i].data.ptr);
@@ -16813,7 +16809,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout_) {
1681316809
kevent(p->fd, NULL, 0, events, FIO_POLL_MAX_EVENTS, &timeout);
1681416810

1681516811
if (active_count > 0) {
16816-
for (size_t i = 0; i < active_count; i++) {
16812+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
1681716813
// test for event(s) type
1681816814
if ((events[i].filter & EVFILT_WRITE))
1681916815
p->settings.on_ready(events[i].udata);
@@ -24204,7 +24200,7 @@ Cleanup
2420424200

2420524201
Copyright and License: see header file (000 copyright.h) or top of file
2420624202
***************************************************************************** */
24207-
#if 0 && defined(FIO_ED25519) && !defined(H___FIO_ED25519___H)
24203+
#if defined(FIO_ED25519) && !defined(H___FIO_ED25519___H) && 0
2420824204
#define H___FIO_ED25519___H
2420924205

2421024206
/* *****************************************************************************
@@ -24222,7 +24218,7 @@ ED25519 API
2422224218
***************************************************************************** */
2422324219

2422424220
/** ED25519 Key Pair */
24225-
typedef struct {
24221+
typedef struct { /* TODO: FIXME: do we need all the bits? */
2422624222
fio_u512 private_key; /* Private key (with extra internal storage?) */
2422724223
fio_u256 public_key; /* Public key */
2422824224
} fio_ed25519_s;
@@ -24260,10 +24256,18 @@ FIO_IFUNC void fio___ed25519_clamp_on_key(uint8_t *k) {
2426024256
k[31] |= 0x40U; /* set the 255th bit (making sure the value is big) */
2426124257
}
2426224258

24263-
static fio_u256 FIO___ED25519_PRIME = fio_u256_init64(0x7FFFFFFFFFFFFFFF,
24264-
0xFFFFFFFFFFFFFFFF,
24265-
0xFFFFFFFFFFFFFFFF,
24266-
0xFFFFFFFFFFFFFFED);
24259+
static fio_u256 FIO___ED25519_PRIME = fio_u256_init64(0xFFFFFFFFFFFFFFEDULL,
24260+
0xFFFFFFFFFFFFFFFFULL,
24261+
0xFFFFFFFFFFFFFFFFULL,
24262+
0x7FFFFFFFFFFFFFFFULL);
24263+
/* clang-format off */
24264+
static fio_u1024 FIO___ED25519_PRIME_UNPACKED =
24265+
fio_u1024_init64(0xFFEDULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
24266+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
24267+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
24268+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0x7FFFULL);
24269+
/* clang-format on */
24270+
2426724271
/* Obfuscate or recover ED25519 keys to prevent easy memory scraping */
2426824272
FIO_IFUNC void fio___ed25519_flip(fio_ed25519_s *k) {
2426924273
/* Generate a deterministic mask */
@@ -24285,8 +24289,9 @@ FIO_IFUNC fio_u1024 fio___ed25519_unpack(uint8_t *u) {
2428524289
return r;
2428624290
}
2428724291

24288-
#define fio___ed25519_add fio_u1024_add64
24289-
#define fio___ed25519_sub fio_u1024_sub64
24292+
#define fio___ed25519_add fio_u1024_add64
24293+
#define fio___ed25519_sub fio_u1024_sub64
24294+
#define fio___ed25519_swap_if fio_u1024_ct_swap_if
2429024295

2429124296
FIO_IFUNC void fio___ed25519_normalize_step(fio_u1024 *u) {
2429224297
uint64_t c;
@@ -50798,23 +50803,23 @@ FIO_SFUNC void FIO_NAME_TEST(stl, core)(void) {
5079850803
}
5079950804
{
5080050805
fprintf(stderr, "* Testing popcount and hemming distance calculation.\n");
50801-
for (size_t i = 0; i < 64; ++i) {
50806+
for (int i = 0; i < 64; ++i) {
5080250807
FIO_ASSERT(fio_popcount((uint64_t)1 << i) == 1,
5080350808
"fio_popcount error for 1 bit");
5080450809
}
50805-
for (size_t i = 0; i < 63; ++i) {
50810+
for (int i = 0; i < 63; ++i) {
5080650811
FIO_ASSERT(fio_popcount((uint64_t)3 << i) == 2,
5080750812
"fio_popcount error for 2 bits");
5080850813
}
50809-
for (size_t i = 0; i < 62; ++i) {
50814+
for (int i = 0; i < 62; ++i) {
5081050815
FIO_ASSERT(fio_popcount((uint64_t)7 << i) == 3,
5081150816
"fio_popcount error for 3 bits");
5081250817
}
50813-
for (size_t i = 0; i < 59; ++i) {
50818+
for (int i = 0; i < 59; ++i) {
5081450819
FIO_ASSERT(fio_popcount((uint64_t)21 << i) == 3,
5081550820
"fio_popcount error for 3 alternating bits");
5081650821
}
50817-
for (size_t i = 0; i < 64; ++i) {
50822+
for (int i = 0; i < 64; ++i) {
5081850823
FIO_ASSERT(fio_hemming_dist(((uint64_t)1 << i) - 1, 0) == i,
5081950824
"fio_hemming_dist error at %d",
5082050825
i);
@@ -51069,7 +51074,7 @@ FIO_SFUNC void FIO_NAME_TEST(stl, core)(void) {
5106951074
fio_u256_mul(&result, &ua, &ub);
5107051075
FIO_ASSERT(!memcmp(result.u64, expected, sizeof(result.u64)),
5107151076
"Multi-Precision MUL error");
51072-
FIO_ASSERT(fio_u256_is_eq(&result, (fio_u256 *)&expected),
51077+
FIO_ASSERT(fio_u512_is_eq(&result, (fio_u512 *)&expected),
5107351078
"Multi-Precision MUL error (is_eq)");
5107451079
{
5107551080
fio_u512 cpy = result;

fio-stl/000 core.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1636,16 +1636,12 @@ FIO_IFUNC void fio_u2buf24_be(void *buf, uint32_t i) {
16361636
/** Converts an unaligned byte stream to a 24 bit number - local endieness. */
16371637
FIO_IFUNC uint32_t fio_buf2u24u(const void *c) { return fio_buf2u24_be(c); }
16381638
/** Writes a 24 bit number to an unaligned buffer - in local endieness. */
1639-
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) {
1640-
return fio_u2buf24_be(buf, i);
1641-
}
1639+
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) { fio_u2buf24_be(buf, i); }
16421640
#elif __LITTLE_ENDIAN__
16431641
/** Converts an unaligned byte stream to a 24 bit number - local endieness. */
16441642
FIO_IFUNC uint32_t fio_buf2u24u(const void *c) { return fio_buf2u24_le(c); }
16451643
/** Writes a 24 bit number to an unaligned buffer - in local endieness. */
1646-
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) {
1647-
return fio_u2buf24_le(buf, i);
1648-
}
1644+
FIO_IFUNC void fio_u2buf24u(void *buf, uint32_t i) { fio_u2buf24_le(buf, i); }
16491645
#else
16501646
#warning "Couldn't calculate local version for fio_buf2u24u and fio_u2buf24u"
16511647
#endif

fio-stl/102 poll epoll.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout) {
160160
int active_count = epoll_wait(p->fds[0].fd, events, FIO_POLL_MAX_EVENTS, 0);
161161
if (active_count > 0) {
162162
/* TODO! fix error handling*/
163-
for (size_t i = 0; i < active_count; i++) {
163+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
164164
// errors are handled as disconnections (on_close) in the EPOLLIN queue
165165
// if no error, try an active event(s)
166166
if (events[i].events & EPOLLOUT)
@@ -170,7 +170,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout) {
170170
}
171171
active_count = epoll_wait(p->fds[1].fd, events, FIO_POLL_MAX_EVENTS, 0);
172172
if (active_count > 0) {
173-
for (size_t i = 0; i < active_count; i++) {
173+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
174174
// holds an active event(s)
175175
if (events[i].events & EPOLLIN)
176176
p->settings.on_data(events[i].data.ptr);

fio-stl/102 poll kqueue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ SFUNC int fio_poll_review(fio_poll_s *p, size_t timeout_) {
138138
kevent(p->fd, NULL, 0, events, FIO_POLL_MAX_EVENTS, &timeout);
139139

140140
if (active_count > 0) {
141-
for (size_t i = 0; i < active_count; i++) {
141+
for (unsigned i = 0; i < (unsigned)active_count; i++) {
142142
// test for event(s) type
143143
if ((events[i].filter & EVFILT_WRITE))
144144
p->settings.on_ready(events[i].udata);

fio-stl/154 ed25519.h

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
1818
Copyright and License: see header file (000 copyright.h) or top of file
1919
***************************************************************************** */
20-
#if 0 && defined(FIO_ED25519) && !defined(H___FIO_ED25519___H)
20+
#if defined(FIO_ED25519) && !defined(H___FIO_ED25519___H) && 0
2121
#define H___FIO_ED25519___H
2222

2323
/* *****************************************************************************
@@ -35,7 +35,7 @@ ED25519 API
3535
***************************************************************************** */
3636

3737
/** ED25519 Key Pair */
38-
typedef struct {
38+
typedef struct { /* TODO: FIXME: do we need all the bits? */
3939
fio_u512 private_key; /* Private key (with extra internal storage?) */
4040
fio_u256 public_key; /* Public key */
4141
} fio_ed25519_s;
@@ -73,10 +73,18 @@ FIO_IFUNC void fio___ed25519_clamp_on_key(uint8_t *k) {
7373
k[31] |= 0x40U; /* set the 255th bit (making sure the value is big) */
7474
}
7575

76-
static fio_u256 FIO___ED25519_PRIME = fio_u256_init64(0x7FFFFFFFFFFFFFFF,
77-
0xFFFFFFFFFFFFFFFF,
78-
0xFFFFFFFFFFFFFFFF,
79-
0xFFFFFFFFFFFFFFED);
76+
static fio_u256 FIO___ED25519_PRIME = fio_u256_init64(0xFFFFFFFFFFFFFFEDULL,
77+
0xFFFFFFFFFFFFFFFFULL,
78+
0xFFFFFFFFFFFFFFFFULL,
79+
0x7FFFFFFFFFFFFFFFULL);
80+
/* clang-format off */
81+
static fio_u1024 FIO___ED25519_PRIME_UNPACKED =
82+
fio_u1024_init64(0xFFEDULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
83+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
84+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0xFFFFULL,
85+
0xFFFFULL, 0xFFFFULL, 0xFFFFULL, 0x7FFFULL);
86+
/* clang-format on */
87+
8088
/* Obfuscate or recover ED25519 keys to prevent easy memory scraping */
8189
FIO_IFUNC void fio___ed25519_flip(fio_ed25519_s *k) {
8290
/* Generate a deterministic mask */
@@ -98,8 +106,9 @@ FIO_IFUNC fio_u1024 fio___ed25519_unpack(uint8_t *u) {
98106
return r;
99107
}
100108

101-
#define fio___ed25519_add fio_u1024_add64
102-
#define fio___ed25519_sub fio_u1024_sub64
109+
#define fio___ed25519_add fio_u1024_add64
110+
#define fio___ed25519_sub fio_u1024_sub64
111+
#define fio___ed25519_swap_if fio_u1024_ct_swap_if
103112

104113
FIO_IFUNC void fio___ed25519_normalize_step(fio_u1024 *u) {
105114
uint64_t c;

fio-stl/902 core.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,23 +233,23 @@ FIO_SFUNC void FIO_NAME_TEST(stl, core)(void) {
233233
}
234234
{
235235
fprintf(stderr, "* Testing popcount and hemming distance calculation.\n");
236-
for (size_t i = 0; i < 64; ++i) {
236+
for (int i = 0; i < 64; ++i) {
237237
FIO_ASSERT(fio_popcount((uint64_t)1 << i) == 1,
238238
"fio_popcount error for 1 bit");
239239
}
240-
for (size_t i = 0; i < 63; ++i) {
240+
for (int i = 0; i < 63; ++i) {
241241
FIO_ASSERT(fio_popcount((uint64_t)3 << i) == 2,
242242
"fio_popcount error for 2 bits");
243243
}
244-
for (size_t i = 0; i < 62; ++i) {
244+
for (int i = 0; i < 62; ++i) {
245245
FIO_ASSERT(fio_popcount((uint64_t)7 << i) == 3,
246246
"fio_popcount error for 3 bits");
247247
}
248-
for (size_t i = 0; i < 59; ++i) {
248+
for (int i = 0; i < 59; ++i) {
249249
FIO_ASSERT(fio_popcount((uint64_t)21 << i) == 3,
250250
"fio_popcount error for 3 alternating bits");
251251
}
252-
for (size_t i = 0; i < 64; ++i) {
252+
for (int i = 0; i < 64; ++i) {
253253
FIO_ASSERT(fio_hemming_dist(((uint64_t)1 << i) - 1, 0) == i,
254254
"fio_hemming_dist error at %d",
255255
i);
@@ -504,7 +504,7 @@ FIO_SFUNC void FIO_NAME_TEST(stl, core)(void) {
504504
fio_u256_mul(&result, &ua, &ub);
505505
FIO_ASSERT(!memcmp(result.u64, expected, sizeof(result.u64)),
506506
"Multi-Precision MUL error");
507-
FIO_ASSERT(fio_u256_is_eq(&result, (fio_u256 *)&expected),
507+
FIO_ASSERT(fio_u512_is_eq(&result, (fio_u512 *)&expected),
508508
"Multi-Precision MUL error (is_eq)");
509509
{
510510
fio_u512 cpy = result;

0 commit comments

Comments
 (0)