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;
}
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);
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);
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);
}
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);
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);
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()));
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;
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);
}
if (taskmgr != NULL) {
result = isc_task_create(taskmgr, &cleaner->task, 0);
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_iterator;
* 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);
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);
* 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));
*/
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));
/*
{
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);
}
freenode:
dns_db_detachnode(db, &node);
nonode:
- UNEXPECTED_ERROR(__FILE__, __LINE__, "missing SOA");
+ UNEXPECTED_ERROR("missing SOA");
return (result);
}
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));
}
}
}
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);
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",
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;
}
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)) {
}
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)) {
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);
}
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);
}
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));
}
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);
}
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);
}
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);
}
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);
}
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);
}
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;
}
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);
}
}
break;
default:
- FATAL_ERROR(__FILE__, __LINE__, "Unexpected state %d",
- state);
+ FATAL_ERROR("Unexpected state %d", state);
/* Does not return. */
}
}
count--;
}
} else {
- FATAL_ERROR(__FILE__, __LINE__,
- "Unexpected label type %02x", count);
+ FATAL_ERROR("Unexpected label type %02x", count);
UNREACHABLE();
}
count--;
}
} else {
- FATAL_ERROR(__FILE__, __LINE__,
- "Unexpected label type %02x", count);
+ FATAL_ERROR("Unexpected label type %02x", count);
UNREACHABLE();
}
state = fw_start;
break;
default:
- FATAL_ERROR(__FILE__, __LINE__, "Unknown state %d",
- state);
+ FATAL_ERROR("Unknown state %d", state);
/* Does not return. */
}
}
UNUSED(rdataset);
UNUSED(sigrdataset);
- FATAL_ERROR(__FILE__, __LINE__, "zone_findzonecut() called!");
+ FATAL_ERROR("zone_findzonecut() called!");
UNREACHABLE();
return (ISC_R_NOTIMPLEMENTED);
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;
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;
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;
case DNS_RPZ_TYPE_BAD:
break;
}
- FATAL_ERROR(__FILE__, __LINE__, "impossible rpz type %d", type);
+ FATAL_ERROR("impossible rpz type %d", type);
return ("impossible");
}
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;
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;
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;
}
} 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);
}
#include <isc/error.h> /* Contractual promise. */
#include <isc/strerr.h> /* for ISC_STRERRORSIZE */
-/*% 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
#else /* UNIT_TESTING */
-/*% Runtime Check */
#define RUNTIME_CHECK(cond) ISC_ERROR_RUNTIMECHECK(cond)
#endif /* UNIT_TESTING */
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;
remaining--;
break;
default:
- FATAL_ERROR(__FILE__, __LINE__, "Unexpected state %d",
- state);
+ FATAL_ERROR("Unexpected state %d", state);
}
} while (!done);
#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);
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);
}
}
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;
}
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;
}
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;
}
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);
}
if (sendmsg(s, &msg, 0) < 0) {
int debug = ISC_LOG_DEBUG(10);
- const char *typestr;
switch (errno) {
#ifdef ENOPROTOOPT
case ENOPROTOOPT:
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);
}
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;
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;
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) */
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);
}
}
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);
}
if (clock_gettime(clock, &ts) == -1) {
char strbuf[ISC_STRERRORSIZE];
strerror_r(errno, strbuf, sizeof(strbuf));
- UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
+ UNEXPECTED_ERROR("%s", strbuf);
return (ISC_R_UNEXPECTED);
}
if (clock_gettime(CLOCKSOURCE, &ts) == -1) {
char strbuf[ISC_STRERRORSIZE];
strerror_r(errno, strbuf, sizeof(strbuf));
- UNEXPECTED_ERROR(__FILE__, __LINE__, "%s", strbuf);
+ UNEXPECTED_ERROR("%s", strbuf);
return (ISC_R_UNEXPECTED);
}
/* 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)");
}
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)
*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;
}
}
/* "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 {