From 3a1bb8dac8092217f303b4295fbfa765c9f103f2 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Fri, 10 Feb 2023 10:18:38 -0800 Subject: [PATCH] remove some unused functions removed some functions that are no longer used and unlikely to be resurrected, and also some that were only used to support Windows and can now be replaced with generic versions. --- bin/dig/dig.c | 5 --- bin/dig/dighost.h | 6 --- bin/dnssec/dnssec-signzone.c | 6 +-- lib/dns/masterdump.c | 13 ++---- lib/isc/dir.c | 73 -------------------------------- lib/isc/file.c | 17 -------- lib/isc/include/isc/dir.h | 9 ---- lib/isc/include/isc/file.h | 12 +----- lib/ns/include/ns/interfacemgr.h | 7 --- lib/ns/include/ns/sortlist.h | 12 ------ lib/ns/interfacemgr.c | 7 --- lib/ns/sortlist.c | 26 ------------ 12 files changed, 7 insertions(+), 186 deletions(-) diff --git a/bin/dig/dig.c b/bin/dig/dig.c index 546399c9d6..9438ae0826 100644 --- a/bin/dig/dig.c +++ b/bin/dig/dig.c @@ -3045,11 +3045,6 @@ dig_startup(void) { isc_loopmgr_run(loopmgr); } -void -dig_query_start(void) { - start_lookup(); -} - void dig_shutdown(void) { destroy_lookup(default_lookup); diff --git a/bin/dig/dighost.h b/bin/dig/dighost.h index 0b2ad0dc5d..0587ce1403 100644 --- a/bin/dig/dighost.h +++ b/bin/dig/dighost.h @@ -444,12 +444,6 @@ dig_query_setup(bool, bool, int argc, char **argv); void dig_startup(void); -/*% - * Initiates the next lookup cycle - */ -void -dig_query_start(void); - /*% * Activate/deactivate IDN filtering of output. */ diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 835dc2737a..6f2328c72e 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3913,11 +3913,7 @@ main(int argc, char *argv[]) { result = isc_file_mktemplate(output, tempfile, tempfilelen); check_result(result, "isc_file_mktemplate"); - if (outputformat == dns_masterformat_text) { - result = isc_file_openunique(tempfile, &outfp); - } else { - result = isc_file_bopenunique(tempfile, &outfp); - } + result = isc_file_openunique(tempfile, &outfp); if (result != ISC_R_SUCCESS) { fatal("failed to open temporary output file: %s", isc_result_totext(result)); diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index d07919c41f..d9cdcb786e 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1791,8 +1791,7 @@ dns_master_dumptostream(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, } static isc_result_t -opentmp(isc_mem_t *mctx, dns_masterformat_t format, const char *file, - char **tempp, FILE **fp) { +opentmp(isc_mem_t *mctx, const char *file, char **tempp, FILE **fp) { FILE *f = NULL; isc_result_t result; char *tempname = NULL; @@ -1806,11 +1805,7 @@ opentmp(isc_mem_t *mctx, dns_masterformat_t format, const char *file, goto cleanup; } - if (format == dns_masterformat_text) { - result = isc_file_openunique(tempname, &f); - } else { - result = isc_file_bopenunique(tempname, &f); - } + result = isc_file_openunique(tempname, &f); if (result != ISC_R_SUCCESS) { isc_log_write(dns_lctx, ISC_LOGCATEGORY_GENERAL, DNS_LOGMODULE_MASTERDUMP, ISC_LOG_ERROR, @@ -1846,7 +1841,7 @@ dns_master_dumpasync(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, file = isc_mem_strdup(mctx, filename); - result = opentmp(mctx, format, filename, &tempname, &f); + result = opentmp(mctx, filename, &tempname, &f); if (result != ISC_R_SUCCESS) { goto cleanup_file; } @@ -1887,7 +1882,7 @@ dns_master_dump(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, char *tempname; dns_dumpctx_t *dctx = NULL; - result = opentmp(mctx, format, filename, &tempname, &f); + result = opentmp(mctx, filename, &tempname, &f); if (result != ISC_R_SUCCESS) { return (result); } diff --git a/lib/isc/dir.c b/lib/isc/dir.c index b7eabe9a6f..473618cb57 100644 --- a/lib/isc/dir.c +++ b/lib/isc/dir.c @@ -193,76 +193,3 @@ isc_dir_chroot(const char *dirname) { return (ISC_R_NOTIMPLEMENTED); #endif /* ifdef HAVE_CHROOT */ } - -isc_result_t -isc_dir_createunique(char *templet) { - isc_result_t result; - char *x; - char *p; - int i; - int pid; - - REQUIRE(templet != NULL); - - /*! - * \brief mkdtemp is not portable, so this emulates it. - */ - - pid = getpid(); - - /* - * Replace trailing Xs with the process-id, zero-filled. - */ - for (x = templet + strlen(templet) - 1; *x == 'X' && x >= templet; - x--, pid /= 10) - { - *x = pid % 10 + '0'; - } - - x++; /* Set x to start of ex-Xs. */ - - do { - i = mkdir(templet, 0700); - if (i == 0 || errno != EEXIST) { - break; - } - - /* - * The BSD algorithm. - */ - p = x; - while (*p != '\0') { - if (isdigit((unsigned char)*p)) { - *p = 'a'; - } else if (*p != 'z') { - ++*p; - } else { - /* - * Reset character and move to next. - */ - *p++ = 'a'; - continue; - } - - break; - } - - if (*p == '\0') { - /* - * Tried all combinations. errno should already - * be EEXIST, but ensure it is anyway for - * isc__errno2result(). - */ - errno = EEXIST; - break; - } - } while (1); - - if (i == -1) { - result = isc__errno2result(errno); - } else { - result = ISC_R_SUCCESS; - } - - return (result); -} diff --git a/lib/isc/file.c b/lib/isc/file.c index bdf65fb460..a1aed8e164 100644 --- a/lib/isc/file.c +++ b/lib/isc/file.c @@ -383,23 +383,6 @@ isc_file_openuniquemode(char *templet, int mode, FILE **fp) { return (result); } -isc_result_t -isc_file_bopenunique(char *templet, FILE **fp) { - int mode = S_IWUSR | S_IRUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH; - return (isc_file_openuniquemode(templet, mode, fp)); -} - -isc_result_t -isc_file_bopenuniqueprivate(char *templet, FILE **fp) { - int mode = S_IWUSR | S_IRUSR; - return (isc_file_openuniquemode(templet, mode, fp)); -} - -isc_result_t -isc_file_bopenuniquemode(char *templet, int mode, FILE **fp) { - return (isc_file_openuniquemode(templet, mode, fp)); -} - isc_result_t isc_file_remove(const char *filename) { int r; diff --git a/lib/isc/include/isc/dir.h b/lib/isc/include/isc/dir.h index c1ff2c7192..90c327ecb4 100644 --- a/lib/isc/include/isc/dir.h +++ b/lib/isc/include/isc/dir.h @@ -68,13 +68,4 @@ isc_dir_chdir(const char *dirname); isc_result_t isc_dir_chroot(const char *dirname); -isc_result_t -isc_dir_createunique(char *templet); -/*!< - * Use a templet (such as from isc_file_mktemplate()) to create a uniquely - * named, empty directory. The templet string is modified in place. - * If result == ISC_R_SUCCESS, it is the name of the directory that was - * created. - */ - ISC_LANG_ENDDECLS diff --git a/lib/isc/include/isc/file.h b/lib/isc/include/isc/file.h index f78c5c580c..46d0f9246a 100644 --- a/lib/isc/include/isc/file.h +++ b/lib/isc/include/isc/file.h @@ -102,16 +102,8 @@ isc_result_t isc_file_openuniqueprivate(char *templet, FILE **fp); isc_result_t isc_file_openuniquemode(char *templet, int mode, FILE **fp); -isc_result_t -isc_file_bopenunique(char *templet, FILE **fp); -isc_result_t -isc_file_bopenuniqueprivate(char *templet, FILE **fp); -isc_result_t -isc_file_bopenuniquemode(char *templet, int mode, FILE **fp); /*!< * \brief Create and open a file with a unique name based on 'templet'. - * isc_file_bopen*() open the file in binary mode in Windows. - * isc_file_open*() open the file in text mode in Windows. * * Notes: *\li 'template' is a reserved work in C++. If you want to complain @@ -312,8 +304,8 @@ isc_result_t isc_file_splitpath(isc_mem_t *mctx, const char *path, char **dirname, char const **basename); /*%< - * Split a path into dirname and basename. If 'path' contains no slash - * (or, on windows, backslash), then '*dirname' is set to ".". + * Split a path into dirname and basename. If 'path' contains no slash, + * then '*dirname' is set to ".". * * Allocates memory for '*dirname', which can be freed with isc_mem_free(). * diff --git a/lib/ns/include/ns/interfacemgr.h b/lib/ns/include/ns/interfacemgr.h index 4c248dec23..317b722405 100644 --- a/lib/ns/include/ns/interfacemgr.h +++ b/lib/ns/include/ns/interfacemgr.h @@ -127,13 +127,6 @@ ns_interfacemgr_setbacklog(ns_interfacemgr_t *mgr, int backlog); * Set the size of the listen() backlog queue. */ -bool -ns_interfacemgr_islistening(ns_interfacemgr_t *mgr); -/*%< - * Return if the manager is listening on any interface. It can be called - * after a scan or adjust. - */ - isc_result_t ns_interfacemgr_scan(ns_interfacemgr_t *mgr, bool verbose, bool config); /*%< diff --git a/lib/ns/include/ns/sortlist.h b/lib/ns/include/ns/sortlist.h index 3333e9cd49..baac9fd16a 100644 --- a/lib/ns/include/ns/sortlist.h +++ b/lib/ns/include/ns/sortlist.h @@ -66,15 +66,3 @@ ns_sortlist_addrorder2(const isc_netaddr_t *addr, const void *arg); * ACL forming the second element in a 2-element top-level * sortlist statement. */ - -void -ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, dns_aclenv_t *env, - isc_netaddr_t *client_addr, - dns_addressorderfunc_t *orderp, void **argp); -/*%< - * Find the sortlist statement in 'acl' that applies to 'clientaddr', if any. - * If a sortlist statement applies, return in '*orderp' a pointer to a function - * for ranking network addresses based on that sortlist statement, and in - * '*argp' an argument to pass to said function. If no sortlist statement - * applies, set '*orderp' and '*argp' to NULL. - */ diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index d10f41c0c2..c159369a64 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -1349,13 +1349,6 @@ ns_interfacemgr_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) { return (result); } -bool -ns_interfacemgr_islistening(ns_interfacemgr_t *mgr) { - REQUIRE(NS_INTERFACEMGR_VALID(mgr)); - - return (ISC_LIST_EMPTY(mgr->interfaces) ? false : true); -} - void ns_interfacemgr_setlistenon4(ns_interfacemgr_t *mgr, ns_listenlist_t *value) { REQUIRE(NS_INTERFACEMGR_VALID(mgr)); diff --git a/lib/ns/sortlist.c b/lib/ns/sortlist.c index 2aada90b19..971edb60d2 100644 --- a/lib/ns/sortlist.c +++ b/lib/ns/sortlist.c @@ -153,29 +153,3 @@ ns_sortlist_addrorder1(const isc_netaddr_t *addr, const void *arg) { return (INT_MAX); } - -void -ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, dns_aclenv_t *env, - isc_netaddr_t *client_addr, - dns_addressorderfunc_t *orderp, void **argp) { - ns_sortlisttype_t sortlisttype; - - sortlisttype = ns_sortlist_setup(sortlist_acl, env, client_addr, argp); - - switch (sortlisttype) { - case NS_SORTLISTTYPE_1ELEMENT: - *orderp = ns_sortlist_addrorder1; - break; - case NS_SORTLISTTYPE_2ELEMENT: - *orderp = ns_sortlist_addrorder2; - break; - case NS_SORTLISTTYPE_NONE: - *orderp = NULL; - break; - default: - UNEXPECTED_ERROR( - "unexpected return from ns_sortlist_setup(): %d", - sortlisttype); - break; - } -}