From f102df96b86ba3658aa2a6594fbffd6c1e2ec309 Mon Sep 17 00:00:00 2001 From: Artem Boldariev Date: Thu, 22 Dec 2022 19:54:16 +0200 Subject: [PATCH] Rename isc_tlsctx_cache_new() -> isc_tlsctx_cache_create() Additionally to renaming, it changes the function definition so that it accepts a pointer to pointer instead of returning a pointer to the new object. It is mostly done to make it in line with other functions in the module. --- bin/dig/dighost.c | 2 +- bin/named/server.c | 4 ++-- bin/nsupdate/nsupdate.c | 2 +- lib/isc/include/isc/tls.h | 7 ++++--- lib/isc/tls.c | 7 ++++--- tests/dns/dispatch_test.c | 2 +- 6 files changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 217dd3e6f8..41a001054b 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -630,7 +630,7 @@ make_empty_lookup(void) { ISC_LIST_INIT(looknew->q); ISC_LIST_INIT(looknew->my_server_list); - looknew->tls_ctx_cache = isc_tlsctx_cache_new(mctx); + isc_tlsctx_cache_create(mctx, &looknew->tls_ctx_cache); isc_refcount_init(&looknew->references, 1); diff --git a/bin/named/server.c b/bin/named/server.c index 3027bafe75..7019256dd3 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -8448,13 +8448,13 @@ load_configuration(const char *filename, named_server_t *server, isc_tlsctx_cache_detach(&server->tlsctx_server_cache); } - server->tlsctx_server_cache = isc_tlsctx_cache_new(named_g_mctx); + isc_tlsctx_cache_create(named_g_mctx, &server->tlsctx_server_cache); if (server->tlsctx_client_cache != NULL) { isc_tlsctx_cache_detach(&server->tlsctx_client_cache); } - server->tlsctx_client_cache = isc_tlsctx_cache_new(named_g_mctx); + isc_tlsctx_cache_create(named_g_mctx, &server->tlsctx_client_cache); dns_zonemgr_set_tlsctx_cache(server->zonemgr, server->tlsctx_client_cache); diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index de98154ef0..55c1ae343d 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -967,7 +967,7 @@ setup_system(void) { } transport_list = dns_transport_list_new(gmctx); - tls_ctx_cache = isc_tlsctx_cache_new(gmctx); + isc_tlsctx_cache_create(gmctx, &tls_ctx_cache); if (tls_client_key_file == NULL) { result = create_name("tls-non-auth-client", namedata, diff --git a/lib/isc/include/isc/tls.h b/lib/isc/include/isc/tls.h index 24577ec13d..113d603229 100644 --- a/lib/isc/include/isc/tls.h +++ b/lib/isc/include/isc/tls.h @@ -466,13 +466,14 @@ typedef enum { } isc_tlsctx_cache_transport_t; /*%< TLS context cache transport type values. */ -isc_tlsctx_cache_t * -isc_tlsctx_cache_new(isc_mem_t *mctx); +void +isc_tlsctx_cache_create(isc_mem_t *mctx, isc_tlsctx_cache_t **cachep); /*%< * Create a new TLS context cache object. * * Requires: - *\li 'mctx' is a valid memory context. + *\li 'mctx' is a valid memory context; + *\li 'cachep' is a valid pointer to a pointer which must be equal to NULL. */ void diff --git a/lib/isc/tls.c b/lib/isc/tls.c index a7d9a93332..6a9605928c 100644 --- a/lib/isc/tls.c +++ b/lib/isc/tls.c @@ -1174,10 +1174,11 @@ struct isc_tlsctx_cache { isc_ht_t *data; }; -isc_tlsctx_cache_t * -isc_tlsctx_cache_new(isc_mem_t *mctx) { +void +isc_tlsctx_cache_create(isc_mem_t *mctx, isc_tlsctx_cache_t **cachep) { isc_tlsctx_cache_t *nc; + REQUIRE(cachep != NULL && *cachep == NULL); nc = isc_mem_get(mctx, sizeof(*nc)); *nc = (isc_tlsctx_cache_t){ .magic = TLSCTX_CACHE_MAGIC }; @@ -1187,7 +1188,7 @@ isc_tlsctx_cache_new(isc_mem_t *mctx) { isc_ht_init(&nc->data, mctx, 5, ISC_HT_CASE_SENSITIVE); isc_rwlock_init(&nc->rwlock, 0, 0); - return (nc); + *cachep = nc; } void diff --git a/tests/dns/dispatch_test.c b/tests/dns/dispatch_test.c index 649166bf25..ed046db9f1 100644 --- a/tests/dns/dispatch_test.c +++ b/tests/dns/dispatch_test.c @@ -181,7 +181,7 @@ setup_test(void **state) { testdata.region.length = sizeof(testdata.rbuf); memset(testdata.message, 0, sizeof(testdata.message)); - tls_tlsctx_client_cache = isc_tlsctx_cache_new(mctx); + isc_tlsctx_cache_create(mctx, &tls_tlsctx_client_cache); if (isc_tlsctx_createserver(NULL, NULL, &tls_listen_tlsctx) != ISC_R_SUCCESS)