]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
add type to hooktable_free callbacks each-resolver-plugin 11250/head
authorColin Vidal <colin@isc.org>
Mon, 24 Nov 2025 10:28:48 +0000 (11:28 +0100)
committerColin Vidal <colin@isc.org>
Mon, 24 Nov 2025 10:28:48 +0000 (11:28 +0100)
The `hootable_free` callbacks (used in views and zones) are now typed
with `dns_hooktable_free_t`, as the hook definitions are now part of
libdns.

lib/dns/hooks.c
lib/dns/include/dns/hooks.h
lib/dns/include/dns/view.h
lib/dns/include/dns/zone.h
lib/dns/zone.c
tests/libtest/ns.c

index 09bb5df26d4c630ff06fd4890ac53a480a10683e..fccb7453d5da98a201ba3b5b406297ddc846305b 100644 (file)
@@ -298,7 +298,7 @@ dns_hooktable_create(isc_mem_t *mctx, dns_hooktable_t **tablep) {
 }
 
 void
-dns_hooktable_free(isc_mem_t *mctx, void **tablep) {
+dns_hooktable_free(isc_mem_t *mctx, dns_hooktable_t **tablep) {
        dns_hooktable_t *table = NULL;
        int i = 0;
 
index 34b1e53ae2142fc1bae752681259db8cf47eeeac..0b902dc4336ca493e3aeb6ae6c49a3f2dd93b590 100644 (file)
@@ -443,6 +443,8 @@ typedef struct dns_hook {
 typedef ISC_LIST(dns_hook_t) dns_hooklist_t;
 typedef dns_hooklist_t dns_hooktable_t[DNS_HOOKPOINTS_COUNT];
 
+typedef void (*dns_hooktable_free_t)(isc_mem_t *, dns_hooktable_t **);
+
 /*%
  * dns__hook_table is a global hook table, which is used if view->hooktable
  * is NULL.  It's intended only for use by unit tests.
@@ -638,7 +640,7 @@ dns_plugins_free(isc_mem_t *mctx, void **listp);
  */
 
 void
-dns_hooktable_free(isc_mem_t *mctx, void **tablep);
+dns_hooktable_free(isc_mem_t *mctx, dns_hooktable_t **tablep);
 /*%<
  * Free a hook table.
  */
index bb74c0a2c637b05bd8eb143301e0f3a5666614c8..2228f438d1c57441d68f19376a6e3792cd839b57 100644 (file)
@@ -69,6 +69,7 @@
 #include <dns/clientinfo.h>
 #include <dns/dnstap.h>
 #include <dns/fixedname.h>
+#include <dns/hooks.h>
 #include <dns/nta.h>
 #include <dns/rdatastruct.h>
 #include <dns/rpz.h>
@@ -243,8 +244,8 @@ struct dns_view {
        void (*plugins_free)(isc_mem_t *, void **);
 
        /* Hook table */
-       void *hooktable; /* dns_hooktable */
-       void (*hooktable_free)(isc_mem_t *, void **);
+       dns_hooktable_t     *hooktable;
+       dns_hooktable_free_t hooktable_free;
 };
 
 #define DNS_VIEW_MAGIC      ISC_MAGIC('V', 'i', 'e', 'w')
index d9821e7213bf3343233ccf51395e9f22321ae461..667f62a07f591b6e6c7b0f9df4db576391e45f73 100644 (file)
@@ -29,6 +29,7 @@
 
 #include <dns/catz.h>
 #include <dns/diff.h>
+#include <dns/hooks.h>
 #include <dns/master.h>
 #include <dns/masterdump.h>
 #include <dns/rdatastruct.h>
@@ -2719,7 +2720,7 @@ dns_zone_getkeystores(dns_zone_t *zone);
  * initialized.
  */
 
-void *
+dns_hooktable_t *
 dns_zone_gethooktable(dns_zone_t *zone);
 /**<
  * Returns the zone hooktable
@@ -2730,7 +2731,7 @@ dns_zone_gethooktable(dns_zone_t *zone);
 
 void
 dns_zone_sethooktable(dns_zone_t *zone, void *hooktable,
-                     void (*hooktable_free)(isc_mem_t *, void **));
+                     dns_hooktable_free_t hooktable_free);
 /**<
  * Initialize zone hooktable and free callback
  *
index a46969b3e8e324871cd743f7584dcf80a575c29a..bef967b9a264d589188f8e1091c313b2753a268a 100644 (file)
@@ -525,8 +525,8 @@ struct dns_zone {
         */
        void *plugins;
        void (*plugins_free)(isc_mem_t *, void **);
-       void *hooktable;
-       void (*hooktable_free)(isc_mem_t *, void **);
+       dns_hooktable_t *hooktable;
+       dns_hooktable_free_t hooktable_free;
 
        /* Configuration text */
        char *cfg;
@@ -24005,7 +24005,7 @@ dns_zone_setrad(dns_zone_t *zone, dns_name_t *name) {
        rcu_read_unlock();
 }
 
-void *
+dns_hooktable_t *
 dns_zone_gethooktable(dns_zone_t *zone) {
        REQUIRE(DNS_ZONE_VALID(zone));
        return zone->hooktable;
@@ -24013,7 +24013,7 @@ dns_zone_gethooktable(dns_zone_t *zone) {
 
 void
 dns_zone_sethooktable(dns_zone_t *zone, void *hooktable,
-                     void (*hooktable_free)(isc_mem_t *, void **)) {
+                     dns_hooktable_free_t hooktable_free) {
        REQUIRE(DNS_ZONE_VALID(zone));
        REQUIRE(zone->hooktable == NULL);
        REQUIRE(zone->hooktable_free == NULL);
index e8e432fd47c20dc30fe82dfc6997dac5786af4fd..628ee2f4c9db8f5d55e7738bfe88a6c75831f137 100644 (file)
@@ -401,7 +401,7 @@ create_qctx_for_client(ns_client_t *client, query_ctx_t **qctxp) {
        ns_query_start(client, client->inner.handle);
 
        dns__hook_table = saved_hook_table;
-       dns_hooktable_free(isc_g_mctx, (void **)&query_hooks);
+       dns_hooktable_free(isc_g_mctx, &query_hooks);
 
        isc_nmhandle_detach(&client->inner.reqhandle);