diff --git a/lib/dns/dst_result.c b/lib/dns/dst_result.c index 889b96398d..796c8442ee 100644 --- a/lib/dns/dst_result.c +++ b/lib/dns/dst_result.c @@ -9,8 +9,7 @@ * information regarding copyright ownership. */ -#include -#include +#include static const char *text[DST_R_NRESULTS] = { "algorithm is unsupported", /*%< 0 */ @@ -64,43 +63,4 @@ static const char *ids[DST_R_NRESULTS] = { "DST_R_EXTERNALKEY", }; -#define DST_RESULT_RESULTSET 2 - -static isc_once_t once = ISC_ONCE_INIT; - -static void -initialize_action(void) { - isc_result_t result; - - result = isc_result_register(ISC_RESULTCLASS_DST, DST_R_NRESULTS, text, - DST_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_register() failed: %u", result); - } - result = isc_result_registerids(ISC_RESULTCLASS_DST, DST_R_NRESULTS, - ids, DST_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_registerids() failed: %u", result); - } -} - -static void -initialize(void) { - RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); -} - -const char * -dst_result_totext(isc_result_t result) { - initialize(); - - return (isc_result_totext(result)); -} - -void -dst_result_register(void) { - initialize(); -} - /*! \file */ diff --git a/lib/dns/include/dst/result.h b/lib/dns/include/dst/result.h index 16e2c83870..120dd1443e 100644 --- a/lib/dns/include/dst/result.h +++ b/lib/dns/include/dst/result.h @@ -14,7 +14,6 @@ /*! \file dst/result.h */ -#include #include /* diff --git a/lib/dns/result.c b/lib/dns/result.c index 1c8641227b..0fa023431b 100644 --- a/lib/dns/result.c +++ b/lib/dns/result.c @@ -11,11 +11,7 @@ /*! \file */ -#include -#include - -#include -#include +#include static const char *text[DNS_R_NRESULTS] = { "label too long", /*%< 0 DNS_R_LABELTOOLONG */ @@ -341,57 +337,6 @@ static const char *rcode_ids[DNS_R_NRCODERESULTS] = { "DNS_R_BADVERS", }; -#define DNS_RESULT_RESULTSET 2 -#define DNS_RESULT_RCODERESULTSET 3 - -static isc_once_t once = ISC_ONCE_INIT; - -static void -initialize_action(void) { - isc_result_t result; - - result = isc_result_register(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS, text, - DNS_RESULT_RESULTSET); - if (result == ISC_R_SUCCESS) { - result = isc_result_register(ISC_RESULTCLASS_DNSRCODE, - DNS_R_NRCODERESULTS, rcode_text, - DNS_RESULT_RCODERESULTSET); - } - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_register() failed: %u", result); - } - - result = isc_result_registerids(ISC_RESULTCLASS_DNS, DNS_R_NRESULTS, - ids, DNS_RESULT_RESULTSET); - if (result == ISC_R_SUCCESS) { - result = isc_result_registerids(ISC_RESULTCLASS_DNSRCODE, - DNS_R_NRCODERESULTS, rcode_ids, - DNS_RESULT_RCODERESULTSET); - } - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_registerids() failed: %u", result); - } -} - -static void -initialize(void) { - RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); -} - -const char * -dns_result_totext(isc_result_t result) { - initialize(); - - return (isc_result_totext(result)); -} - -void -dns_result_register(void) { - initialize(); -} - dns_rcode_t dns_result_torcode(isc_result_t result) { dns_rcode_t rcode = dns_rcode_servfail; diff --git a/lib/isc/include/isc/result.h b/lib/isc/include/isc/result.h index 22969775df..8bb2709649 100644 --- a/lib/isc/include/isc/result.h +++ b/lib/isc/include/isc/result.h @@ -107,14 +107,6 @@ const char *isc_result_toid(isc_result_t); * "ISC_R_SUCCESS". */ -isc_result_t -isc_result_register(unsigned int base, unsigned int nresults, const char **text, - int set); - -isc_result_t -isc_result_registerids(unsigned int base, unsigned int nresults, - const char **ids, int set); - ISC_LANG_ENDDECLS #endif /* ISC_RESULT_H */ diff --git a/lib/isc/pk11_result.c b/lib/isc/pk11_result.c index 5aeb8ea849..36edc8c4f5 100644 --- a/lib/isc/pk11_result.c +++ b/lib/isc/pk11_result.c @@ -27,43 +27,3 @@ static const char *ids[PK11_R_NRESULTS] = { "PK11_R_NORANDOMSERVICE", "PK11_R_NODIGESTSERVICE", "PK11_R_NOAESSERVICE", }; - -#define PK11_RESULT_RESULTSET 2 - -static isc_once_t once = ISC_ONCE_INIT; - -static void -initialize_action(void) { - isc_result_t result; - - result = isc_result_register(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS, - text, PK11_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_register() failed: %u", result); - } - - result = isc_result_registerids(ISC_RESULTCLASS_PK11, PK11_R_NRESULTS, - ids, PK11_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_registerids() failed: %u", result); - } -} - -static void -initialize(void) { - RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); -} - -const char * -pk11_result_totext(isc_result_t result) { - initialize(); - - return (isc_result_totext(result)); -} - -void -pk11_result_register(void) { - initialize(); -} diff --git a/lib/isc/result.c b/lib/isc/result.c index 565e8406d3..7cfc9312cc 100644 --- a/lib/isc/result.c +++ b/lib/isc/result.c @@ -15,21 +15,9 @@ #include #include -#include #include -#include #include -typedef struct resulttable { - unsigned int base; - unsigned int last; - const char **text; - int set; - ISC_LINK(struct resulttable) link; -} resulttable; - -typedef ISC_LIST(resulttable) resulttable_list_t; - static const char *description[ISC_R_NRESULTS] = { "success", /*%< 0 */ "out of memory", /*%< 1 */ @@ -178,75 +166,8 @@ static const char *identifier[ISC_R_NRESULTS] = { "ISC_R_SUCCESS", "ISC_R_TLSERROR", "ISC_R_HTTP2ALPNERROR" }; -#define ISC_RESULT_RESULTSET 2 -#define ISC_RESULT_UNAVAILABLESET 3 - -static isc_once_t once = ISC_ONCE_INIT; static resulttable_list_t description_tables; static resulttable_list_t identifier_tables; -static isc_rwlock_t lock; - -static isc_result_t -register_table(resulttable_list_t *tables, unsigned int base, - unsigned int nresults, const char **text, int set) { - resulttable *table; - - REQUIRE(base % ISC_RESULTCLASS_SIZE == 0); - REQUIRE(nresults <= ISC_RESULTCLASS_SIZE); - REQUIRE(text != NULL); - - /* - * We use malloc() here because we we want to be able to use - * isc_result_totext() even if there is no memory context. - */ - table = malloc(sizeof(*table)); - if (table == NULL) { - return (ISC_R_NOMEMORY); - } - table->base = base; - table->last = base + nresults - 1; - table->text = text; - table->set = set; - ISC_LINK_INIT(table, link); - - RWLOCK(&lock, isc_rwlocktype_write); - - ISC_LIST_APPEND(*tables, table, link); - - RWUNLOCK(&lock, isc_rwlocktype_write); - - return (ISC_R_SUCCESS); -} - -static void -initialize_action(void) { - isc_result_t result; - - isc_rwlock_init(&lock, 0, 0); - ISC_LIST_INIT(description_tables); - ISC_LIST_INIT(identifier_tables); - - result = register_table(&description_tables, ISC_RESULTCLASS_ISC, - ISC_R_NRESULTS, description, - ISC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "register_table() failed: %u", result); - } - - result = register_table(&identifier_tables, ISC_RESULTCLASS_ISC, - ISC_R_NRESULTS, identifier, - ISC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "register_table() failed: %u", result); - } -} - -static void -initialize(void) { - RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); -} static const char * isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { @@ -254,10 +175,6 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { const char *text; int index; - initialize(); - - RWLOCK(&lock, isc_rwlocktype_read); - text = NULL; for (table = ISC_LIST_HEAD(*tables); table != NULL; table = ISC_LIST_NEXT(table, link)) @@ -272,8 +189,6 @@ isc_result_tomany_helper(resulttable_list_t *tables, isc_result_t result) { text = "(result code text not available)"; } - RWUNLOCK(&lock, isc_rwlocktype_read); - return (text); } @@ -286,19 +201,3 @@ const char * isc_result_toid(isc_result_t result) { return (isc_result_tomany_helper(&identifier_tables, result)); } - -isc_result_t -isc_result_register(unsigned int base, unsigned int nresults, const char **text, - int set) { - initialize(); - - return (register_table(&description_tables, base, nresults, text, set)); -} - -isc_result_t -isc_result_registerids(unsigned int base, unsigned int nresults, - const char **ids, int set) { - initialize(); - - return (register_table(&identifier_tables, base, nresults, ids, set)); -} diff --git a/lib/isccc/include/isccc/result.h b/lib/isccc/include/isccc/result.h index 5346babefc..79979710e0 100644 --- a/lib/isccc/include/isccc/result.h +++ b/lib/isccc/include/isccc/result.h @@ -28,12 +28,8 @@ /*! \file isccc/result.h */ -#include -#include #include -#include - /*% Unknown Version */ #define ISCCC_R_UNKNOWNVERSION (ISC_RESULTCLASS_ISCCC + 0) /*% Syntax Error */ @@ -49,17 +45,4 @@ #define ISCCC_R_NRESULTS 6 /*%< Number of results */ -ISC_LANG_BEGINDECLS - -const char * -isccc_result_totext(isc_result_t result); -/*% - * Convert a isccc_result_t into a string message describing the result. - */ - -void -isccc_result_register(void); - -ISC_LANG_ENDDECLS - #endif /* ISCCC_RESULT_H */ diff --git a/lib/isccc/result.c b/lib/isccc/result.c index 0f261e319c..0217d68e5a 100644 --- a/lib/isccc/result.c +++ b/lib/isccc/result.c @@ -25,8 +25,7 @@ /*! \file */ -#include -#include +#include static const char *text[ISCCC_R_NRESULTS] = { "unknown version", /* 1 */ @@ -41,43 +40,3 @@ static const char *ids[ISCCC_R_NRESULTS] = { "ISCCC_R_UNKNOWNVERSION", "ISCCC_R_SYNTAX", "ISCCC_R_BADAUTH", "ISCCC_R_EXPIRED", "ISCCC_R_CLOCKSKEW", "ISCCC_R_DUPLICATE", }; - -#define ISCCC_RESULT_RESULTSET 2 - -static isc_once_t once = ISC_ONCE_INIT; - -static void -initialize_action(void) { - isc_result_t result; - - result = isc_result_register(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS, - text, ISCCC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_register() failed: %u", result); - } - - result = isc_result_registerids(ISC_RESULTCLASS_ISCCC, ISCCC_R_NRESULTS, - ids, ISCCC_RESULT_RESULTSET); - if (result != ISC_R_SUCCESS) { - UNEXPECTED_ERROR(__FILE__, __LINE__, - "isc_result_registerids() failed: %u", result); - } -} - -static void -initialize(void) { - RUNTIME_CHECK(isc_once_do(&once, initialize_action) == ISC_R_SUCCESS); -} - -const char * -isccc_result_totext(isc_result_t result) { - initialize(); - - return (isc_result_totext(result)); -} - -void -isccc_result_register(void) { - initialize(); -}