diff --git a/daemon/aux.h b/daemon/aux.h index d7b4a55..90e3be4 100644 --- a/daemon/aux.h +++ b/daemon/aux.h @@ -21,9 +21,6 @@ #define OFFSET_OF(t,e) ((unsigned int) (unsigned long) &(((t *) 0)->e)) #define ZERO(x) memset(&(x), 0, sizeof(x)) -#ifndef ARRAYSIZE -#define ARRAYSIZE(a) (sizeof(a) / sizeof(*(a))) -#endif #define IPF "%u.%u.%u.%u" #define IPP(x) ((unsigned char *) (&(x)))[0], ((unsigned char *) (&(x)))[1], ((unsigned char *) (&(x)))[2], ((unsigned char *) (&(x)))[3] diff --git a/daemon/call.c b/daemon/call.c index c166fa7..9024d18 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -1474,7 +1474,7 @@ void relays_cache_init(struct relays_cache *c) { } int relays_cache_want_ports(struct relays_cache *c, int portA, int portB, struct call *call) { - if (c->relays_open + 2 > ARRAYSIZE(c->relays_A)) + if (c->relays_open + 2 > G_N_ELEMENTS(c->relays_A)) return -1; if (get_consecutive_ports(&c->relays_A[c->relays_open], 2, portA, call)) return -1; @@ -1489,7 +1489,7 @@ static int relays_cache_get_ports(struct relays_cache *c, int num, struct call * if (c->relays_open >= num) return 0; - if (c->relays_open + num > ARRAYSIZE(c->relays_A)) + if (c->relays_open + num > G_N_ELEMENTS(c->relays_A)) return -1; if (get_consecutive_ports(&c->relays_A[c->relays_open], num, 0, call)) return -1; @@ -1517,12 +1517,12 @@ static void relays_cache_port_used(struct relays_cache *c) { void relays_cache_cleanup(struct relays_cache *c, struct callmaster *m) { int i; - for (i = 0; i < ARRAYSIZE(c->relays_A); i++) { + for (i = 0; i < G_N_ELEMENTS(c->relays_A); i++) { if (c->relays_A[i].fd == -1) break; release_port(&c->relays_A[i], m); } - for (i = 0; i < ARRAYSIZE(c->relays_B); i++) { + for (i = 0; i < G_N_ELEMENTS(c->relays_B); i++) { if (c->relays_B[i].fd == -1) break; release_port(&c->relays_B[i], m); @@ -1880,7 +1880,7 @@ static csa_func __call_stream_address(struct peer *p, int variant) { csa_func variants[2]; assert(variant >= 0); - assert(variant < ARRAYSIZE(variants)); + assert(variant < G_N_ELEMENTS(variants)); m = p->up->call->callmaster; other = p->other; diff --git a/daemon/crypto.c b/daemon/crypto.c index e3e5694..306fe12 100644 --- a/daemon/crypto.c +++ b/daemon/crypto.c @@ -103,7 +103,7 @@ const struct crypto_suite crypto_suites[] = { }, }; -const int num_crypto_suites = ARRAYSIZE(crypto_suites); +const int num_crypto_suites = G_N_ELEMENTS(crypto_suites); @@ -456,7 +456,7 @@ static int evp_session_key_cleanup(struct crypto_context *c) { unsigned char block[16]; int len, i; - for (i = 0; i < ARRAYSIZE(c->session_key_ctx); i++) { + for (i = 0; i < G_N_ELEMENTS(c->session_key_ctx); i++) { if (!c->session_key_ctx[i]) continue; diff --git a/daemon/rtcp.c b/daemon/rtcp.c index 921ee1f..b540a9c 100644 --- a/daemon/rtcp.c +++ b/daemon/rtcp.c @@ -3,6 +3,7 @@ #include #include #include +#include #include "str.h" #include "call.h" @@ -246,7 +247,7 @@ static int rtcp_parse(GQueue *q, str *_s) { if ((hdr->header.v_p_x & 0xc0) != 0x80) /* version 2 */ goto error; - if (hdr->header.pt >= ARRAYSIZE(handler_funcs)) + if (hdr->header.pt >= G_N_ELEMENTS(handler_funcs)) goto error; func = handler_funcs[hdr->header.pt]; if (!func) diff --git a/daemon/stun.c b/daemon/stun.c index 31942ed..54c32fe 100644 --- a/daemon/stun.c +++ b/daemon/stun.c @@ -5,6 +5,7 @@ #include #include #include +#include #include "str.h" #include "aux.h" @@ -352,7 +353,7 @@ static int check_auth(str *msg, struct stun_attrs *attrs, struct peer *peer) { iov[2].iov_base = msg->s + OFFSET_OF(struct header, cookie); iov[2].iov_len = ntohs(lenX) + - 24 + 20 - OFFSET_OF(struct header, cookie); - __integrity(iov, ARRAYSIZE(iov), &peer->ice_pwd, digest); + __integrity(iov, G_N_ELEMENTS(iov), &peer->ice_pwd, digest); return memcmp(digest, attrs->msg_integrity.s, 20) ? -1 : 0; }