diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-24 03:17:46 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2014-04-24 03:17:46 +0200 |
commit | 4872dd03e73aac434d735782417e40ca33336dac (patch) | |
tree | 8c8a20da4b077e60ed26aa393fd7c39c4e8dacde /src | |
parent | baf9b2fd6096e5e8eee45b9f2feffa9adec6e927 (diff) | |
download | fastd-4872dd03e73aac434d735782417e40ca33336dac.tar fastd-4872dd03e73aac434d735782417e40ca33336dac.zip |
Always use size_t for counters
Diffstat (limited to 'src')
-rw-r--r-- | src/fastd.c | 7 | ||||
-rw-r--r-- | src/fastd.h | 6 | ||||
-rw-r--r-- | src/peer.c | 7 | ||||
-rw-r--r-- | src/peer.h | 2 | ||||
-rw-r--r-- | src/sha256.c | 13 | ||||
-rw-r--r-- | src/socket.c | 2 |
6 files changed, 15 insertions, 22 deletions
diff --git a/src/fastd.c b/src/fastd.c index e8b4677..5c63ec6 100644 --- a/src/fastd.c +++ b/src/fastd.c @@ -185,7 +185,7 @@ static void close_log(void) { static void init_sockets(void) { ctx.socks = malloc(conf.n_bind_addrs * sizeof(fastd_socket_t)); - unsigned i; + size_t i; fastd_bind_address_t *addr = conf.bind_addrs; for (i = 0; i < conf.n_bind_addrs; i++) { ctx.socks[i] = (fastd_socket_t){ .fd = -2, .addr = addr }; @@ -222,7 +222,7 @@ void fastd_setfl(const int fd, int set, int unset) { } static void close_sockets(void) { - unsigned i; + size_t i; for (i = 0; i < ctx.n_socks; i++) fastd_socket_close(&ctx.socks[i]); @@ -385,8 +385,7 @@ static void dump_state(void) { } if (conf.mode == MODE_TAP) { - unsigned int eth_addresses = 0; - size_t i; + size_t i, eth_addresses = 0; for (i = 0; i < VECTOR_LEN(ctx.eth_addrs); i++) { if (VECTOR_INDEX(ctx.eth_addrs, i).peer == peer) eth_addresses++; diff --git a/src/fastd.h b/src/fastd.h index 0f5fec0..4119a06 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -125,8 +125,6 @@ struct fastd_peer_group { fastd_peer_group_t *children; const fastd_peer_group_config_t *conf; - - unsigned n_connections; }; struct fastd_stats { @@ -157,7 +155,7 @@ struct fastd_config { char *ifname; - unsigned n_bind_addrs; + size_t n_bind_addrs; fastd_bind_address_t *bind_addrs; fastd_bind_address_t *bind_addr_default_v4; @@ -257,7 +255,7 @@ struct fastd_context { int tunfd; - unsigned n_socks; + size_t n_socks; fastd_socket_t *socks; fastd_socket_t *sock_default_v4; @@ -515,9 +515,8 @@ void fastd_peer_delete(fastd_peer_t *peer) { delete_peer(peer); } -static inline unsigned count_established_group_peers(fastd_peer_group_t *group) { - unsigned ret = 0; - size_t i; +static inline size_t count_established_group_peers(fastd_peer_group_t *group) { + size_t i, ret = 0; for (i = 0; i < VECTOR_LEN(ctx.peers); i++) { fastd_peer_t *peer = VECTOR_INDEX(ctx.peers, i); @@ -538,7 +537,7 @@ bool fastd_peer_may_connect(fastd_peer_t *peer) { if (group->conf->max_connections < 0) continue; - if (count_established_group_peers(group) >= (unsigned)group->conf->max_connections) + if (count_established_group_peers(group) >= (size_t)group->conf->max_connections) return false; } @@ -85,7 +85,7 @@ struct fastd_peer_eth_addr { struct fastd_remote { fastd_remote_t *next; - unsigned ref; + size_t ref; fastd_remote_config_t *config; diff --git a/src/sha256.c b/src/sha256.c index 0e0aac0..38bc43d 100644 --- a/src/sha256.c +++ b/src/sha256.c @@ -37,7 +37,7 @@ static inline uint32_t rotr(uint32_t x, int r) { } static inline void copy_words(uint32_t w[8], const uint32_t *in, ssize_t *left) { - unsigned i; + size_t i; for (i = 0; i < 8; i++) { if (*left >= 4) { w[i] = ntohl(in[i]); @@ -81,7 +81,7 @@ static void sha256_list(uint32_t out[FASTD_SHA256_HASH_WORDS], const uint32_t *c 0x5be0cd19 }; ssize_t left = len; - unsigned i; + size_t i; while (left >= -8) { uint32_t w[64], v[8]; @@ -154,9 +154,8 @@ void fastd_sha256_blocks(fastd_sha256_t *out, ...) { } void fastd_sha256(fastd_sha256_t *out, const uint32_t *in, size_t len) { - size_t count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; + size_t i, count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; const uint32_t *blocks[count]; - unsigned i; for (i = 0; i < count; i++) blocks[i] = in + i*FASTD_SHA256_BLOCK_WORDS; @@ -186,10 +185,9 @@ static void hmacsha256_list(fastd_sha256_t *out, const uint32_t key[FASTD_HMACSH 0x5c5c5c5c, }; - size_t count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; + size_t i, count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; const uint32_t *blocks[count+2]; uint32_t ipad[8], opad[8]; - unsigned i; for (i = 0; i < 8; i++) { ipad[i] = key[i] ^ 0x36363636; @@ -246,9 +244,8 @@ bool fastd_hmacsha256_blocks_verify(const uint8_t mac[FASTD_SHA256_HASH_BYTES], } void fastd_hmacsha256(fastd_sha256_t *out, const uint32_t key[FASTD_HMACSHA256_KEY_WORDS], const uint32_t *in, size_t len) { - size_t count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; + size_t i, count = (len+FASTD_SHA256_BLOCK_BYTES-1) / FASTD_SHA256_BLOCK_BYTES; const uint32_t *blocks[count]; - unsigned i; for (i = 0; i < count; i++) blocks[i] = in + i*FASTD_SHA256_BLOCK_WORDS; diff --git a/src/socket.c b/src/socket.c index 77f73b4..2a8611d 100644 --- a/src/socket.c +++ b/src/socket.c @@ -182,7 +182,7 @@ static bool set_bound_address(fastd_socket_t *sock) { } bool fastd_socket_handle_binds(void) { - unsigned i; + size_t i; for (i = 0; i < ctx.n_socks; i++) { if (ctx.socks[i].fd >= 0) |