2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +00:00

Merge branch '2993-replace-instances-of-arraysize-with-array_size' into 'main'

Resolve "Replace instances of ARRAYSIZE with ARRAY_SIZE"

Closes #2993

See merge request isc-projects/bind9!5551
This commit is contained in:
Mark Andrews 2021-11-02 10:57:45 +00:00
commit d051de17de
3 changed files with 6 additions and 17 deletions

View File

@ -152,10 +152,6 @@
#define SIZE_AS_PERCENT ((size_t)-2)
#endif /* ifndef SIZE_AS_PERCENT */
#ifndef ARRAYSIZE
#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
#endif
#ifdef TUNE_LARGE
#define RESOLVER_NTASKS_PERCPU 32
#else
@ -5829,7 +5825,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
}
name = dns_fixedname_initname(&fixed);
for (ipv4only_zone = 0; ipv4only_zone < ARRAYSIZE(zones);
for (ipv4only_zone = 0; ipv4only_zone < ARRAY_SIZE(zones);
ipv4only_zone++) {
dns_forwarders_t *dnsforwarders = NULL;

View File

@ -90,12 +90,7 @@ static isc_result_t
svcb_validate(uint16_t key, isc_region_t *region) {
size_t i;
#ifndef ARRAYSIZE
/* defined in winnt.h */
#define ARRAYSIZE(x) (sizeof(x) / sizeof(*x))
#endif
for (i = 0; i < ARRAYSIZE(sbpr); i++) {
for (i = 0; i < ARRAY_SIZE(sbpr); i++) {
if (sbpr[i].value == key) {
switch (sbpr[i].encoding) {
case sbpr_port:
@ -172,7 +167,7 @@ svc_keyfromregion(isc_textregion_t *region, char sep, uint16_t *value,
unsigned long ul;
/* Look for known key names. */
for (i = 0; i < ARRAYSIZE(sbpr); i++) {
for (i = 0; i < ARRAY_SIZE(sbpr); i++) {
size_t len = strlen(sbpr[i].name);
if (strncasecmp(region->base, sbpr[i].name, len) != 0 ||
(region->base[len] != 0 && region->base[len] != sep))
@ -235,7 +230,7 @@ svc_fromtext(isc_textregion_t *region, isc_buffer_t *target) {
unsigned int used;
unsigned long ul;
for (i = 0; i < ARRAYSIZE(sbpr); i++) {
for (i = 0; i < ARRAY_SIZE(sbpr); i++) {
len = strlen(sbpr[i].name);
if (strncmp(region->base, sbpr[i].name, len) != 0 ||
(region->base[len] != 0 && region->base[len] != '='))
@ -360,7 +355,7 @@ svcparamkey(unsigned short value, enum encoding *encoding, char *buf,
size_t i;
int n;
for (i = 0; i < ARRAYSIZE(sbpr); i++) {
for (i = 0; i < ARRAY_SIZE(sbpr); i++) {
if (sbpr[i].value == value && sbpr[i].initial) {
*encoding = sbpr[i].encoding;
return (sbpr[i].name);

View File

@ -146,9 +146,7 @@ addzoneconf(void **state) {
result = cfg_parser_create(mctx, lctx, &p);
assert_int_equal(result, ISC_R_SUCCESS);
#define ARRAYSIZE(x) (sizeof(x) / sizeof(x[0]))
for (size_t i = 0; i < ARRAYSIZE(tests); i++) {
for (size_t i = 0; i < ARRAY_SIZE(tests); i++) {
cfg_obj_t *conf = NULL;
const cfg_obj_t *obj = NULL, *zlist = NULL;