]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
De-duplicate __FILE__, __LINE__
authorTony Finch <dot@dotat.at>
Fri, 14 Oct 2022 15:07:07 +0000 (16:07 +0100)
committerTony Finch <dot@dotat.at>
Mon, 17 Oct 2022 15:00:26 +0000 (16:00 +0100)
Mostly generated automatically with the following semantic patch,
except where coccinelle was confused by #ifdef in lib/isc/net.c

@@ expression list args; @@
- UNEXPECTED_ERROR(__FILE__, __LINE__, args)
+ UNEXPECTED_ERROR(args)
@@ expression list args; @@
- FATAL_ERROR(__FILE__, __LINE__, args)
+ FATAL_ERROR(args)

(cherry picked from commit ec50c58f5205abf076152d51f9192c807920add5)

32 files changed:
bin/named/dlz_dlopen_driver.c
bin/named/main.c
bin/named/server.c
doc/dev/unexpected
lib/dns/cache.c
lib/dns/diff.c
lib/dns/journal.c
lib/dns/master.c
lib/dns/masterdump.c
lib/dns/name.c
lib/dns/rbtdb.c
lib/dns/resolver.c
lib/dns/rpz.c
lib/dns/view.c
lib/dns/zone.c
lib/isc/condition.c
lib/isc/entropy.c
lib/isc/include/isc/util.h
lib/isc/interfaceiter.c
lib/isc/lex.c
lib/isc/managers.c
lib/isc/mem.c
lib/isc/net.c
lib/isc/netmgr/netmgr-int.h
lib/isc/rwlock.c
lib/isc/sockaddr.c
lib/isc/time.c
lib/isc/timer.c
lib/isc/tls.c
lib/ns/interfacemgr.c
lib/ns/sortlist.c
lib/ns/update.c

index 45cfbfa97687c6662a30daa0d35efba50b7700db..f636cd26de569cc4fe449e9ab639bd6180175643 100644 (file)
@@ -532,8 +532,7 @@ dlz_dlopen_init(isc_mem_t *mctx) {
                                  mctx, &dlz_dlopen);
 
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "dns_sdlzregister() failed: %s",
+               UNEXPECTED_ERROR("dns_sdlzregister() failed: %s",
                                 isc_result_totext(result));
                result = ISC_R_UNEXPECTED;
        }
index b8122401d01d2bb91c04e76f24bdeb6d97121051..4fdfa98fa3dc0f51426f36f61135a43f650eaeb1 100644 (file)
@@ -1426,8 +1426,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
 
        if ((h = scf_handle_create(SCF_VERSION)) == NULL) {
                if (debug) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "scf_handle_create() failed: %s",
+                       UNEXPECTED_ERROR("scf_handle_create() failed: %s",
                                         scf_strerror(scf_error()));
                }
                return (ISC_R_FAILURE);
@@ -1435,8 +1434,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
 
        if (scf_handle_bind(h) == -1) {
                if (debug) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "scf_handle_bind() failed: %s",
+                       UNEXPECTED_ERROR("scf_handle_bind() failed: %s",
                                         scf_strerror(scf_error()));
                }
                scf_handle_destroy(h);
@@ -1445,8 +1443,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
 
        if ((namelen = scf_myname(h, NULL, 0)) == -1) {
                if (debug) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "scf_myname() failed: %s",
+                       UNEXPECTED_ERROR("scf_myname() failed: %s",
                                         scf_strerror(scf_error()));
                }
                scf_handle_destroy(h);
@@ -1454,8 +1451,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
        }
 
        if ((instance = isc_mem_allocate(mctx, namelen + 1)) == NULL) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "named_smf_get_instance memory "
+               UNEXPECTED_ERROR("named_smf_get_instance memory "
                                 "allocation failed: %s",
                                 isc_result_totext(ISC_R_NOMEMORY));
                scf_handle_destroy(h);
@@ -1464,8 +1460,7 @@ named_smf_get_instance(char **ins_name, int debug, isc_mem_t *mctx) {
 
        if (scf_myname(h, instance, namelen + 1) == -1) {
                if (debug) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "scf_myname() failed: %s",
+                       UNEXPECTED_ERROR("scf_myname() failed: %s",
                                         scf_strerror(scf_error()));
                }
                scf_handle_destroy(h);
@@ -1576,8 +1571,7 @@ main(int argc, char *argv[]) {
                if (result == ISC_R_RELOAD) {
                        named_server_reloadwanted(named_g_server);
                } else if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_app_run(): %s",
+                       UNEXPECTED_ERROR("isc_app_run(): %s",
                                         isc_result_totext(result));
                        /*
                         * Force exit.
@@ -1591,8 +1585,7 @@ main(int argc, char *argv[]) {
                result = named_smf_get_instance(&instance, 1, named_g_mctx);
                if (result == ISC_R_SUCCESS && instance != NULL) {
                        if (smf_disable_instance(instance, 0) != 0) {
-                               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                "smf_disable_instance() "
+                               UNEXPECTED_ERROR("smf_disable_instance() "
                                                 "failed for %s : %s",
                                                 instance,
                                                 scf_strerror(scf_error()));
index d4ac044ddae24c7e6837cfeb754039ae30cf4c01..d213c7a900e9a1233c7e1a6aba0b6c37b6f1d62d 100644 (file)
@@ -4758,8 +4758,7 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config,
                maps, AF_INET6, &dispatch6, &dscp6,
                (ISC_LIST_PREV(view, link) == NULL)));
        if (dispatch4 == NULL && dispatch6 == NULL) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "unable to obtain either an IPv4 or"
+               UNEXPECTED_ERROR("unable to obtain either an IPv4 or"
                                 " an IPv6 dispatch");
                result = ISC_R_UNEXPECTED;
                goto cleanup;
index ffa4b2a9b938ca9d73fa2f9cd4655e1fa65ada9f..bb9f00a8b50384fa8eaa79772f216321c4a4bc5a 100644 (file)
@@ -37,8 +37,7 @@ not, we call UNEXPECTED_ERROR().  E.g.
 
 void foo() {
        if (some_unix_thang() < 0) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "some_unix_thang() failed: %s",
+               UNEXPECTED_ERROR("some_unix_thang() failed: %s",
                                 strerror(errno));
                return (ISC_R_UNEXPECTED);
        }
index bb4bea3052126a2a741d47fa2f6bf4e282deb0d4..3e4e8c95f87e39f1c069363b9062678b9239f468 100644 (file)
@@ -467,8 +467,7 @@ cache_cleaner_init(dns_cache_t *cache, isc_taskmgr_t *taskmgr,
        if (taskmgr != NULL && timermgr != NULL) {
                result = isc_task_create(taskmgr, 1, &cleaner->task);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_task_create() failed: %s",
+                       UNEXPECTED_ERROR("isc_task_create() failed: %s",
                                         isc_result_totext(result));
                        result = ISC_R_UNEXPECTED;
                        goto cleanup;
@@ -480,8 +479,7 @@ cache_cleaner_init(dns_cache_t *cache, isc_taskmgr_t *taskmgr,
                                             cleaner_shutdown_action, cache);
                if (result != ISC_R_SUCCESS) {
                        isc_refcount_decrement0(&cleaner->cache->live_tasks);
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "cache cleaner: "
+                       UNEXPECTED_ERROR("cache cleaner: "
                                         "isc_task_onshutdown() failed: %s",
                                         isc_result_totext(result));
                        goto cleanup;
@@ -547,8 +545,7 @@ begin_cleaning(cache_cleaner_t *cleaner) {
                 * so there is nothing to be cleaned.
                 */
                if (result != ISC_R_NOMORE && cleaner->iterator != NULL) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "cache cleaner: "
+                       UNEXPECTED_ERROR("cache cleaner: "
                                         "dns_dbiterator_first() failed: %s",
                                         isc_result_totext(result));
                        dns_dbiterator_destroy(&cleaner->iterator);
@@ -687,10 +684,8 @@ incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
 
                result = dns_dbiterator_current(cleaner->iterator, &node, NULL);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "cache cleaner: "
-                                        "dns_dbiterator_current() "
-                                        "failed: %s",
+                       UNEXPECTED_ERROR("cache cleaner: "
+                                        "dns_dbiterator_current() failed: %s",
                                         isc_result_totext(result));
 
                        end_cleaning(cleaner, event);
@@ -716,8 +711,7 @@ incremental_cleaning_action(isc_task_t *task, isc_event_t *event) {
                         * keep trying to clean it, otherwise stop cleaning.
                         */
                        if (result != ISC_R_NOMORE) {
-                               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                "cache cleaner: "
+                               UNEXPECTED_ERROR("cache cleaner: "
                                                 "dns_dbiterator_next() "
                                                 "failed: %s",
                                                 isc_result_totext(result));
@@ -792,8 +786,7 @@ dns_cache_clean(dns_cache_t *cache, isc_stdtime_t now) {
                 */
                result = dns_db_expirenode(cache->db, node, now);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "cache cleaner: dns_db_expirenode() "
+                       UNEXPECTED_ERROR("cache cleaner: dns_db_expirenode() "
                                         "failed: %s",
                                         isc_result_totext(result));
                        /*
index f5f7cef11c9b0d2c2f2a1a76e3224ed4ddbd7230..a1a2c438d36f31e623a0aa911a227d1675e7c750 100644 (file)
@@ -176,8 +176,7 @@ dns_diff_appendminimal(dns_diff_t *diff, dns_difftuple_t **tuplep) {
                {
                        ISC_LIST_UNLINK(diff->tuples, ot, link);
                        if ((*tuplep)->op == ot->op) {
-                               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                "unexpected non-minimal diff");
+                               UNEXPECTED_ERROR("unexpected non-minimal diff");
                        } else {
                                dns_difftuple_free(tuplep);
                        }
@@ -615,8 +614,7 @@ dns_diff_print(dns_diff_t *diff, FILE *file) {
 
                result = diff_tuple_tordataset(t, &rd, &rdl, &rds);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "diff_tuple_tordataset failed: %s",
+                       UNEXPECTED_ERROR("diff_tuple_tordataset failed: %s",
                                         isc_result_totext(result));
                        result = ISC_R_UNEXPECTED;
                        goto cleanup;
index 23534115ed620819ef173c12dcff447cdd20b628..930fae3c7374a15e494f6c17d30f9f2d1ae45d70 100644 (file)
@@ -168,7 +168,7 @@ dns_db_createsoatuple(dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx,
 freenode:
        dns_db_detachnode(db, &node);
 nonode:
-       UNEXPECTED_ERROR(__FILE__, __LINE__, "missing SOA");
+       UNEXPECTED_ERROR("missing SOA");
        return (result);
 }
 
index f84dd114cf04c95aead5f9225b383d341bbcc9de..6acd19232f76209f75c7c838f077c865c3de52a2 100644 (file)
@@ -445,8 +445,7 @@ loadctx_destroy(dns_loadctx_t *lctx) {
        if (lctx->f != NULL) {
                isc_result_t result = isc_stdio_close(lctx->f);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_stdio_close() failed: %s",
+                       UNEXPECTED_ERROR("isc_stdio_close() failed: %s",
                                         isc_result_totext(result));
                }
        }
@@ -1281,8 +1280,7 @@ load_text(dns_loadctx_t *lctx) {
                                }
                                dump_time = (isc_stdtime_t)dump_time64;
                                if (dump_time != dump_time64) {
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "%s: %s:%lu: $DATE "
+                                       UNEXPECTED_ERROR("%s: %s:%lu: $DATE "
                                                         "outside epoch",
                                                         "dns_master_load",
                                                         source, line);
@@ -1290,8 +1288,7 @@ load_text(dns_loadctx_t *lctx) {
                                        goto insist_and_cleanup;
                                }
                                if (dump_time > current_time) {
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "%s: %s:%lu: "
+                                       UNEXPECTED_ERROR("%s: %s:%lu: "
                                                         "$DATE in future, "
                                                         "using current date",
                                                         "dns_master_load",
@@ -1570,8 +1567,7 @@ load_text(dns_loadctx_t *lctx) {
                                ictx->drop = false;
                        }
                } else {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "%s:%lu: isc_lex_gettoken() returned "
+                       UNEXPECTED_ERROR("%s:%lu: isc_lex_gettoken() returned "
                                         "unexpected token type (%d)",
                                         source, line, token.type);
                        result = ISC_R_UNEXPECTED;
@@ -1663,8 +1659,7 @@ load_text(dns_loadctx_t *lctx) {
                }
 
                if (token.type != isc_tokentype_string) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_lex_gettoken() returned "
+                       UNEXPECTED_ERROR("isc_lex_gettoken() returned "
                                         "unexpected token type");
                        result = ISC_R_UNEXPECTED;
                        if (MANYERRS(lctx, result)) {
@@ -1685,8 +1680,7 @@ load_text(dns_loadctx_t *lctx) {
                }
 
                if (token.type != isc_tokentype_string) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_lex_gettoken() returned "
+                       UNEXPECTED_ERROR("isc_lex_gettoken() returned "
                                         "unexpected token type");
                        result = ISC_R_UNEXPECTED;
                        if (MANYERRS(lctx, result)) {
@@ -2273,8 +2267,7 @@ load_header(dns_loadctx_t *lctx) {
 
        result = isc_stdio_read(data, 1, commonlen, lctx->f, NULL);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_stdio_read failed: %s",
+               UNEXPECTED_ERROR("isc_stdio_read failed: %s",
                                 isc_result_totext(result));
                return (result);
        }
@@ -2306,8 +2299,7 @@ load_header(dns_loadctx_t *lctx) {
 
        result = isc_stdio_read(data + commonlen, 1, remainder, lctx->f, NULL);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_stdio_read failed: %s",
+               UNEXPECTED_ERROR("isc_stdio_read failed: %s",
                                 isc_result_totext(result));
                return (result);
        }
@@ -2332,8 +2324,7 @@ openfile_raw(dns_loadctx_t *lctx, const char *master_file) {
 
        result = isc_stdio_open(master_file, "rb", &lctx->f);
        if (result != ISC_R_SUCCESS && result != ISC_R_FILENOTFOUND) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_stdio_open() failed: %s",
+               UNEXPECTED_ERROR("isc_stdio_open() failed: %s",
                                 isc_result_totext(result));
        }
 
index e2743de806557139fbf80e7020b5ee6dda52d8eb..505de8394c5c106c368230210cd690c326c0f9d6 100644 (file)
@@ -856,8 +856,7 @@ dns_rdataset_totext(dns_rdataset_t *rdataset, const dns_name_t *owner_name,
        isc_result_t result;
        result = totext_ctx_init(&dns_master_style_debug, NULL, &ctx);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "could not set master file style");
+               UNEXPECTED_ERROR("could not set master file style");
                return (ISC_R_UNEXPECTED);
        }
 
@@ -889,8 +888,7 @@ dns_master_rdatasettotext(const dns_name_t *owner_name,
        isc_result_t result;
        result = totext_ctx_init(style, indent, &ctx);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "could not set master file style");
+               UNEXPECTED_ERROR("could not set master file style");
                return (ISC_R_UNEXPECTED);
        }
 
@@ -906,8 +904,7 @@ dns_master_questiontotext(const dns_name_t *owner_name,
        isc_result_t result;
        result = totext_ctx_init(style, NULL, &ctx);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "could not set master file style");
+               UNEXPECTED_ERROR("could not set master file style");
                return (ISC_R_UNEXPECTED);
        }
 
@@ -982,8 +979,7 @@ dump_rdataset(isc_mem_t *mctx, const dns_name_t *name, dns_rdataset_t *rdataset,
        result = isc_stdio_write(r.base, 1, (size_t)r.length, f, NULL);
 
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "master file write failed: %s",
+               UNEXPECTED_ERROR("master file write failed: %s",
                                 isc_result_totext(result));
                return (result);
        }
@@ -1265,8 +1261,7 @@ restart:
        result = isc_stdio_write(r.base, 1, (size_t)r.length, f, NULL);
 
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "raw master file write failed: %s",
+               UNEXPECTED_ERROR("raw master file write failed: %s",
                                 isc_result_totext(result));
                return (result);
        }
@@ -1585,8 +1580,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version,
 
        result = totext_ctx_init(style, NULL, &dctx->tctx);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "could not set master file style");
+               UNEXPECTED_ERROR("could not set master file style");
                goto cleanup;
        }
 
@@ -1976,8 +1970,7 @@ dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db,
 
        result = totext_ctx_init(style, NULL, &ctx);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "could not set master file style");
+               UNEXPECTED_ERROR("could not set master file style");
                return (ISC_R_UNEXPECTED);
        }
 
index f1939d27d10ef54cb53297d7bfa44b3d63107b4c..9fa238b14c0b2a60c72f25265556f7e24c49c0f8 100644 (file)
@@ -1244,8 +1244,7 @@ dns_name_fromtext(dns_name_t *name, isc_buffer_t *source,
                        }
                        break;
                default:
-                       FATAL_ERROR(__FILE__, __LINE__, "Unexpected state %d",
-                                   state);
+                       FATAL_ERROR("Unexpected state %d", state);
                        /* Does not return. */
                }
        }
@@ -1467,8 +1466,7 @@ dns_name_totext2(const dns_name_t *name, unsigned int options,
                                count--;
                        }
                } else {
-                       FATAL_ERROR(__FILE__, __LINE__,
-                                   "Unexpected label type %02x", count);
+                       FATAL_ERROR("Unexpected label type %02x", count);
                        UNREACHABLE();
                }
 
@@ -1591,8 +1589,7 @@ dns_name_tofilenametext(const dns_name_t *name, bool omit_final_dot,
                                count--;
                        }
                } else {
-                       FATAL_ERROR(__FILE__, __LINE__,
-                                   "Unexpected label type %02x", count);
+                       FATAL_ERROR("Unexpected label type %02x", count);
                        UNREACHABLE();
                }
 
@@ -1674,8 +1671,7 @@ dns_name_downcase(const dns_name_t *source, dns_name_t *name,
                                count--;
                        }
                } else {
-                       FATAL_ERROR(__FILE__, __LINE__,
-                                   "Unexpected label type %02x", count);
+                       FATAL_ERROR("Unexpected label type %02x", count);
                        /* Does not return. */
                }
        }
@@ -1885,8 +1881,7 @@ dns_name_fromwire(dns_name_t *name, isc_buffer_t *source,
                        state = fw_start;
                        break;
                default:
-                       FATAL_ERROR(__FILE__, __LINE__, "Unknown state %d",
-                                   state);
+                       FATAL_ERROR("Unknown state %d", state);
                        /* Does not return. */
                }
        }
index d5b542aaa45d45ba3584f9ede74424f8d460aeec..ea3c005d3514b0646f512c05d3fe4b2eff9ee826 100644 (file)
@@ -4436,7 +4436,7 @@ zone_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options,
        UNUSED(rdataset);
        UNUSED(sigrdataset);
 
-       FATAL_ERROR(__FILE__, __LINE__, "zone_findzonecut() called!");
+       FATAL_ERROR("zone_findzonecut() called!");
 
        UNREACHABLE();
        return (ISC_R_NOTIMPLEMENTED);
index e7437656b6a1312cdf8f9b281ce969f780909b84..4f2e363b9936a937aee09af7f259007bc3d41730 100644 (file)
@@ -1299,7 +1299,7 @@ fctx_stoptimer(fetchctx_t *fctx) {
        result = isc_timer_reset(fctx->timer, isc_timertype_inactive, NULL,
                                 NULL, true);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_timer_reset(): %s",
+               UNEXPECTED_ERROR("isc_timer_reset(): %s",
                                 isc_result_totext(result));
        }
 }
@@ -4907,8 +4907,7 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
 
        if (!dns_name_issubdomain(fctx->name, fctx->domain)) {
                dns_name_format(fctx->domain, buf, sizeof(buf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "'%s' is not subdomain of '%s'", fctx->info,
+               UNEXPECTED_ERROR("'%s' is not subdomain of '%s'", fctx->info,
                                 buf);
                result = ISC_R_UNEXPECTED;
                goto cleanup_fcount;
@@ -4924,8 +4923,7 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
                         res->query_timeout % 1000 * 1000000);
        iresult = isc_time_nowplusinterval(&fctx->expires, &interval);
        if (iresult != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_time_nowplusinterval: %s",
+               UNEXPECTED_ERROR("isc_time_nowplusinterval: %s",
                                 isc_result_totext(iresult));
                result = ISC_R_UNEXPECTED;
                goto cleanup_qmessage;
@@ -4941,7 +4939,7 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
        isc_interval_set(&interval, 2, 0);
        iresult = isc_time_add(&fctx->expires, &interval, &fctx->final);
        if (iresult != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_time_add: %s",
+               UNEXPECTED_ERROR("isc_time_add: %s",
                                 isc_result_totext(iresult));
                result = ISC_R_UNEXPECTED;
                goto cleanup_qmessage;
@@ -4956,7 +4954,7 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
                                   NULL, res->buckets[bucketnum].task,
                                   fctx_expired, fctx, &fctx->timer);
        if (iresult != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "isc_timer_create: %s",
+               UNEXPECTED_ERROR("isc_timer_create: %s",
                                 isc_result_totext(iresult));
                result = ISC_R_UNEXPECTED;
                goto cleanup_qmessage;
@@ -4983,8 +4981,7 @@ fctx_create(dns_resolver_t *res, isc_task_t *task, const dns_name_t *name,
                iresult = isc_time_nowplusinterval(&fctx->expires_try_stale,
                                                   &interval);
                if (iresult != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_time_nowplusinterval: %s",
+                       UNEXPECTED_ERROR("isc_time_nowplusinterval: %s",
                                         isc_result_totext(iresult));
                        result = ISC_R_UNEXPECTED;
                        goto cleanup_timer;
index 90832b34d13d923087c2da5f486f1df17c12a0e1..3e4cb547398309893b462acf01e5c780338e24c9 100644 (file)
@@ -213,7 +213,7 @@ dns_rpz_type2str(dns_rpz_type_t type) {
        case DNS_RPZ_TYPE_BAD:
                break;
        }
-       FATAL_ERROR(__FILE__, __LINE__, "impossible rpz type %d", type);
+       FATAL_ERROR("impossible rpz type %d", type);
        return ("impossible");
 }
 
index f413cf252711ef55e051484bced9bfd9b500c463..e1b9d5394db6d0de1efb86e6c60064a69c5ec00c 100644 (file)
@@ -123,8 +123,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name,
        view->zonetable = NULL;
        result = dns_zt_create(mctx, rdclass, &view->zonetable);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "dns_zt_create() failed: %s",
+               UNEXPECTED_ERROR("dns_zt_create() failed: %s",
                                 isc_result_totext(result));
                result = ISC_R_UNEXPECTED;
                goto cleanup_mutex;
@@ -135,8 +134,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, const char *name,
        view->fwdtable = NULL;
        result = dns_fwdtable_create(mctx, &view->fwdtable);
        if (result != ISC_R_SUCCESS) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "dns_fwdtable_create() failed: %s",
+               UNEXPECTED_ERROR("dns_fwdtable_create() failed: %s",
                                 isc_result_totext(result));
                result = ISC_R_UNEXPECTED;
                goto cleanup_zt;
index 3247fdea991372d5f10efde08eedbd26b0f09f25..ce209780ef5180de36772d78f5b6e606c77a8c0e 100644 (file)
@@ -5234,8 +5234,7 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime,
                break;
 
        default:
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "unexpected zone type %d",
-                                zone->type);
+               UNEXPECTED_ERROR("unexpected zone type %d", zone->type);
                result = ISC_R_UNEXPECTED;
                goto cleanup;
        }
index 19c16be6b1c67fcb2879babc93631ffb260d3a42..8cd765a067d2eeb1bd21394d2bf70c13207d5ad5 100644 (file)
@@ -62,7 +62,6 @@ isc_condition_waituntil(isc_condition_t *c, isc_mutex_t *m, isc_time_t *t) {
        } while (presult == EINTR);
 
        strerror_r(presult, strbuf, sizeof(strbuf));
-       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                        "pthread_cond_timedwait() returned %s", strbuf);
+       UNEXPECTED_ERROR("pthread_cond_timedwait() returned %s", strbuf);
        return (ISC_R_UNEXPECTED);
 }
index ce79ba21c3b676d13986adb4c1d808d13797042f..38fcfa0df7b47594d62967633342460e906ac58a 100644 (file)
@@ -22,7 +22,7 @@
 void
 isc_entropy_get(void *buf, size_t buflen) {
        if (RAND_bytes(buf, buflen) < 1) {
-               FATAL_ERROR(__FILE__, __LINE__, "RAND_bytes(): %s",
+               FATAL_ERROR("RAND_bytes(): %s",
                            ERR_error_string(ERR_get_error(), NULL));
        }
 }
index 1409710fbc7201853729d97f8f2b7cec2c0b7cc5..ccc71f07c2964162b027260b57e4b82870c45d36 100644 (file)
@@ -311,10 +311,10 @@ mock_assert(const int result, const char *const expression,
  */
 #include <isc/error.h> /* Contractual promise. */
 
-/*% Unexpected Error */
-#define UNEXPECTED_ERROR isc_error_unexpected
-/*% Fatal Error */
-#define FATAL_ERROR isc_error_fatal
+#define UNEXPECTED_ERROR(...) \
+       isc_error_unexpected(__FILE__, __LINE__, __VA_ARGS__)
+
+#define FATAL_ERROR(...) isc_error_fatal(__FILE__, __LINE__, __VA_ARGS__)
 
 #ifdef UNIT_TESTING
 
@@ -325,7 +325,6 @@ mock_assert(const int result, const char *const expression,
 
 #else /* UNIT_TESTING */
 
-/*% Runtime Check */
 #define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
 
 #endif /* UNIT_TESTING */
index abb16f4b6da0683dc1300ae059fed76e12ebe080..566c5bd4651b8bf15f06db73825a2a33933b89fd 100644 (file)
@@ -202,8 +202,7 @@ isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
 
        if (getifaddrs(&iter->ifaddrs) < 0) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "getting interface addresses: getifaddrs: %s",
+               UNEXPECTED_ERROR("getting interface addresses: getifaddrs: %s",
                                 strbuf);
                result = ISC_R_UNEXPECTED;
                goto failure;
index 50218b78b398779cb5e79a9a2ee2be52a4df3200..63b9b79d343d174c77297dd0bb41c364272ca753 100644 (file)
@@ -902,8 +902,7 @@ isc_lex_gettoken(isc_lex_t *lex, unsigned int options, isc_token_t *tokenp) {
                        remaining--;
                        break;
                default:
-                       FATAL_ERROR(__FILE__, __LINE__, "Unexpected state %d",
-                                   state);
+                       FATAL_ERROR("Unexpected state %d", state);
                }
        } while (!done);
 
index 63ef09e5b40585e60af1b337ecdcdb20144a6bba..5e9a6c3731207006ef03092bf843d752d6634af2 100644 (file)
@@ -37,8 +37,7 @@ isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
                INSIST(netmgr != NULL);
                result = isc__taskmgr_create(mctx, quantum, netmgr, &taskmgr);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_taskmgr_create() failed: %s",
+                       UNEXPECTED_ERROR("isc_taskmgr_create() failed: %s",
                                         isc_result_totext(result));
                        goto fail;
                }
@@ -49,8 +48,7 @@ isc_managers_create(isc_mem_t *mctx, size_t workers, size_t quantum,
        if (timermgrp != NULL) {
                result = isc__timermgr_create(mctx, &timermgr);
                if (result != ISC_R_SUCCESS) {
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "isc_timermgr_create() failed: %s",
+                       UNEXPECTED_ERROR("isc_timermgr_create() failed: %s",
                                         isc_result_totext(result));
                        goto fail;
                }
index f828672119ef9c96ebaaaa3ea5055453fadbf1f1..9af25e600a87841dd579c7ac04a61074d42d932e 100644 (file)
@@ -1236,10 +1236,9 @@ isc__mempool_destroy(isc_mempool_t **restrict mpctxp FLARG) {
 #endif
 
        if (mpctx->allocated > 0) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "isc_mempool_destroy(): mempool %s "
-                                "leaked memory",
-                                mpctx->name);
+               UNEXPECTED_ERROR(
+                       "isc_mempool_destroy(): mempool %s leaked memory",
+                       mpctx->name);
        }
        REQUIRE(mpctx->allocated == 0);
 
index efb9ff1ccf5f8813d68f111ab2fa94fbb5526361..2367c08f5b9fbc04581c64ff5612f4e1139b361f 100644 (file)
@@ -142,8 +142,7 @@ try_proto(int domain) {
                        return (ISC_R_NOTFOUND);
                default:
                        strerror_r(errno, strbuf, sizeof(strbuf));
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "socket() failed: %s", strbuf);
+                       UNEXPECTED_ERROR("socket() failed: %s", strbuf);
                        return (ISC_R_UNEXPECTED);
                }
        }
@@ -241,8 +240,7 @@ try_ipv6only(void) {
        s = socket(PF_INET6, SOCK_STREAM, 0);
        if (s == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "socket() failed: %s",
-                                strbuf);
+               UNEXPECTED_ERROR("socket() failed: %s", strbuf);
                ipv6only_result = ISC_R_UNEXPECTED;
                return;
        }
@@ -259,8 +257,7 @@ try_ipv6only(void) {
        s = socket(PF_INET6, SOCK_DGRAM, 0);
        if (s == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "socket() failed: %s",
-                                strbuf);
+               UNEXPECTED_ERROR("socket() failed: %s", strbuf);
                ipv6only_result = ISC_R_UNEXPECTED;
                return;
        }
@@ -303,8 +300,7 @@ try_ipv6pktinfo(void) {
        s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
        if (s == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "socket() failed: %s",
-                                strbuf);
+               UNEXPECTED_ERROR("socket() failed: %s", strbuf);
                ipv6pktinfo_result = ISC_R_UNEXPECTED;
                return;
        }
@@ -424,13 +420,12 @@ make_nonblock(int fd) {
 
        if (ret == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
 #ifdef USE_FIONBIO_IOCTL
-                                "ioctl(%d, FIONBIO, &on): %s", fd,
+               UNEXPECTED_ERROR("ioctl(%d, FIONBIO, &on): %s", fd, strbuf);
 #else  /* ifdef USE_FIONBIO_IOCTL */
-                                "fcntl(%d, F_SETFL, %d): %s", fd, flags,
-#endif /* ifdef USE_FIONBIO_IOCTL */
+               UNEXPECTED_ERROR("fcntl(%d, F_SETFL, %d): %s", fd, flags,
                                 strbuf);
+#endif /* ifdef USE_FIONBIO_IOCTL */
 
                return (ISC_R_UNEXPECTED);
        }
@@ -511,7 +506,6 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
 
        if (sendmsg(s, &msg, 0) < 0) {
                int debug = ISC_LOG_DEBUG(10);
-               const char *typestr;
                switch (errno) {
 #ifdef ENOPROTOOPT
                case ENOPROTOOPT:
@@ -531,11 +525,10 @@ cmsgsend(int s, int level, int type, struct addrinfo *res) {
                                      ISC_LOGMODULE_SOCKET, ISC_LOG_DEBUG(10),
                                      "sendmsg: %s", strbuf);
                } else {
-                       typestr = (type == IP_TOS) ? "IP_TOS" : "IPV6_TCLASS";
-                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                        "probing "
-                                        "sendmsg() with %s=%02x failed: %s",
-                                        typestr, dscp, strbuf);
+                       UNEXPECTED_ERROR(
+                               "probing sendmsg() with %s=%02x failed: %s",
+                               (type == IP_TOS) ? "IP_TOS" : "IPV6_TCLASS",
+                               dscp, strbuf);
                }
                return (false);
        }
index 0aba2b8b599603e40a55a1deda529143e8e60a15..2a51fe35caff323c48a1e4fafdc241fe97295443 100644 (file)
@@ -2235,10 +2235,9 @@ isc__nmsocket_readtimeout_cb(uv_timer_t *timer);
 void
 isc__nmsocket_writetimeout_cb(void *data, isc_result_t eresult);
 
-#define UV_RUNTIME_CHECK(func, ret)                                           \
-       if (ret != 0) {                                                       \
-               isc_error_fatal(__FILE__, __LINE__, "%s failed: %s\n", #func, \
-                               uv_strerror(ret));                            \
+#define UV_RUNTIME_CHECK(func, ret)                                      \
+       if (ret != 0) {                                                  \
+               FATAL_ERROR("%s failed: %s\n", #func, uv_strerror(ret)); \
        }
 
 void
index 2691a44de440f27b07c9b908cc7b6b4395a020fd..9a56dc30a15bc3fccc12fb6b4905cc76a85644ae 100644 (file)
@@ -208,8 +208,7 @@ isc_rwlock_init(isc_rwlock_t *rwl, unsigned int read_quota,
        rwl->readers_waiting = 0;
        atomic_init(&rwl->write_granted, 0);
        if (read_quota != 0) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "read quota is not supported");
+               UNEXPECTED_ERROR("read quota is not supported");
        }
        if (write_quota == 0) {
                write_quota = RWLOCK_DEFAULT_WRITE_QUOTA;
index 85b3d284394ce7a9f18a7e3651e9afd7d3a58df5..038e3ec7c42273e8a5f4148017d698ce5903b6a5 100644 (file)
@@ -234,8 +234,7 @@ isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, bool address_only) {
                p = ntohs(sockaddr->type.sin6.sin6_port);
                break;
        default:
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "unknown address family: %d",
+               UNEXPECTED_ERROR("unknown address family: %d",
                                 (int)sockaddr->type.sa.sa_family);
                s = (const unsigned char *)&sockaddr->type;
                length = sockaddr->length;
@@ -341,7 +340,7 @@ isc_sockaddr_pf(const isc_sockaddr_t *sockaddr) {
        case AF_INET6:
                return (PF_INET6);
        default:
-               FATAL_ERROR(__FILE__, __LINE__, "unknown address family: %d",
+               FATAL_ERROR("unknown address family: %d",
                            (int)sockaddr->type.sa.sa_family);
        }
 #endif /* if (AF_INET == PF_INET && AF_INET6 == PF_INET6) */
@@ -380,7 +379,7 @@ isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) {
                sockaddr->type.sin6.sin6_port = htons(port);
                break;
        default:
-               FATAL_ERROR(__FILE__, __LINE__, "unknown address family: %d",
+               FATAL_ERROR("unknown address family: %d",
                            (int)sockaddr->type.sa.sa_family);
        }
 }
@@ -397,7 +396,7 @@ isc_sockaddr_getport(const isc_sockaddr_t *sockaddr) {
                port = ntohs(sockaddr->type.sin6.sin6_port);
                break;
        default:
-               FATAL_ERROR(__FILE__, __LINE__, "unknown address family: %d",
+               FATAL_ERROR("unknown address family: %d",
                            (int)sockaddr->type.sa.sa_family);
        }
 
index 4f6c4a03c33fd9d221b8fd4cd45447bca0c4cf96..a3bd27d42e3e6d70f2456608fc139968dc42e6f2 100644 (file)
@@ -137,7 +137,7 @@ time_now(isc_time_t *t, clockid_t clock) {
 
        if (clock_gettime(clock, &ts) == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
+               UNEXPECTED_ERROR("%s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
 
@@ -181,7 +181,7 @@ isc_time_nowplusinterval(isc_time_t *t, const isc_interval_t *i) {
 
        if (clock_gettime(CLOCKSOURCE, &ts) == -1) {
                strerror_r(errno, strbuf, sizeof(strbuf));
-               UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
+               UNEXPECTED_ERROR("%s", strbuf);
                return (ISC_R_UNEXPECTED);
        }
 
index 30de75632fda24edc9eb8a36825ff329d5db8557..a9d15cb390840e36cbcfdbd175970903d1edb19f 100644 (file)
@@ -24,6 +24,7 @@
 #include <isc/once.h>
 #include <isc/print.h>
 #include <isc/refcount.h>
+#include <isc/result.h>
 #include <isc/task.h>
 #include <isc/thread.h>
 #include <isc/time.h>
@@ -565,9 +566,7 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
                                        isc_task_send(timer->task,
                                                      ISC_EVENT_PTR(&event));
                                } else {
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "%s",
-                                                        "couldn't allocate "
+                                       UNEXPECTED_ERROR("couldn't allocate "
                                                         "event");
                                }
                        }
@@ -579,11 +578,9 @@ dispatch(isc_timermgr_t *manager, isc_time_t *now) {
                        if (need_schedule) {
                                result = schedule(timer, now, false);
                                if (result != ISC_R_SUCCESS) {
-                                       UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                        "%s: %u",
-                                                        "couldn't schedule "
-                                                        "timer",
-                                                        result);
+                                       UNEXPECTED_ERROR(
+                                               "couldn't schedule timer: %s",
+                                               isc_result_totext(result));
                                }
                        }
                } else {
index 4dc848260ea9f2c5c4b676a678d9b0d651df2deb..f92a6ac0498f426eb4169814ffadddc9a5017dfd 100644 (file)
@@ -122,8 +122,7 @@ tls_initialize(void) {
 
        /* Protect ourselves against unseeded PRNG */
        if (RAND_status() != 1) {
-               FATAL_ERROR(__FILE__, __LINE__,
-                           "OpenSSL pseudorandom number generator "
+               FATAL_ERROR("OpenSSL pseudorandom number generator "
                            "cannot be initialized (see the `PRNG not "
                            "seeded' message in the OpenSSL FAQ)");
        }
index d02493244ec6f61083a2314b991c966efd2f22f8..10deb55fb92118f73c01384dda9b89ba59e644b5 100644 (file)
@@ -1317,8 +1317,7 @@ do_scan(ns_interfacemgr_t *mgr, bool verbose, bool config) {
                continue;
        }
        if (result != ISC_R_NOMORE) {
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "interface iteration failed: %s",
+               UNEXPECTED_ERROR("interface iteration failed: %s",
                                 isc_result_totext(result));
        } else {
                result = ((tried_listening && all_addresses_in_use)
index 3e6a3517e9001688123ce681a95910a3acc39802..2aada90b196edb996ad7a712f514afca0d2f3fa6 100644 (file)
@@ -173,10 +173,9 @@ ns_sortlist_byaddrsetup(dns_acl_t *sortlist_acl, dns_aclenv_t *env,
                *orderp = NULL;
                break;
        default:
-               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                "unexpected return from ns_sortlist_setup(): "
-                                "%d",
-                                sortlisttype);
+               UNEXPECTED_ERROR(
+                       "unexpected return from ns_sortlist_setup(): %d",
+                       sortlisttype);
                break;
        }
 }
index 24bd3c36776ea023c7a3b8c2b8f4e58137aaff91..a0599cad654c7f9d2ec6489facaf3bfa4a026981 100644 (file)
@@ -2746,10 +2746,9 @@ update_action(isc_task_t *task, isc_event_t *event) {
                        /* "temp<rr.name, rr.type> += rr;" */
                        result = temp_append(&temp, name, &rdata);
                        if (result != ISC_R_SUCCESS) {
-                               UNEXPECTED_ERROR(__FILE__, __LINE__,
-                                                "temp entry creation failed: "
-                                                "%s",
-                                                isc_result_totext(result));
+                               UNEXPECTED_ERROR(
+                                       "temp entry creation failed: %s",
+                                       isc_result_totext(result));
                                FAIL(ISC_R_UNEXPECTED);
                        }
                } else {