157, 184, 192 };
unsigned int i;
- for (i = 0; i < sizeof(allowed) / sizeof(allowed[0]); i++)
+ for (i = 0; i < ARRAY_SIZE(allowed); i++)
if (chan->chan == allowed[i])
return 1;
switch (n_chans) {
case 2:
allowed = allowed_40;
- allowed_no = sizeof(allowed_40) / sizeof(allowed_40[0]);
+ allowed_no = ARRAY_SIZE(allowed_40);
break;
case 4:
allowed = allowed_80;
- allowed_no = sizeof(allowed_80) / sizeof(allowed_80[0]);
+ allowed_no = ARRAY_SIZE(allowed_80);
break;
default:
wpa_printf(MSG_DEBUG, "Unknown width for %d channels", n_chans);
first = sec_chan;
ok = 0;
- for (k = 0; k < sizeof(allowed) / sizeof(allowed[0]); k++) {
+ for (k = 0; k < ARRAY_SIZE(allowed); k++) {
if (first == allowed[k]) {
ok = 1;
break;
#endif /* ALL_DH_GROUPS */
};
-#define NUM_DH_GROUPS (sizeof(dh_groups) / sizeof(dh_groups[0]))
+#define NUM_DH_GROUPS ARRAY_SIZE(dh_groups)
const struct dh_group * dh_groups_get(int id)
#endif /* MADWIFI_NG */
int idx = op - first;
if (first <= op &&
- idx < (int) (sizeof(opnames) / sizeof(opnames[0])) &&
+ idx < (int) ARRAY_SIZE(opnames) &&
opnames[idx])
perror(opnames[idx]);
else
wpa_printf(MSG_DEBUG, "nl80211: Subscribe to mgmt frames with AP "
"handle %p", bss->nl_mgmt);
- for (i = 0; i < sizeof(stypes) / sizeof(stypes[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(stypes); i++) {
if (nl80211_register_frame(bss, bss->nl_mgmt,
(WLAN_FC_TYPE_MGMT << 2) |
(stypes[i] << 4),
};
static struct sock_fprog msock_filter = {
- .len = sizeof(msock_filter_insns)/sizeof(msock_filter_insns[0]),
+ .len = ARRAY_SIZE(msock_filter_insns),
.filter = msock_filter_insns,
};
{ AUTH_HMAC_MD5_96, 16, 12 }
};
-#define NUM_INTEG_ALGS (sizeof(ikev2_integ_algs) / sizeof(ikev2_integ_algs[0]))
+#define NUM_INTEG_ALGS ARRAY_SIZE(ikev2_integ_algs)
static struct ikev2_prf_alg ikev2_prf_algs[] = {
{ PRF_HMAC_MD5, 16, 16 }
};
-#define NUM_PRF_ALGS (sizeof(ikev2_prf_algs) / sizeof(ikev2_prf_algs[0]))
+#define NUM_PRF_ALGS ARRAY_SIZE(ikev2_prf_algs)
static struct ikev2_encr_alg ikev2_encr_algs[] = {
{ ENCR_3DES, 24, 8 }
};
-#define NUM_ENCR_ALGS (sizeof(ikev2_encr_algs) / sizeof(ikev2_encr_algs[0]))
+#define NUM_ENCR_ALGS ARRAY_SIZE(ikev2_encr_algs)
const struct ikev2_integ_alg * ikev2_get_integ(int id)
{ RADIUS_ATTR_NAS_IPV6_ADDRESS, "NAS-IPv6-Address", RADIUS_ATTR_IPV6 },
{ RADIUS_ATTR_ERROR_CAUSE, "Error-Cause", RADIUS_ATTR_INT32 }
};
-#define RADIUS_ATTRS (sizeof(radius_attrs) / sizeof(radius_attrs[0]))
+#define RADIUS_ATTRS ARRAY_SIZE(radius_attrs)
static struct radius_attr_type *radius_get_attr_type(u8 type)
TLS_CIPHER_AES_256_CBC, TLS_HASH_SHA256 }
};
-#define NUM_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
-#define NUM_TLS_CIPHER_SUITES NUM_ELEMS(tls_cipher_suites)
+#define NUM_TLS_CIPHER_SUITES ARRAY_SIZE(tls_cipher_suites)
static const struct tls_cipher_data tls_ciphers[] = {
CRYPTO_CIPHER_ALG_AES }
};
-#define NUM_TLS_CIPHER_DATA NUM_ELEMS(tls_ciphers)
+#define NUM_TLS_CIPHER_DATA ARRAY_SIZE(tls_ciphers)
/**
struct __user_cap_header_struct header;
struct __user_cap_data_struct cap;
- setgroups(sizeof(groups)/sizeof(groups[0]), groups);
+ setgroups(ARRAY_SIZE(groups), groups);
prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0);
u8 *buf;
unsigned int i;
- for (i = 0; i < sizeof(vectors) / sizeof(vectors[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(vectors); i++) {
struct cbc_test_vector *tv = &vectors[i];
buf = malloc(tv->len);
if (buf == NULL) {
u8 p[64], c[64], tmp[64];
size_t k_len, p_len, aad_len, iv_len;
- for (i = 0; i < sizeof(gcm_tests) / sizeof(gcm_tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(gcm_tests); i++) {
const struct gcm_test_vector *tc = &gcm_tests[i];
k_len = os_strlen(tc->k) / 2;
test_aes_perf();
- for (i = 0; i < sizeof(test_vectors) / sizeof(test_vectors[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(test_vectors); i++) {
tv = &test_vectors[i];
if (omac1_aes_128(tv->k, tv->msg, tv->msg_len, result) ||
memcmp(result, tv->tag, 16) != 0) {
size_t len[2];
int errors = 0;
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
printf("MD4 test case %d:", i);
addr[0] = (u8 *) tests[i].data;
size_t len[2];
int errors = 0;
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
printf("MD5 test case %d:", i);
addr[0] = (u8 *) tests[i].data;
}
};
-#define NUM_GSM_TESTS (sizeof(gsm_test_sets) / sizeof(gsm_test_sets[0]))
+#define NUM_GSM_TESTS ARRAY_SIZE(gsm_test_sets)
struct milenage_test_set {
}
};
-#define NUM_TESTS (sizeof(test_sets) / sizeof(test_sets[0]))
+#define NUM_TESTS ARRAY_SIZE(test_sets)
int main(int argc, char *argv[])
}
};
-#define NUM_TESTS (sizeof(tests) / sizeof(tests[0]))
+#define NUM_TESTS ARRAY_SIZE(tests)
static int run_test(unsigned int i, const u8 *key, size_t key_len,
},
};
-#define NUM_PASSPHRASE_TESTS \
-(sizeof(passphrase_tests) / sizeof(passphrase_tests[0]))
+#define NUM_PASSPHRASE_TESTS ARRAY_SIZE(passphrase_tests)
struct rfc6070_test {
#endif
};
-#define NUM_RFC6070_TESTS \
-(sizeof(rfc6070_tests) / sizeof(rfc6070_tests[0]))
+#define NUM_RFC6070_TESTS ARRAY_SIZE(rfc6070_tests)
int main(int argc, char *argv[])
size_t len[2];
int errors = 0;
- for (i = 0; i < sizeof(tests) / sizeof(tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(tests); i++) {
printf("SHA256 test case %d:", i + 1);
addr[0] = (u8 *) tests[i].data;
printf("\n");
}
- for (i = 0; i < sizeof(hmac_tests) / sizeof(hmac_tests[0]); i++) {
+ for (i = 0; i < ARRAY_SIZE(hmac_tests); i++) {
struct hmac_test *t = &hmac_tests[i];
printf("HMAC-SHA256 test case %d:", i + 1);
switch (arg) {
case 1:
/* counter list */
- count = sizeof(sta_counters) / sizeof(sta_counters[0]);
+ count = ARRAY_SIZE(sta_counters);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
switch (arg) {
case 1:
/* counter list */
- count = sizeof(bss_counters) / sizeof(bss_counters[0]);
+ count = ARRAY_SIZE(bss_counters);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
switch (arg) {
case 1:
/* counter list */
- count = sizeof(tdls_counters) / sizeof(tdls_counters[0]);
+ count = ARRAY_SIZE(tdls_counters);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
switch (arg) {
case 1:
/* frame list */
- count = sizeof(inject_frames) / sizeof(inject_frames[0]);
+ count = ARRAY_SIZE(inject_frames);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
break;
switch (arg) {
case 1:
/* counter list */
- count = sizeof(sta_infos) / sizeof(sta_infos[0]);
+ count = ARRAY_SIZE(sta_infos);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
switch (arg) {
case 1:
/* counter list */
- count = sizeof(bss_infos) / sizeof(bss_infos[0]);
+ count = ARRAY_SIZE(bss_infos);
res = os_calloc(count, sizeof(char *));
if (res == NULL)
return NULL;
static char ** wlantest_cli_cmd_list(void)
{
char **res;
- int i, count;
+ int i;
- count = sizeof(wlantest_cli_commands) /
- sizeof(wlantest_cli_commands[0]);
- res = os_calloc(count, sizeof(char *));
+ res = os_calloc(ARRAY_SIZE(wlantest_cli_commands), sizeof(char *));
if (res == NULL)
return NULL;
#undef _FUNC
#undef FUNC
#undef FUNC_KEY
-#define NUM_SSID_FIELDS (sizeof(ssid_fields) / sizeof(ssid_fields[0]))
+#define NUM_SSID_FIELDS ARRAY_SIZE(ssid_fields)
/**
#undef STR
#undef STR_RANGE
#undef BIN
-#define NUM_GLOBAL_FIELDS (sizeof(global_fields) / sizeof(global_fields[0]))
+#define NUM_GLOBAL_FIELDS ARRAY_SIZE(global_fields)
int wpa_config_process_global(struct wpa_config *config, char *pos, int line)
const char *args[] = {"ccmp", "tkip", "none"};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Pairwise", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto nomem;
} else {
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Pairwise",
};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Group", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto nomem;
} else {
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Group",
};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "KeyMgmt", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto nomem;
} else {
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "KeyMgmt",
const char *args[] = { "rsn", "wpa" };
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "Protocol", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto nomem;
} else {
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "Protocol",
const char *args[] = { "open", "shared", "leap" };
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "AuthAlg", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto nomem;
} else {
if (!wpa_dbus_dict_begin_string_array(&iter_dict, "AuthAlg",
/***** Scan */
if (!wpa_dbus_dict_append_string_array(&iter_dict, "Scan", scans,
- sizeof(scans) / sizeof(char *)))
+ ARRAY_SIZE(scans)))
goto nomem;
/***** Modes */
const char *args[] = {"CCMP", "TKIP", "NONE"};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "pairwise", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto error;
}
} else {
};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "group", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto error;
}
} else {
};
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "key_mgmt", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto error;
}
} else {
const char *args[] = { "RSN", "WPA" };
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "proto", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto error;
}
} else {
const char *args[] = { "OPEN", "SHARED", "LEAP" };
if (!wpa_dbus_dict_append_string_array(
&iter_dict, "auth_alg", args,
- sizeof(args) / sizeof(char*)))
+ ARRAY_SIZE(args)))
goto error;
}
} else {
"sae_groups", "dtim_period", "beacon_int", "ap_vendor_elements",
"ignore_old_scan_res", "freq_list", "external_sim"
};
- int i, num_fields = sizeof(fields) / sizeof(fields[0]);
+ int i, num_fields = ARRAY_SIZE(fields);
if (arg == 1) {
char **res = os_calloc(num_fields + 1, sizeof(char *));
"disc_int",
"per_sta_psk",
};
- int i, num_fields = sizeof(fields) / sizeof(fields[0]);
+ int i, num_fields = ARRAY_SIZE(fields);
if (arg == 1) {
char **res = os_calloc(num_fields + 1, sizeof(char *));
int i, count;
struct cli_txt_entry *e;
- count = sizeof(wpa_cli_commands) / sizeof(wpa_cli_commands[0]);
+ count = ARRAY_SIZE(wpa_cli_commands);
count += dl_list_len(&p2p_groups);
count += dl_list_len(&ifnames);
res = os_calloc(count + 1, sizeof(char *));