Commit 04150fa89f for bind
commit 04150fa89f56de4b1f369989699cb8a47e584864
Author: OndÅ™ej Surý <ondrej@isc.org>
Date: Tue Sep 22 11:00:08 2026 +0200
Declare counted_by counters before the pointers they count
clang rejects a counted_by or sized_by argument that names a later
member of the same struct unless -fexperimental-late-parse-attributes
is in effect, so <isc/region.h>, <isc/buffer.h> and <dns/rdata.h> did
not compile for anyone including the installed headers without that
experimental flag. Moving each count in front of the pointer it
describes removes the need for it, and all three structs keep their
previous size.
The reordering turns the few remaining positional initializers of
these types into type errors, so they become designated initializers.
Assisted-by: Claude:claude-opus-5
diff --git a/lib/dns/include/dns/rdata.h b/lib/dns/include/dns/rdata.h
index 110b50f45a..b351a5c4b8 100644
--- a/lib/dns/include/dns/rdata.h
+++ b/lib/dns/include/dns/rdata.h
@@ -107,11 +107,11 @@
* purpose the client desires.
*/
struct dns_rdata {
- unsigned char *data ISC_ATTR_COUNTED_BY_PTR(length);
+ uint16_t length;
dns_rdataclass_t rdclass;
dns_rdatatype_t type;
- uint16_t length;
uint16_t flags;
+ unsigned char *data ISC_ATTR_COUNTED_BY_PTR(length);
ISC_LINK(dns_rdata_t) link;
};
diff --git a/lib/dns/opensslecdsa_link.c b/lib/dns/opensslecdsa_link.c
index f8b1614ab9..d07bda2383 100644
--- a/lib/dns/opensslecdsa_link.c
+++ b/lib/dns/opensslecdsa_link.c
@@ -477,11 +477,11 @@ opensslecdsa_tofile(const dst_key_t *key, const char *directory) {
switch (key->key_alg) {
case DST_ALG_ECDSA256:
result = isc_ossl_wrap_p256_secret_region(
- pkey, (isc_region_t){ buf, keylen });
+ pkey, (isc_region_t){ .base = buf, .length = keylen });
break;
case DST_ALG_ECDSA384:
result = isc_ossl_wrap_p384_secret_region(
- pkey, (isc_region_t){ buf, keylen });
+ pkey, (isc_region_t){ .base = buf, .length = keylen });
break;
default:
UNREACHABLE();
diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c
index db050e06cd..448ec9add8 100644
--- a/lib/dns/sdlz.c
+++ b/lib/dns/sdlz.c
@@ -1632,7 +1632,7 @@ dns_sdlzssumatch(const dns_name_t *signer, const dns_name_t *name,
char b_type[DNS_RDATATYPE_FORMATSIZE];
char b_key[DST_KEY_FORMATSIZE];
isc_buffer_t *tkey_token = NULL;
- isc_region_t token_region = { NULL, 0 };
+ isc_region_t token_region = { 0 };
uint32_t token_len = 0;
bool ret;
diff --git a/lib/dns/ssu_external.c b/lib/dns/ssu_external.c
index f7ed766a1f..ca838021d1 100644
--- a/lib/dns/ssu_external.c
+++ b/lib/dns/ssu_external.c
@@ -122,7 +122,7 @@ dns_ssu_external_match(const dns_name_t *identity, const dns_name_t *signer,
int fd;
const char *sock_path;
unsigned int req_len;
- isc_region_t token_region = { NULL, 0 };
+ isc_region_t token_region = { 0 };
unsigned char *data;
isc_buffer_t buf;
uint32_t token_len = 0;
diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c
index f614a76ce9..5ea3596bc9 100644
--- a/lib/dns/tkey.c
+++ b/lib/dns/tkey.c
@@ -178,7 +178,8 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin,
return ISC_R_SUCCESS;
}
- intoken = (isc_region_t){ tkeyin->key, tkeyin->keylen };
+ intoken = (isc_region_t){ .base = tkeyin->key,
+ .length = tkeyin->keylen };
result = dst_gssapi_acceptctx(tctx->gssapi_keytab, &intoken, &outtoken,
&gss_ctx, principal, tctx->mctx);
if (result != ISC_R_SUCCESS) {
diff --git a/lib/isc/crypto/ossl3.c b/lib/isc/crypto/ossl3.c
index bf2e108f2c..51d94b304f 100644
--- a/lib/isc/crypto/ossl3.c
+++ b/lib/isc/crypto/ossl3.c
@@ -84,13 +84,17 @@ static EVP_CIPHER *evp_aes_256_ctr = NULL;
static EVP_CIPHER *evp_chacha20 = NULL;
static isc_constregion_t md_to_name[ISC_MD_MAX] = {
- [ISC_MD_UNKNOWN] = { NULL, 0 },
- [ISC_MD_MD5] = { "MD5", sizeof("MD5") - 1 },
- [ISC_MD_SHA1] = { "SHA1", sizeof("SHA1") - 1 },
- [ISC_MD_SHA224] = { "SHA2-224", sizeof("SHA2-224") - 1 },
- [ISC_MD_SHA256] = { "SHA2-256", sizeof("SHA2-256") - 1 },
- [ISC_MD_SHA384] = { "SHA2-384", sizeof("SHA2-384") - 1 },
- [ISC_MD_SHA512] = { "SHA2-512", sizeof("SHA2-512") - 1 },
+ [ISC_MD_UNKNOWN] = { 0 },
+ [ISC_MD_MD5] = { .base = "MD5", .length = sizeof("MD5") - 1 },
+ [ISC_MD_SHA1] = { .base = "SHA1", .length = sizeof("SHA1") - 1 },
+ [ISC_MD_SHA224] = { .base = "SHA2-224",
+ .length = sizeof("SHA2-224") - 1 },
+ [ISC_MD_SHA256] = { .base = "SHA2-256",
+ .length = sizeof("SHA2-256") - 1 },
+ [ISC_MD_SHA384] = { .base = "SHA2-384",
+ .length = sizeof("SHA2-384") - 1 },
+ [ISC_MD_SHA512] = { .base = "SHA2-512",
+ .length = sizeof("SHA2-512") - 1 },
};
static OSSL_PARAM md_to_hmac_params[ISC_MD_MAX][2] = {
diff --git a/lib/isc/include/isc/buffer.h b/lib/isc/include/isc/buffer.h
index 6521ac172b..582333a634 100644
--- a/lib/isc/include/isc/buffer.h
+++ b/lib/isc/include/isc/buffer.h
@@ -170,10 +170,11 @@
struct isc_buffer {
unsigned int magic;
+ /*! The size of the data region. */
+ unsigned int length;
void *base ISC_ATTR_SIZED_BY_PTR(length);
/*@{*/
/*! The following integers are byte offsets from 'base'. */
- unsigned int length;
unsigned int used;
unsigned int current;
unsigned int active;
diff --git a/lib/isc/include/isc/region.h b/lib/isc/include/isc/region.h
index c60b4a7e69..e15c6094d4 100644
--- a/lib/isc/include/isc/region.h
+++ b/lib/isc/include/isc/region.h
@@ -19,26 +19,26 @@
#include <isc/types.h>
struct isc_region {
- unsigned char *base ISC_ATTR_COUNTED_BY_PTR(length);
unsigned int length;
+ unsigned char *base ISC_ATTR_COUNTED_BY_PTR(length);
};
struct isc_textregion {
- char *base ISC_ATTR_COUNTED_BY_PTR(length);
unsigned int length;
+ char *base ISC_ATTR_COUNTED_BY_PTR(length);
};
/* XXXDCL questionable ... bears discussion. we have been putting off
* discussing the region api.
*/
struct isc_constregion {
- const void *base ISC_ATTR_SIZED_BY_PTR(length);
unsigned int length;
+ const void *base ISC_ATTR_SIZED_BY_PTR(length);
};
struct isc_consttextregion {
- const char *base ISC_ATTR_COUNTED_BY_PTR(length);
unsigned int length;
+ const char *base ISC_ATTR_COUNTED_BY_PTR(length);
};
/*@{*/
diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c
index 2ed09d1356..22a5843454 100644
--- a/lib/isc/netmgr/http.c
+++ b/lib/isc/netmgr/http.c
@@ -2689,8 +2689,8 @@ client_httpsend(isc_nmhandle_t *handle, isc_nmsocket_t *sock,
void *cbarg = req->cbarg;
result = client_send(
- handle,
- &(isc_region_t){ (uint8_t *)req->uvbuf.base, req->uvbuf.len });
+ handle, &(isc_region_t){ .base = (uint8_t *)req->uvbuf.base,
+ .length = req->uvbuf.len });
if (result != ISC_R_SUCCESS) {
failed_send_cb(sock, req, result);
return;
diff --git a/meson.build b/meson.build
index cde60fa96f..168fa85b8b 100644
--- a/meson.build
+++ b/meson.build
@@ -172,7 +172,6 @@ add_project_arguments(
'-Werror=vla',
'-fdiagnostics-show-option',
- '-fexperimental-late-parse-attributes',
'-fno-delete-null-pointer-checks',
'-fno-strict-aliasing',
'-fstrict-flex-arrays=3',
diff --git a/tests/dns/dnstap_test.c b/tests/dns/dnstap_test.c
index b38585a1dc..ef76159681 100644
--- a/tests/dns/dnstap_test.c
+++ b/tests/dns/dnstap_test.c
@@ -384,7 +384,7 @@ correct_dnstap_parse(const char *path) {
assert_uint_in_range(len, 1, sizeof(buf) - 1);
fclose(f);
- src = (isc_region_t){ buf, len };
+ src = (isc_region_t){ .base = buf, .length = len };
result = dns_dt_parse(isc_g_mctx, &src, &dt);
assert_int_equal(result, ISC_R_SUCCESS);
dns_dtdata_free(&dt);
@@ -405,7 +405,7 @@ invalid_dnstap_parse(const char *path) {
assert_uint_in_range(len, 1, sizeof(buf) - 1);
fclose(f);
- src = (isc_region_t){ buf, len };
+ src = (isc_region_t){ .base = buf, .length = len };
result = dns_dt_parse(isc_g_mctx, &src, &dt);
assert_int_equal(result, DNS_R_BADDNSTAP);
}
diff --git a/tests/isc/crypto_test.c b/tests/isc/crypto_test.c
index 7ab6886aa8..2a9e13601b 100644
--- a/tests/isc/crypto_test.c
+++ b/tests/isc/crypto_test.c
@@ -112,9 +112,9 @@ test_aead(const aead_testcase_t *const testcase) {
result = isc_crypto_aead_seal(
aead, nonce,
- (isc_constregion_t){ testcase->plaintext,
- sizeof(testcase->plaintext) },
- actual_ciphertext, &outlen, (isc_constregion_t){ NULL, 0 });
+ (isc_constregion_t){ .base = testcase->plaintext,
+ .length = sizeof(testcase->plaintext) },
+ actual_ciphertext, &outlen, (isc_constregion_t){ 0 });
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(outlen, actual_ciphertext.length);
assert_memory_not_equal(actual_ciphertext.base, testcase->ciphertext,
@@ -122,11 +122,12 @@ test_aead(const aead_testcase_t *const testcase) {
result = isc_crypto_aead_seal(
aead, nonce,
- (isc_constregion_t){ testcase->plaintext,
- sizeof(testcase->plaintext) },
+ (isc_constregion_t){ .base = testcase->plaintext,
+ .length = sizeof(testcase->plaintext) },
actual_ciphertext, &outlen,
- (isc_constregion_t){ testcase->additional_data,
- sizeof(testcase->additional_data) });
+ (isc_constregion_t){
+ .base = testcase->additional_data,
+ .length = sizeof(testcase->additional_data) });
assert_int_equal(result, ISC_R_SUCCESS);
assert_int_equal(outlen, actual_ciphertext.length);
assert_memory_equal(actual_ciphertext.base, testcase->ciphertext,
@@ -139,15 +140,15 @@ test_aead(const aead_testcase_t *const testcase) {
result = isc_crypto_aead_open(
aead, nonce,
- (isc_constregion_t){ (uint8_t *)testcase->ciphertext,
- sizeof(testcase->ciphertext) },
- actual_plaintext, &outlen, (isc_constregion_t){ NULL, 0 });
+ (isc_constregion_t){ .base = (uint8_t *)testcase->ciphertext,
+ .length = sizeof(testcase->ciphertext) },
+ actual_plaintext, &outlen, (isc_constregion_t){ 0 });
assert_int_not_equal(result, ISC_R_SUCCESS);
result = isc_crypto_aead_open(
aead, nonce,
- (isc_constregion_t){ (uint8_t *)testcase->ciphertext,
- sizeof(testcase->ciphertext) },
+ (isc_constregion_t){ .base = (uint8_t *)testcase->ciphertext,
+ .length = sizeof(testcase->ciphertext) },
actual_plaintext, &outlen, aad);
assert_int_equal(result, ISC_R_SUCCESS);
assert_memory_equal(actual_plaintext.base, testcase->plaintext,
@@ -252,11 +253,12 @@ ISC_RUN_TEST_IMPL(hkdf) {
0xd5, 0xb8, 0x87, 0x18, 0x58, 0x65,
};
- result = isc_crypto_hkdf((isc_region_t){ actual, sizeof(actual) },
- ISC_MD_SHA256,
- (isc_constregion_t){ ikm, sizeof(ikm) },
- (isc_constregion_t){ salt, sizeof(salt) },
- (isc_constregion_t){ info, sizeof(info) });
+ result = isc_crypto_hkdf(
+ (isc_region_t){ .base = actual, .length = sizeof(actual) },
+ ISC_MD_SHA256,
+ (isc_constregion_t){ .base = ikm, .length = sizeof(ikm) },
+ (isc_constregion_t){ .base = salt, .length = sizeof(salt) },
+ (isc_constregion_t){ .base = info, .length = sizeof(info) });
assert_int_equal(result, ISC_R_SUCCESS);
assert_memory_equal(expected, actual, 42);
@@ -284,9 +286,11 @@ ISC_RUN_TEST_IMPL(hkdf_expand_label) {
};
result = isc_crypto_hkdf_expand_label(
- (isc_region_t){ actual, sizeof(actual) }, ISC_MD_SHA256,
- (isc_constregion_t){ secret, sizeof(secret) },
- (isc_constregion_t){ "client in", sizeof("client in") - 1 });
+ (isc_region_t){ .base = actual, .length = sizeof(actual) },
+ ISC_MD_SHA256,
+ (isc_constregion_t){ .base = secret, .length = sizeof(secret) },
+ (isc_constregion_t){ .base = "client in",
+ .length = sizeof("client in") - 1 });
assert_int_equal(result, ISC_R_SUCCESS);
assert_memory_equal(expected, actual, 32);
}
diff --git a/tests/isc/dnsstream_utils_test.c b/tests/isc/dnsstream_utils_test.c
index 25ddff7030..64c8e19569 100644
--- a/tests/isc/dnsstream_utils_test.c
+++ b/tests/isc/dnsstream_utils_test.c
@@ -505,15 +505,20 @@ ISC_RUN_TEST_IMPL(dnsasm_torn_randomly_test) {
isc_buffer_t dnsbuf;
size_t packetno;
isc_region_t packets[] = {
- { (void *)request, sizeof(request) },
- { (void *)response, sizeof(response) },
- { (void *)request_large, sizeof(request_large) },
- { (void *)response_large, sizeof(response_large) },
- { (void *)request, sizeof(request) },
- { (void *)response_large, sizeof(response_large) },
- { (void *)request_large, sizeof(request_large) },
- { (void *)response_large, sizeof(response_large) },
- { (void *)request, sizeof(request) },
+ { .base = (void *)request, .length = sizeof(request) },
+ { .base = (void *)response, .length = sizeof(response) },
+ { .base = (void *)request_large,
+ .length = sizeof(request_large) },
+ { .base = (void *)response_large,
+ .length = sizeof(response_large) },
+ { .base = (void *)request, .length = sizeof(request) },
+ { .base = (void *)response_large,
+ .length = sizeof(response_large) },
+ { .base = (void *)request_large,
+ .length = sizeof(request_large) },
+ { .base = (void *)response_large,
+ .length = sizeof(response_large) },
+ { .base = (void *)request, .length = sizeof(request) },
};
const size_t npackets = sizeof(packets) / sizeof(packets[0]);