mirror of
https://github.com/strongswan/strongswan.git
synced 2025-10-05 00:00:45 -04:00
changed elemsof() macro to countof()
This commit is contained in:
parent
247e665a44
commit
2775c9aac8
@ -225,7 +225,7 @@ __alg_info_esp_add (struct alg_info_esp *alg_info, int ealg_id, unsigned ek_bits
|
||||
unsigned cnt = alg_info->alg_info_cnt, i;
|
||||
|
||||
/* check for overflows */
|
||||
passert(cnt < elemsof(alg_info->esp));
|
||||
passert(cnt < countof(alg_info->esp));
|
||||
|
||||
/* dont add duplicates */
|
||||
for (i = 0; i < cnt; i++)
|
||||
@ -366,7 +366,7 @@ __alg_info_ike_add (struct alg_info_ike *alg_info, int ealg_id, unsigned ek_bits
|
||||
unsigned i;
|
||||
|
||||
/* check for overflows */
|
||||
passert(cnt < elemsof(alg_info->ike));
|
||||
passert(cnt < countof(alg_info->ike));
|
||||
|
||||
/* dont add duplicates */
|
||||
for (i = 0;i < cnt; i++)
|
||||
@ -410,7 +410,7 @@ static void
|
||||
alg_info_ike_add (struct alg_info *alg_info, int ealg_id, int ek_bits, int aalg_id, int ak_bits, int modp_id)
|
||||
{
|
||||
int i = 0;
|
||||
int n_groups = elemsof(default_ike_groups);
|
||||
int n_groups = countof(default_ike_groups);
|
||||
|
||||
/* if specified modp_id avoid loop over default_ike_groups */
|
||||
if (modp_id)
|
||||
|
@ -30,8 +30,6 @@ extern void init_constants(void);
|
||||
* Any changes here should be reflected there.
|
||||
*/
|
||||
|
||||
#define elemsof(array) (sizeof(array) / sizeof(*(array))) /* number of elements in an array */
|
||||
|
||||
/* Many routines return only success or failure, but wish to describe
|
||||
* the failure in a message. We use the convention that they return
|
||||
* a NULL on success and a pointer to constant string on failure.
|
||||
|
@ -510,7 +510,7 @@ lookup_group(u_int16_t group)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i != elemsof(oakley_group); i++)
|
||||
for (i = 0; i != countof(oakley_group); i++)
|
||||
if (group == oakley_group[i].group)
|
||||
return &oakley_group[i];
|
||||
return NULL;
|
||||
|
@ -526,7 +526,7 @@ init_demux(void)
|
||||
*/
|
||||
const struct state_microcode *t;
|
||||
|
||||
for (t = &state_microcode_table[elemsof(state_microcode_table) - 1];;)
|
||||
for (t = &state_microcode_table[countof(state_microcode_table) - 1];;)
|
||||
{
|
||||
passert(STATE_IKE_FLOOR <= t->state && t->state < STATE_IKE_ROOF);
|
||||
ike_microcode_index[t->state - STATE_IKE_FLOOR] = t;
|
||||
|
@ -1117,7 +1117,7 @@ process_dns_answer(struct adns_continuation *const cr
|
||||
|
||||
r = (qr_header.stuff >> QRS_RCODE_SHIFT) & QRS_RCODE_MASK;
|
||||
if (r != 0)
|
||||
return r < (int)elemsof(rcode_text)? rcode_text[r] : "unknown rcode";
|
||||
return r < (int)countof(rcode_text)? rcode_text[r] : "unknown rcode";
|
||||
|
||||
if (qr_header.ancount == 0)
|
||||
return builddiag("no %s RR found by DNS", rr_typename(type));
|
||||
|
@ -378,7 +378,7 @@ ike_alg_list(void)
|
||||
whack_log(RC_COMMENT, "List of registered IKE DH Groups:");
|
||||
whack_log(RC_COMMENT, " ");
|
||||
|
||||
for (i = 0; i < elemsof(oakley_group); i++)
|
||||
for (i = 0; i < countof(oakley_group); i++)
|
||||
{
|
||||
const struct oakley_group_desc *gdesc=oakley_group + i;
|
||||
|
||||
|
@ -1460,7 +1460,7 @@ scan_proc_shunts(void)
|
||||
* Note: if there are too many fields, just stop;
|
||||
* it will be diagnosed a little later.
|
||||
*/
|
||||
for (fi = 0; fi < (int)elemsof(field); fi++)
|
||||
for (fi = 0; fi < (int)countof(field); fi++)
|
||||
{
|
||||
static const char sep[] = " \t\n"; /* field-separating whitespace */
|
||||
size_t w;
|
||||
@ -1869,7 +1869,7 @@ setup_half_ipsec_sa(struct state *st, bool inbound)
|
||||
|
||||
for (ei = esp_info; ; ei++)
|
||||
{
|
||||
if (ei == &esp_info[elemsof(esp_info)])
|
||||
if (ei == &esp_info[countof(esp_info)])
|
||||
{
|
||||
/* Check for additional kernel alg */
|
||||
#ifndef NO_KERNEL_ALG
|
||||
|
@ -483,7 +483,7 @@ process_rsa_secret(RSA_private_key_t *rsak)
|
||||
MP_INT *n = (MP_INT *) ((char *)rsak + p->offset);
|
||||
|
||||
n_to_mpz(n, buf, sz);
|
||||
if (pb_next < &pub_bytes[elemsof(pub_bytes)])
|
||||
if (pb_next < &pub_bytes[countof(pub_bytes)])
|
||||
{
|
||||
if (eb_next - ebytes + sz > sizeof(ebytes))
|
||||
return "public key takes too many bytes";
|
||||
|
@ -134,7 +134,7 @@ RSA_show_key_fields(RSA_private_key_t *k, int fieldcnt)
|
||||
void
|
||||
RSA_show_private_key(RSA_private_key_t *k)
|
||||
{
|
||||
RSA_show_key_fields(k, elemsof(RSA_private_field));
|
||||
RSA_show_key_fields(k, countof(RSA_private_field));
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -212,7 +212,7 @@ static int pluto_ifn_roof = 0;
|
||||
bool
|
||||
use_interface(const char *rifn)
|
||||
{
|
||||
if (pluto_ifn_roof >= (int)elemsof(pluto_ifn))
|
||||
if (pluto_ifn_roof >= (int)countof(pluto_ifn))
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@
|
||||
#include "db_ops.h"
|
||||
#include "nat_traversal.h"
|
||||
|
||||
#define AD(x) x, elemsof(x) /* Array Description */
|
||||
#define AD(x) x, countof(x) /* Array Description */
|
||||
#define AD_NULL NULL, 0
|
||||
|
||||
/**************** Oakely (main mode) SA database ****************/
|
||||
|
Loading…
x
Reference in New Issue
Block a user