diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 38387b172b..4c78c9cd7f 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -553,7 +553,7 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) { isc_logconfig_t *logconfig = NULL; isc_log_t *log = NULL; - RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS); + isc_log_create(mctx, &log, &logconfig); isc_log_registercategories(log, categories); isc_log_setcontext(log); dns_log_init(log); @@ -565,9 +565,9 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, 0) == ISC_R_SUCCESS); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); + RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == ISC_R_SUCCESS); diff --git a/bin/delv/delv.c b/bin/delv/delv.c index c4bdbb4b3a..0525b2c6fa 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -271,11 +271,7 @@ setup_logging(FILE *errout) { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - result = isc_log_create(mctx, &lctx, &logconfig); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set up logging"); - } - + isc_log_create(mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_registermodules(lctx, modules); isc_log_setcontext(lctx); @@ -287,20 +283,12 @@ setup_logging(FILE *errout) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - - result = isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTPREFIX); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set up log channel 'stderr'"); - } + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, + ISC_LOG_PRINTPREFIX); isc_log_setdebuglevel(lctx, loglevel); - - result = isc_log_settag(logconfig, ";; "); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set log tag"); - } + isc_log_settag(logconfig, ";; "); result = isc_log_usechannel(logconfig, "stderr", ISC_LOGCATEGORY_DEFAULT, NULL); @@ -309,12 +297,9 @@ setup_logging(FILE *errout) { } if (resolve_trace && loglevel < 1) { - result = isc_log_createchannel( - logconfig, "resolver", ISC_LOG_TOFILEDESC, - ISC_LOG_DEBUG(1), &destination, ISC_LOG_PRINTPREFIX); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set up log channel 'resolver'"); - } + isc_log_createchannel(logconfig, "resolver", ISC_LOG_TOFILEDESC, + ISC_LOG_DEBUG(1), &destination, + ISC_LOG_PRINTPREFIX); result = isc_log_usechannel(logconfig, "resolver", DNS_LOGCATEGORY_RESOLVER, @@ -325,12 +310,9 @@ setup_logging(FILE *errout) { } if (validator_trace && loglevel < 3) { - result = isc_log_createchannel( - logconfig, "validator", ISC_LOG_TOFILEDESC, - ISC_LOG_DEBUG(3), &destination, ISC_LOG_PRINTPREFIX); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set up log channel 'validator'"); - } + isc_log_createchannel(logconfig, "validator", + ISC_LOG_TOFILEDESC, ISC_LOG_DEBUG(3), + &destination, ISC_LOG_PRINTPREFIX); result = isc_log_usechannel(logconfig, "validator", DNS_LOGCATEGORY_DNSSEC, @@ -341,12 +323,9 @@ setup_logging(FILE *errout) { } if (message_trace && loglevel < 10) { - result = isc_log_createchannel( - logconfig, "messages", ISC_LOG_TOFILEDESC, - ISC_LOG_DEBUG(10), &destination, ISC_LOG_PRINTPREFIX); - if (result != ISC_R_SUCCESS) { - fatal("Couldn't set up log channel 'messages'"); - } + isc_log_createchannel(logconfig, "messages", ISC_LOG_TOFILEDESC, + ISC_LOG_DEBUG(10), &destination, + ISC_LOG_PRINTPREFIX); result = isc_log_usechannel(logconfig, "messages", DNS_LOGCATEGORY_RESOLVER, diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index 85e725c030..4a4d0b6773 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -1394,9 +1394,7 @@ setup_libs(void) { isc_mem_create(&mctx); isc_mem_setname(mctx, "dig", NULL); - result = isc_log_create(mctx, &lctx, &logconfig); - check_result(result, "isc_log_create"); - + isc_log_create(mctx, &lctx, &logconfig); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 7b0ba04e25..265f557e5a 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -128,7 +128,6 @@ sig_format(dns_rdata_rrsig_t *sig, char *cp, unsigned int size) { void setup_logging(isc_mem_t *mctx, isc_log_t **logp) { - isc_result_t result; isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; isc_log_t *log = NULL; @@ -153,12 +152,11 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) { break; } - RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS); + isc_log_create(mctx, &log, &logconfig); isc_log_setcontext(log); dns_log_init(log); dns_log_setcontext(log); - - RUNTIME_CHECK(isc_log_settag(logconfig, program) == ISC_R_SUCCESS); + isc_log_settag(logconfig, program); /* * Set up a channel similar to default_stderr except: @@ -170,10 +168,9 @@ setup_logging(isc_mem_t *mctx, isc_log_t **logp) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - level, &destination, - ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); - check_result(result, "isc_log_createchannel()"); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, level, + &destination, + ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == ISC_R_SUCCESS); diff --git a/bin/named/include/named/log.h b/bin/named/include/named/log.h index 1cc8414e1f..6abe078416 100644 --- a/bin/named/include/named/log.h +++ b/bin/named/include/named/log.h @@ -45,7 +45,7 @@ named_log_init(bool safe); * as root. */ -isc_result_t +void named_log_setdefaultchannels(isc_logconfig_t *lcfg); /*% * Set up logging channels according to the named defaults, which @@ -53,7 +53,7 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg); * this just means setting up default_debug. */ -isc_result_t +void named_log_setsafechannels(isc_logconfig_t *lcfg); /*% * Like named_log_setdefaultchannels(), but omits any logging to files. diff --git a/bin/named/log.c b/bin/named/log.c index e36fd0e2f8..770154e24c 100644 --- a/bin/named/log.c +++ b/bin/named/log.c @@ -53,10 +53,7 @@ named_log_init(bool safe) { /* * Setup a logging context. */ - result = isc_log_create(named_g_mctx, &named_g_lctx, &lcfg); - if (result != ISC_R_SUCCESS) { - return (result); - } + isc_log_create(named_g_mctx, &named_g_lctx, &lcfg); /* * named-checktool.c:setup_logging() needs to be kept in sync. @@ -71,12 +68,9 @@ named_log_init(bool safe) { ns_log_setcontext(named_g_lctx); if (safe) { - result = named_log_setsafechannels(lcfg); + named_log_setsafechannels(lcfg); } else { - result = named_log_setdefaultchannels(lcfg); - } - if (result != ISC_R_SUCCESS) { - goto cleanup; + named_log_setdefaultchannels(lcfg); } result = named_log_setdefaultcategory(lcfg); @@ -94,9 +88,8 @@ cleanup: return (result); } -isc_result_t +void named_log_setdefaultchannels(isc_logconfig_t *lcfg) { - isc_result_t result; isc_logdestination_t destination; /* @@ -109,12 +102,9 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg) { destination.file.name = "named.run"; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel( - lcfg, "default_debug", ISC_LOG_TOFILE, ISC_LOG_DYNAMIC, - &destination, ISC_LOG_PRINTTIME | ISC_LOG_DEBUGONLY); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TOFILE, + ISC_LOG_DYNAMIC, &destination, + ISC_LOG_PRINTTIME | ISC_LOG_DEBUGONLY); } if (named_g_logfile != NULL) { @@ -122,48 +112,32 @@ named_log_setdefaultchannels(isc_logconfig_t *lcfg) { destination.file.name = named_g_logfile; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel( - lcfg, "default_logfile", ISC_LOG_TOFILE, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY | - ISC_LOG_PRINTLEVEL); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_logfile", ISC_LOG_TOFILE, + ISC_LOG_DYNAMIC, &destination, + ISC_LOG_PRINTTIME | + ISC_LOG_PRINTCATEGORY | + ISC_LOG_PRINTLEVEL); } #if ISC_FACILITY != LOG_DAEMON destination.facility = ISC_FACILITY; - result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, - ISC_LOG_INFO, &destination, 0); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, + ISC_LOG_INFO, &destination, 0); #endif /* if ISC_FACILITY != LOG_DAEMON */ /* * Set the initial debug level. */ isc_log_setdebuglevel(named_g_lctx, named_g_debuglevel); - - result = ISC_R_SUCCESS; - -cleanup: - return (result); } -isc_result_t +void named_log_setsafechannels(isc_logconfig_t *lcfg) { - isc_result_t result; isc_logdestination_t destination; if (!named_g_logstderr) { - result = isc_log_createchannel(lcfg, "default_debug", - ISC_LOG_TONULL, ISC_LOG_DYNAMIC, - NULL, 0); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TONULL, + ISC_LOG_DYNAMIC, NULL, 0); /* * Setting the debug level to zero should get the output @@ -179,29 +153,18 @@ named_log_setsafechannels(isc_logconfig_t *lcfg) { destination.file.name = named_g_logfile; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel( - lcfg, "default_logfile", ISC_LOG_TOFILE, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME | ISC_LOG_PRINTCATEGORY | - ISC_LOG_PRINTLEVEL); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_logfile", ISC_LOG_TOFILE, + ISC_LOG_DYNAMIC, &destination, + ISC_LOG_PRINTTIME | + ISC_LOG_PRINTCATEGORY | + ISC_LOG_PRINTLEVEL); } #if ISC_FACILITY != LOG_DAEMON destination.facility = ISC_FACILITY; - result = isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, - ISC_LOG_INFO, &destination, 0); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, + ISC_LOG_INFO, &destination, 0); #endif /* if ISC_FACILITY != LOG_DAEMON */ - - result = ISC_R_SUCCESS; - -cleanup: - return (result); } isc_result_t diff --git a/bin/named/logconf.c b/bin/named/logconf.c index 8759a2a623..4696886cf1 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -92,7 +92,7 @@ category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) { */ static isc_result_t channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) { - isc_result_t result; + isc_result_t result = ISC_R_SUCCESS; isc_logdestination_t dest; unsigned int type; unsigned int flags = 0; @@ -271,14 +271,12 @@ channel_fromconf(const cfg_obj_t *channel, isc_logconfig_t *logconfig) { } } - if (logconfig == NULL) { - result = ISC_R_SUCCESS; - } else { - result = isc_log_createchannel(logconfig, channelname, type, - level, &dest, flags); + if (logconfig != NULL) { + isc_log_createchannel(logconfig, channelname, type, level, + &dest, flags); } - if (result == ISC_R_SUCCESS && type == ISC_LOG_TOFILE) { + if (type == ISC_LOG_TOFILE) { FILE *fp; /* @@ -333,7 +331,7 @@ named_logconfig(isc_logconfig_t *logconfig, const cfg_obj_t *logstmt) { const cfg_obj_t *catname; if (logconfig != NULL) { - CHECK(named_log_setdefaultchannels(logconfig)); + named_log_setdefaultchannels(logconfig); } (void)cfg_map_get(logstmt, "channel", &channels); diff --git a/bin/named/server.c b/bin/named/server.c index 2836429de3..3a927b01bd 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -9110,8 +9110,7 @@ load_configuration(const char *filename, named_server_t *server, } else { const cfg_obj_t *logobj = NULL; - CHECKM(isc_logconfig_create(named_g_lctx, &logc), - "creating new logging configuration"); + isc_logconfig_create(named_g_lctx, &logc); logobj = NULL; (void)cfg_map_get(config, "logging", &logobj); @@ -9119,16 +9118,14 @@ load_configuration(const char *filename, named_server_t *server, CHECKM(named_logconfig(logc, logobj), "configuring " "logging"); } else { - CHECKM(named_log_setdefaultchannels(logc), - "setting up default logging channels"); + named_log_setdefaultchannels(logc); CHECKM(named_log_setunmatchedcategory(logc), "setting up default 'category unmatched'"); CHECKM(named_log_setdefaultcategory(logc), "setting up default 'category default'"); } - CHECKM(isc_logconfig_use(named_g_lctx, logc), - "installing logging configuration"); + isc_logconfig_use(named_g_lctx, logc); logc = NULL; isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL, diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 9144a7570c..ce3798968d 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -812,9 +812,7 @@ setup_system(void) { dns_result_register(); - result = isc_log_create(gmctx, &glctx, &logconfig); - check_result(result, "isc_log_create"); - + isc_log_create(gmctx, &glctx, &logconfig); isc_log_setcontext(glctx); dns_log_init(glctx); dns_log_setcontext(glctx); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index 6a3b2f3b2b..b6e7a18664 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -985,18 +985,16 @@ main(int argc, char **argv) { isc_taskmgr_create(rndc_mctx, 1, 0, NULL, &taskmgr)); DO("create task", isc_task_create(taskmgr, 0, &task)); - DO("create logging context", - isc_log_create(rndc_mctx, &log, &logconfig)); + isc_log_create(rndc_mctx, &log, &logconfig); isc_log_setcontext(log); - DO("setting log tag", isc_log_settag(logconfig, progname)); + isc_log_settag(logconfig, progname); logdest.file.stream = stderr; logdest.file.name = NULL; logdest.file.versions = ISC_LOG_ROLLNEVER; logdest.file.maximum_size = 0; - DO("creating log channel", - isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - ISC_LOG_INFO, &logdest, - ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_INFO, &logdest, + ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); DO("enabling log channel", isc_log_usechannel(logconfig, "stderr", NULL, NULL)); diff --git a/bin/tests/cfg_test.c b/bin/tests/cfg_test.c index cab9b42a28..0ecab243f4 100644 --- a/bin/tests/cfg_test.c +++ b/bin/tests/cfg_test.c @@ -72,8 +72,7 @@ main(int argc, char **argv) { isc_mem_create(&mctx); - result = isc_log_create(mctx, &lctx, &lcfg); - check_result(result, "isc_log_create()"); + isc_log_create(mctx, &lctx, &lcfg); isc_log_setcontext(lctx); /* @@ -83,10 +82,9 @@ main(int argc, char **argv) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME); - check_result(result, "isc_log_createchannel()"); + isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); + result = isc_log_usechannel(lcfg, "_default", NULL, NULL); check_result(result, "isc_log_usechannel()"); diff --git a/bin/tests/makejournal.c b/bin/tests/makejournal.c index a545738d02..29a2580803 100644 --- a/bin/tests/makejournal.c +++ b/bin/tests/makejournal.c @@ -100,7 +100,7 @@ main(int argc, char **argv) { CHECK(dst_lib_init(mctx, NULL)); dst_active = true; - CHECK(isc_log_create(mctx, &lctx, &logconfig)); + isc_log_create(mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_setcontext(lctx); dns_log_init(lctx); @@ -110,8 +110,9 @@ main(int argc, char **argv) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); + CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); dns_result_register(); diff --git a/bin/tests/optional/adb_test.c b/bin/tests/optional/adb_test.c index 38e965bcf2..b232914574 100644 --- a/bin/tests/optional/adb_test.c +++ b/bin/tests/optional/adb_test.c @@ -297,8 +297,7 @@ main(int argc, char **argv) { isc_mempool_create(mctx, sizeof(client_t), &cmp); isc_mempool_setname(cmp, "adb test clients"); - result = isc_log_create(mctx, &lctx, &lcfg); - check_result(result, "isc_log_create()"); + isc_log_create(mctx, &lctx, &lcfg); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); @@ -310,10 +309,9 @@ main(int argc, char **argv) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - result = isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME); - check_result(result, "isc_log_createchannel()"); + isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); + result = isc_log_usechannel(lcfg, "_default", NULL, NULL); check_result(result, "isc_log_usechannel()"); diff --git a/bin/tests/optional/byname_test.c b/bin/tests/optional/byname_test.c index 6ee3437621..a80160a690 100644 --- a/bin/tests/optional/byname_test.c +++ b/bin/tests/optional/byname_test.c @@ -56,7 +56,7 @@ log_init(void) { /* * Setup a logging context. */ - RUNTIME_CHECK(isc_log_create(mctx, &lctx, &lcfg) == ISC_R_SUCCESS); + isc_log_create(mctx, &lctx, &lcfg); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); @@ -69,10 +69,9 @@ log_init(void) { destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; flags = ISC_LOG_PRINTTIME; - RUNTIME_CHECK(isc_log_createchannel(lcfg, "_default", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, - flags) == ISC_R_SUCCESS); + isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, flags); + RUNTIME_CHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL) == ISC_R_SUCCESS); isc_log_setdebuglevel(lctx, level); diff --git a/bin/tests/optional/db_test.c b/bin/tests/optional/db_test.c index 465e0d1053..f4325ba171 100644 --- a/bin/tests/optional/db_test.c +++ b/bin/tests/optional/db_test.c @@ -402,8 +402,7 @@ main(int argc, char *argv[]) { DNS_DBFIND_VALIDATEGLUE); break; case 'l': - RUNTIME_CHECK(isc_log_create(mctx, &lctx, NULL) == - ISC_R_SUCCESS); + isc_log_create(mctx, &lctx, NULL); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); diff --git a/bin/tests/optional/gsstest.c b/bin/tests/optional/gsstest.c index dd005c084b..dfc1052435 100644 --- a/bin/tests/optional/gsstest.c +++ b/bin/tests/optional/gsstest.c @@ -458,7 +458,7 @@ main(int argc, char *argv[]) { mctx = NULL; isc_mem_create(&mctx); - RUNCHECK(isc_log_create(mctx, &lctx, &lcfg)); + isc_log_create(mctx, &lctx, &lcfg); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); @@ -470,9 +470,9 @@ main(int argc, char *argv[]) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - RUNCHECK(isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME)); + isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); + RUNCHECK(isc_log_usechannel(lcfg, "_default", NULL, NULL)); isc_log_setdebuglevel(lctx, 9); diff --git a/bin/tests/optional/log_test.c b/bin/tests/optional/log_test.c index 3fdd270546..750bcccc5c 100644 --- a/bin/tests/optional/log_test.c +++ b/bin/tests/optional/log_test.c @@ -112,9 +112,9 @@ main(int argc, char **argv) { lcfg = NULL; isc_mem_create(&mctx); - CHECK(isc_log_create(mctx, &lctx, &lcfg)); + isc_log_create(mctx, &lctx, &lcfg); - CHECK(isc_log_settag(lcfg, progname)); + isc_log_settag(lcfg, progname); isc_log_setcontext(lctx); dns_log_init(lctx); @@ -147,20 +147,20 @@ main(int argc, char **argv) { destination.file.maximum_size = 1; destination.file.versions = file_versions; - CHECK(isc_log_createchannel( + isc_log_createchannel( lcfg, "file_test", ISC_LOG_TOFILE, ISC_LOG_INFO, &destination, ISC_LOG_PRINTTIME | ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL | - ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE)); + ISC_LOG_PRINTCATEGORY | ISC_LOG_PRINTMODULE); /* * Create a dynamic debugging channel to a file descriptor. */ destination.file.stream = stderr; - CHECK(isc_log_createchannel(lcfg, "debug_test", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL | - ISC_LOG_DEBUGONLY)); + isc_log_createchannel(lcfg, "debug_test", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, + ISC_LOG_PRINTTIME | ISC_LOG_PRINTLEVEL | + ISC_LOG_DEBUGONLY); /* * Test the usability of the four predefined logging channels. diff --git a/bin/tests/optional/sig0_test.c b/bin/tests/optional/sig0_test.c index 9efcc70b1e..233fc5914d 100644 --- a/bin/tests/optional/sig0_test.c +++ b/bin/tests/optional/sig0_test.c @@ -236,7 +236,7 @@ main(int argc, char *argv[]) { socketmgr = NULL; RUNTIME_CHECK(isc_socketmgr_create(mctx, &socketmgr) == ISC_R_SUCCESS); - RUNTIME_CHECK(isc_log_create(mctx, &lctx, &logconfig) == ISC_R_SUCCESS); + isc_log_create(mctx, &lctx, &logconfig); s = NULL; RUNTIME_CHECK(isc_socket_create(socketmgr, PF_INET, isc_sockettype_udp, diff --git a/bin/tests/system/pipelined/pipequeries.c b/bin/tests/system/pipelined/pipequeries.c index cec9de7cb1..4a10624dea 100644 --- a/bin/tests/system/pipelined/pipequeries.c +++ b/bin/tests/system/pipelined/pipequeries.c @@ -274,7 +274,7 @@ main(int argc, char *argv[]) { lctx = NULL; lcfg = NULL; - RUNCHECK(isc_log_create(mctx, &lctx, &lcfg)); + isc_log_create(mctx, &lctx, &lcfg); RUNCHECK(dst_lib_init(mctx, NULL)); diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c index fcb8f6932a..f18f9fdeb8 100644 --- a/bin/tests/system/rsabigexponent/bigkey.c +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -107,19 +107,20 @@ main(int argc, char **argv) { isc_mem_create(&mctx); CHECK(dst_lib_init(mctx, NULL), "dst_lib_init()"); - CHECK(isc_log_create(mctx, &log_, &logconfig), "isc_log_create()"); + isc_log_create(mctx, &log_, &logconfig); isc_log_setcontext(log_); dns_log_init(log_); dns_log_setcontext(log_); - CHECK(isc_log_settag(logconfig, "bigkey"), "isc_log_settag()"); + isc_log_settag(logconfig, "bigkey"); + destination.file.stream = stderr; destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - level, &destination, - ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL), - "isc_log_createchannel()"); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, level, + &destination, + ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); + CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL), "isc_log_" "usechannel(" ")"); diff --git a/bin/tests/system/tkey/keycreate.c b/bin/tests/system/tkey/keycreate.c index c14e5c1065..cf15fd3544 100644 --- a/bin/tests/system/tkey/keycreate.c +++ b/bin/tests/system/tkey/keycreate.c @@ -232,7 +232,7 @@ main(int argc, char *argv[]) { log = NULL; logconfig = NULL; - RUNCHECK(isc_log_create(mctx, &log, &logconfig)); + isc_log_create(mctx, &log, &logconfig); RUNCHECK(dst_lib_init(mctx, NULL)); diff --git a/bin/tests/system/tkey/keydelete.c b/bin/tests/system/tkey/keydelete.c index 5c61f5919b..52f9c31ec8 100644 --- a/bin/tests/system/tkey/keydelete.c +++ b/bin/tests/system/tkey/keydelete.c @@ -172,7 +172,7 @@ main(int argc, char **argv) { log = NULL; logconfig = NULL; - RUNCHECK(isc_log_create(mctx, &log, &logconfig)); + isc_log_create(mctx, &log, &logconfig); RUNCHECK(dst_lib_init(mctx, NULL)); diff --git a/bin/tools/mdig.c b/bin/tools/mdig.c index 1ce0e43221..65264b817e 100644 --- a/bin/tools/mdig.c +++ b/bin/tools/mdig.c @@ -2086,7 +2086,7 @@ main(int argc, char *argv[]) { lctx = NULL; lcfg = NULL; - RUNCHECK(isc_log_create(mctx, &lctx, &lcfg)); + isc_log_create(mctx, &lctx, &lcfg); RUNCHECK(dst_lib_init(mctx, NULL)); isc_nonce_buf(cookie_secret, sizeof(cookie_secret)); diff --git a/bin/tools/named-journalprint.c b/bin/tools/named-journalprint.c index 68bb04f844..70304a01d8 100644 --- a/bin/tools/named-journalprint.c +++ b/bin/tools/named-journalprint.c @@ -32,7 +32,7 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) { isc_logconfig_t *logconfig = NULL; isc_log_t *log = NULL; - RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS); + isc_log_create(mctx, &log, &logconfig); isc_log_setcontext(log); dns_log_init(log); dns_log_setcontext(log); @@ -41,9 +41,9 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - RUNTIME_CHECK(isc_log_createchannel(logconfig, "stderr", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, 0) == ISC_R_SUCCESS); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); + RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == ISC_R_SUCCESS); diff --git a/conftools/perllib/dnsconf/DNSConf.i b/conftools/perllib/dnsconf/DNSConf.i index 6e1161a746..e7a61ad3ba 100644 --- a/conftools/perllib/dnsconf/DNSConf.i +++ b/conftools/perllib/dnsconf/DNSConf.i @@ -62,8 +62,7 @@ int ctx_init(void) { isc_mem_create(&ctx.mem); - if (isc_log_create(ctx.mem, &ctx.log, &ctx.logcfg) != ISC_R_SUCCESS) - goto done; + isc_log_create(ctx.mem, &ctx.log, &ctx.logcfg); isc_log_setcontext(ctx.log); dns_log_init(ctx.log); diff --git a/doc/design/logging b/doc/design/logging index 91caa6c41c..3563b94198 100644 --- a/doc/design/logging +++ b/doc/design/logging @@ -283,8 +283,7 @@ rudimentary initialization of both. isc_logconfig_t *lcfg; isc_mem_create(&mctx); - if (isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS)) - oops_it_didnt_work(); + isc_log_create(mctx, &lctx, &lcfg); 3) Initialize any additional libraries. The convention for the name of the initialization function is {library}_log_init, with just a pointer @@ -374,7 +373,7 @@ configuration, first create the new configuration with: and then configure newlcfg with isc_log_createchannel() and isc_log_usechannel(). When it is all ready: - result = isc_logconfig_use(lctx, newlcfg); + isc_logconfig_use(lctx, newlcfg); If the new configuration is successfully installed, then the old one will be destroyed, freeing all memory it used. diff --git a/doc/dev/dev.md b/doc/dev/dev.md index 1464c9ac8b..955805d0df 100644 --- a/doc/dev/dev.md +++ b/doc/dev/dev.md @@ -1066,9 +1066,7 @@ the following steps need to be taken to initialize it. isc_logconfig_t *lcfg; isc_mem_create(&mctx); - if (isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS)) { - oops_it_didnt_work(); - } + isc_log_create(mctx, &lctx, &lcfg) != ISC_R_SUCCESS); 1. Initialize any additional libraries. The convention for the name of the initialization function is `{library}_log_init()`, with a pointer to @@ -1091,24 +1089,16 @@ the following steps need to be taken to initialize it. destination.file.name = "/var/log/example"; destination.file.maximum_size = 0; /* No byte limit. */ destination.file.versions = ISC_LOG_ROLLNEVER; /* External rolling. */ - result = isc_log_createchannel(lcfg, "sample1", ISC_LOG_TOFILE, - ISC_LOG_DYNAMIC, &destination, - ISC_LOG_PRINTTIME); - if (result != ISC_R_SUCCESS) - oops_it_didnt_work(); + isc_log_createchannel(lcfg, "sample1", ISC_LOG_TOFILE, ISC_LOG_DYNAMIC, + &destination, ISC_LOG_PRINTTIME); destination.file.stream = stdout; - result = isc_log_createchannel(lcfg, "sample2", ISC_LOG_TOFILEDESC, - ISC_LOG_INFO, &destination, - ISC_LOG_PRINTTIME); - if (result != ISC_R_SUCCESS) - oops_it_didnt_work(); + isc_log_createchannel(lcfg, "sample2", ISC_LOG_TOFILEDESC, + ISC_LOG_INFO, &destination, ISC_LOG_PRINTTIME); destination.facility = LOG_ERR; - result = isc_log_createchannel(lcfg, "sample3", ISC_LOG_SYSLOG, - ISC_LOG_ERROR, &destination, 0); - if (result != ISC_R_SUCCESS) - oops_it_didnt_work(); + isc_log_createchannel(lcfg, "sample3", ISC_LOG_SYSLOG, ISC_LOG_ERROR, + &destination, 0); `ISC_LOG_DYNAMIC` is used to define a channel that wants any of the messages up to the current debugging level of the program. diff --git a/lib/dns/client.c b/lib/dns/client.c index 6a003e8d79..b78a35306a 100644 --- a/lib/dns/client.c +++ b/lib/dns/client.c @@ -445,10 +445,7 @@ dns_client_create(dns_client_t **clientp, unsigned int options) { goto cleanup; } #if 0 - result = isc_log_create(mctx, &lctx, &logconfig); - if (result != ISC_R_SUCCESS) { - goto cleanup; - } + isc_log_create(mctx, &lctx, &logconfig); isc_log_setcontext(lctx); dns_log_init(lctx); dns_log_setcontext(lctx); diff --git a/lib/dns/tests/dnstest.c b/lib/dns/tests/dnstest.c index 9b5740b4bb..b1e70080e7 100644 --- a/lib/dns/tests/dnstest.c +++ b/lib/dns/tests/dnstest.c @@ -153,8 +153,7 @@ dns_test_begin(FILE *logfile, bool start_managers) { isc_logconfig_t *logconfig = NULL; INSIST(lctx == NULL); - CHECK(isc_log_create(dt_mctx, &lctx, &logconfig)); - + isc_log_create(dt_mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_setcontext(lctx); dns_log_init(lctx); @@ -164,9 +163,8 @@ dns_test_begin(FILE *logfile, bool start_managers) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); } diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 9797a4ce1b..ac8b3d8672 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -183,7 +183,7 @@ LIBISC_EXTERNAL_DATA extern isc_logmodule_t isc_modules[]; ISC_LANG_BEGINDECLS -isc_result_t +void isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp); /*%< * Establish a new logging context, with default channels. @@ -203,13 +203,9 @@ isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp); *\li *lcfgp will point to a valid logging configuration if all of the * necessary memory was allocated, or NULL otherwise. *\li On failure, no additional memory is allocated. - * - * Returns: - *\li #ISC_R_SUCCESS Success - *\li #ISC_R_NOMEMORY Resource limit: Out of memory */ -isc_result_t +void isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp); /*%< * Create the data structure that holds all of the configurable information @@ -249,13 +245,9 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp); *\li *lcfgp will point to a valid logging context if all of the necessary * memory was allocated, or NULL otherwise. *\li On failure, no additional memory is allocated. - * - * Returns: - *\li #ISC_R_SUCCESS Success - *\li #ISC_R_NOMEMORY Resource limit: Out of memory */ -isc_result_t +void isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg); /*%< * Associate a new configuration with a logging context. @@ -274,10 +266,6 @@ isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg); * * Ensures: *\li Future calls to isc_log_write will use the new configuration. - * - * Returns: - *\li #ISC_R_SUCCESS Success - *\li #ISC_R_NOMEMORY Resource limit: Out of memory */ void @@ -388,7 +376,7 @@ isc_log_registermodules(isc_log_t *lctx, isc_logmodule_t modules[]); * used with isc_log_usechannel() and isc_log_write(). */ -isc_result_t +void isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, unsigned int type, int level, const isc_logdestination_t *destination, @@ -449,12 +437,6 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, * No additional memory is being used by the logging context. * Any channel that previously existed with the given name * is not redefined. - * - * Returns: - *\li #ISC_R_SUCCESS Success - *\li #ISC_R_NOMEMORY Resource limit: Out of memory - *\li #ISC_R_UNEXPECTED type was out of range and REQUIRE() - * was disabled. */ isc_result_t @@ -699,7 +681,7 @@ isc_log_getduplicateinterval(isc_logconfig_t *lcfg); *\li The current duplicate filtering interval. */ -isc_result_t +void isc_log_settag(isc_logconfig_t *lcfg, const char *tag); /*%< * Set the program name or other identifier for #ISC_LOG_PRINTTAG. @@ -718,10 +700,6 @@ isc_log_settag(isc_logconfig_t *lcfg, const char *tag); * #ISC_LOG_PRINTTAG channel flag to not print anything. If tag equals the * empty string, calls to isc_log_gettag will return NULL. * - * Returns: - *\li #ISC_R_SUCCESS Success - *\li #ISC_R_NOMEMORY Resource Limit: Out of memory - * * XXXDCL when creating a new isc_logconfig_t, it might be nice if the tag * of the currently active isc_logconfig_t was inherited. this does not * currently happen. diff --git a/lib/isc/log.c b/lib/isc/log.c index 22d4a6fd42..36ddb38e6b 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -196,11 +196,11 @@ LIBISC_EXTERNAL_DATA isc_log_t *isc_lctx = NULL; /*! * Forward declarations. */ -static isc_result_t +static void assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, const isc_logmodule_t *module, isc_logchannel_t *channel); -static isc_result_t +static void sync_channellist(isc_logconfig_t *lcfg); static isc_result_t @@ -232,74 +232,55 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, /* * Establish a new logging context, with default channels. */ -isc_result_t +void isc_log_create(isc_mem_t *mctx, isc_log_t **lctxp, isc_logconfig_t **lcfgp) { isc_log_t *lctx; isc_logconfig_t *lcfg = NULL; - isc_result_t result; REQUIRE(mctx != NULL); REQUIRE(lctxp != NULL && *lctxp == NULL); REQUIRE(lcfgp == NULL || *lcfgp == NULL); lctx = isc_mem_get(mctx, sizeof(*lctx)); - if (lctx != NULL) { - lctx->mctx = NULL; - isc_mem_attach(mctx, &lctx->mctx); - lctx->categories = NULL; - lctx->category_count = 0; - lctx->modules = NULL; - lctx->module_count = 0; - lctx->debug_level = 0; + lctx->mctx = NULL; + isc_mem_attach(mctx, &lctx->mctx); + lctx->categories = NULL; + lctx->category_count = 0; + lctx->modules = NULL; + lctx->module_count = 0; + lctx->debug_level = 0; - ISC_LIST_INIT(lctx->messages); + ISC_LIST_INIT(lctx->messages); - isc_mutex_init(&lctx->lock); + isc_mutex_init(&lctx->lock); - /* - * Normally setting the magic number is the last step done - * in a creation function, but a valid log context is needed - * by isc_log_registercategories and isc_logconfig_create. - * If either fails, the lctx is destroyed and not returned - * to the caller. - */ - lctx->magic = LCTX_MAGIC; + /* + * Normally setting the magic number is the last step done + * in a creation function, but a valid log context is needed + * by isc_log_registercategories and isc_logconfig_create. + * If either fails, the lctx is destroyed and not returned + * to the caller. + */ + lctx->magic = LCTX_MAGIC; - isc_log_registercategories(lctx, isc_categories); - isc_log_registermodules(lctx, isc_modules); - result = isc_logconfig_create(lctx, &lcfg); - } else { - result = ISC_R_NOMEMORY; + isc_log_registercategories(lctx, isc_categories); + isc_log_registermodules(lctx, isc_modules); + isc_logconfig_create(lctx, &lcfg); + + sync_channellist(lcfg); + + atomic_init(&lctx->logconfig, (uintptr_t)lcfg); + + *lctxp = lctx; + if (lcfgp != NULL) { + *lcfgp = lcfg; } - - if (result == ISC_R_SUCCESS) { - result = sync_channellist(lcfg); - } - - if (result == ISC_R_SUCCESS) { - atomic_init(&lctx->logconfig, (uintptr_t)lcfg); - - *lctxp = lctx; - if (lcfgp != NULL) { - *lcfgp = lcfg; - } - } else { - if (lcfg != NULL) { - isc_logconfig_destroy(&lcfg); - } - if (lctx != NULL) { - isc_log_destroy(&lctx); - } - } - - return (result); } -isc_result_t +void isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) { isc_logconfig_t *lcfg; isc_logdestination_t destination; - isc_result_t result = ISC_R_SUCCESS; int level = ISC_LOG_INFO; REQUIRE(lcfgp != NULL && *lcfgp == NULL); @@ -321,60 +302,42 @@ isc_logconfig_create(isc_log_t *lctx, isc_logconfig_t **lcfgp) { * Create the default channels: * default_syslog, default_stderr, default_debug and null. */ - if (result == ISC_R_SUCCESS) { - destination.facility = LOG_DAEMON; - result = isc_log_createchannel(lcfg, "default_syslog", - ISC_LOG_TOSYSLOG, level, - &destination, 0); - } + destination.facility = LOG_DAEMON; + isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, level, + &destination, 0); - if (result == ISC_R_SUCCESS) { - destination.file.stream = stderr; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.suffix = isc_log_rollsuffix_increment; - destination.file.maximum_size = 0; - result = isc_log_createchannel(lcfg, "default_stderr", - ISC_LOG_TOFILEDESC, level, - &destination, ISC_LOG_PRINTTIME); - } + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.suffix = isc_log_rollsuffix_increment; + destination.file.maximum_size = 0; + isc_log_createchannel(lcfg, "default_stderr", ISC_LOG_TOFILEDESC, level, + &destination, ISC_LOG_PRINTTIME); - if (result == ISC_R_SUCCESS) { - /* - * Set the default category's channel to default_stderr, - * which is at the head of the channels list because it was - * just created. - */ - default_channel.channel = ISC_LIST_HEAD(lcfg->channels); + /* + * Set the default category's channel to default_stderr, + * which is at the head of the channels list because it was + * just created. + */ + default_channel.channel = ISC_LIST_HEAD(lcfg->channels); - destination.file.stream = stderr; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.suffix = isc_log_rollsuffix_increment; - destination.file.maximum_size = 0; - result = isc_log_createchannel( - lcfg, "default_debug", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); - } + destination.file.stream = stderr; + destination.file.name = NULL; + destination.file.versions = ISC_LOG_ROLLNEVER; + destination.file.suffix = isc_log_rollsuffix_increment; + destination.file.maximum_size = 0; + isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); - if (result == ISC_R_SUCCESS) { - result = isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL, - ISC_LOG_DYNAMIC, NULL, 0); - } + isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL, ISC_LOG_DYNAMIC, + NULL, 0); - if (result == ISC_R_SUCCESS) { - *lcfgp = lcfg; - } else { - isc_logconfig_destroy(&lcfg); - } - - return (result); + *lcfgp = lcfg; } -isc_result_t +void isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg) { isc_logconfig_t *old_cfg; - isc_result_t result; REQUIRE(VALID_CONTEXT(lctx)); REQUIRE(VALID_CONFIG(lcfg)); @@ -385,17 +348,12 @@ isc_logconfig_use(isc_log_t *lctx, isc_logconfig_t *lcfg) { * They won't be equal if isc_log_usechannel has not been called * since any call to isc_log_registercategories. */ - result = sync_channellist(lcfg); - if (result != ISC_R_SUCCESS) { - return (result); - } + sync_channellist(lcfg); old_cfg = (isc_logconfig_t *)atomic_exchange_acq_rel(&lctx->logconfig, (uintptr_t)lcfg); isc_logconfig_destroy(&old_cfg); - - return (ISC_R_SUCCESS); } void @@ -650,7 +608,7 @@ isc_log_modulebyname(isc_log_t *lctx, const char *name) { return (NULL); } -isc_result_t +void isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, unsigned int type, int level, const isc_logdestination_t *destination, @@ -715,9 +673,7 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, break; default: - isc_mem_free(mctx, channel->name); - isc_mem_put(mctx, channel, sizeof(*channel)); - return (ISC_R_UNEXPECTED); + ISC_UNREACHABLE(); } ISC_LIST_PREPEND(lcfg->channels, channel, link); @@ -729,8 +685,6 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, if (strcmp(name, "default_stderr") == 0) { default_channel.channel = channel; } - - return (ISC_R_SUCCESS); } isc_result_t @@ -739,7 +693,6 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, const isc_logmodule_t *module) { isc_log_t *lctx; isc_logchannel_t *channel; - isc_result_t result = ISC_R_SUCCESS; unsigned int i; REQUIRE(VALID_CONFIG(lcfg)); @@ -763,21 +716,18 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, } if (category != NULL) { - result = assignchannel(lcfg, category->id, module, channel); + assignchannel(lcfg, category->id, module, channel); } else { /* * Assign to all categories. Note that this includes * the default channel. */ for (i = 0; i < lctx->category_count; i++) { - result = assignchannel(lcfg, i, module, channel); - if (result != ISC_R_SUCCESS) { - break; - } + assignchannel(lcfg, i, module, channel); } } - return (result); + return (ISC_R_SUCCESS); } void @@ -888,7 +838,7 @@ isc_log_getduplicateinterval(isc_logconfig_t *lcfg) { return (lcfg->duplicate_interval); } -isc_result_t +void isc_log_settag(isc_logconfig_t *lcfg, const char *tag) { REQUIRE(VALID_CONFIG(lcfg)); @@ -903,8 +853,6 @@ isc_log_settag(isc_logconfig_t *lcfg, const char *tag) { } lcfg->tag = NULL; } - - return (ISC_R_SUCCESS); } char * @@ -947,12 +895,11 @@ isc_log_closefilelogs(isc_log_t *lctx) { **** Internal functions ****/ -static isc_result_t +static void assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, const isc_logmodule_t *module, isc_logchannel_t *channel) { isc_logchannellist_t *new_item; isc_log_t *lctx; - isc_result_t result; REQUIRE(VALID_CONFIG(lcfg)); @@ -965,10 +912,7 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, /* * Ensure lcfg->channellist_count == lctx->category_count. */ - result = sync_channellist(lcfg); - if (result != ISC_R_SUCCESS) { - return (result); - } + sync_channellist(lcfg); new_item = isc_mem_get(lctx->mctx, sizeof(*new_item)); @@ -990,15 +934,13 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, lcfg->dynamic = true; } } - - return (ISC_R_SUCCESS); } /* * This would ideally be part of isc_log_registercategories(), except then * that function would have to return isc_result_t instead of void. */ -static isc_result_t +static void sync_channellist(isc_logconfig_t *lcfg) { unsigned int bytes; isc_log_t *lctx; @@ -1011,7 +953,7 @@ sync_channellist(isc_logconfig_t *lcfg) { REQUIRE(lctx->category_count != 0); if (lctx->category_count == lcfg->channellist_count) { - return (ISC_R_SUCCESS); + return; } bytes = lctx->category_count * sizeof(ISC_LIST(isc_logchannellist_t)); @@ -1029,8 +971,6 @@ sync_channellist(isc_logconfig_t *lcfg) { lcfg->channellists = lists; lcfg->channellist_count = lctx->category_count; - - return (ISC_R_SUCCESS); } static isc_result_t @@ -1721,16 +1661,12 @@ isc_log_doit(isc_log_t *lctx, isc_logcategory_t *category, size = sizeof(isc_logmessage_t) + strlen(lctx->buffer) + 1; message = isc_mem_get(lctx->mctx, size); - { - message->text = (char *)(message + 1); - size -= sizeof(isc_logmessage_t); - strlcpy(message->text, lctx->buffer, - size); - TIME_NOW(&message->time); - ISC_LINK_INIT(message, link); - ISC_LIST_APPEND(lctx->messages, message, - link); - } + message->text = (char *)(message + 1); + size -= sizeof(isc_logmessage_t); + strlcpy(message->text, lctx->buffer, size); + TIME_NOW(&message->time); + ISC_LINK_INIT(message, link); + ISC_LIST_APPEND(lctx->messages, message, link); } } diff --git a/lib/isc/tests/isctest.c b/lib/isc/tests/isctest.c index ba8fa7ac79..3d31df2f54 100644 --- a/lib/isc/tests/isctest.c +++ b/lib/isc/tests/isctest.c @@ -116,8 +116,7 @@ isc_test_begin(FILE *logfile, bool start_managers, unsigned int workers) { isc_logconfig_t *logconfig = NULL; INSIST(test_lctx == NULL); - CHECK(isc_log_create(test_mctx, &test_lctx, &logconfig)); - + isc_log_create(test_mctx, &test_lctx, &logconfig); isc_log_registercategories(test_lctx, categories); isc_log_setcontext(test_lctx); @@ -125,9 +124,8 @@ isc_test_begin(FILE *logfile, bool start_managers, unsigned int workers) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); } diff --git a/lib/isccfg/tests/duration_test.c b/lib/isccfg/tests/duration_test.c index 171aa26c23..44234152a5 100644 --- a/lib/isccfg/tests/duration_test.c +++ b/lib/isccfg/tests/duration_test.c @@ -73,7 +73,7 @@ setup() { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - CHECK(isc_log_create(mctx, &lctx, &logconfig)); + isc_log_create(mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_setcontext(lctx); @@ -81,8 +81,8 @@ setup() { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); return (ISC_R_SUCCESS); diff --git a/lib/isccfg/tests/parser_test.c b/lib/isccfg/tests/parser_test.c index 24466f6121..f5ac432462 100644 --- a/lib/isccfg/tests/parser_test.c +++ b/lib/isccfg/tests/parser_test.c @@ -73,7 +73,7 @@ setup() { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - CHECK(isc_log_create(mctx, &lctx, &logconfig)); + isc_log_create(mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_setcontext(lctx); @@ -81,8 +81,8 @@ setup() { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); return (ISC_R_SUCCESS); diff --git a/lib/ns/tests/nstest.c b/lib/ns/tests/nstest.c index 38cf4db69b..7a70d536d6 100644 --- a/lib/ns/tests/nstest.c +++ b/lib/ns/tests/nstest.c @@ -288,7 +288,7 @@ ns_test_begin(FILE *logfile, bool start_managers) { isc_logconfig_t *logconfig = NULL; INSIST(lctx == NULL); - CHECK(isc_log_create(mctx, &lctx, &logconfig)); + isc_log_create(mctx, &lctx, &logconfig); isc_log_registercategories(lctx, categories); isc_log_setcontext(lctx); @@ -299,9 +299,8 @@ ns_test_begin(FILE *logfile, bool start_managers) { destination.file.name = NULL; destination.file.versions = ISC_LOG_ROLLNEVER; destination.file.maximum_size = 0; - CHECK(isc_log_createchannel(logconfig, "stderr", - ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, - &destination, 0)); + isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, + ISC_LOG_DYNAMIC, &destination, 0); CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL)); }