]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Refactor the isc_log API so it cannot fail on memory failures
authorMark Andrews <marka@isc.org>
Wed, 18 Mar 2020 03:17:55 +0000 (14:17 +1100)
committerOndřej Surý <ondrej@isc.org>
Wed, 18 Mar 2020 08:05:59 +0000 (09:05 +0100)
The isc_mem API now crashes on memory allocation failure, and this is
the next commit in series to cleanup the code that could fail before,
but cannot fail now, e.g. isc_result_t return type has been changed to
void for the isc_log API functions that could only return ISC_R_SUCCESS.

35 files changed:
bin/check/check-tool.c
bin/delv/delv.c
bin/dig/dighost.c
bin/dnssec/dnssectool.c
bin/named/include/named/log.h
bin/named/log.c
bin/named/logconf.c
bin/named/server.c
bin/nsupdate/nsupdate.c
bin/rndc/rndc.c
bin/tests/cfg_test.c
bin/tests/makejournal.c
bin/tests/optional/adb_test.c
bin/tests/optional/byname_test.c
bin/tests/optional/db_test.c
bin/tests/optional/gsstest.c
bin/tests/optional/log_test.c
bin/tests/optional/sig0_test.c
bin/tests/system/pipelined/pipequeries.c
bin/tests/system/rsabigexponent/bigkey.c
bin/tests/system/tkey/keycreate.c
bin/tests/system/tkey/keydelete.c
bin/tools/mdig.c
bin/tools/named-journalprint.c
conftools/perllib/dnsconf/DNSConf.i
doc/design/logging
doc/dev/dev.md
lib/dns/client.c
lib/dns/tests/dnstest.c
lib/isc/include/isc/log.h
lib/isc/log.c
lib/isc/tests/isctest.c
lib/isccfg/tests/duration_test.c
lib/isccfg/tests/parser_test.c
lib/ns/tests/nstest.c

index 38387b172b9bd6652334e468bfeaa32bf7fc6b61..4c78c9cd7f4fa12226b673151c8db13e0a73bada 100644 (file)
@@ -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);
 
index c4bdbb4b3a8f4e0b03f864fece6f318f85a46955..0525b2c6fa6431a478280949612bab1a45dca7f9 100644 (file)
@@ -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,
index 85e725c030ac0df0b8c6e842ddfbcb1d61944dd8..4a4d0b677358d00eb9fac70245c8780ffb264d8b 100644 (file)
@@ -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);
index 7b0ba04e25d71cbb0d840bc1ff4cbd1a8380b938..265f557e5a0de7ded1c6dd2acd92f57e0a96c253 100644 (file)
@@ -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);
index 1cc8414e1fcc526da47ef15b569dfb4a69405c59..6abe078416273010aa9595a27d2cdd0f5724892d 100644 (file)
@@ -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.
index e36fd0e2f8133477c64b6e973cf5ea4fb6588eaa..770154e24c4a7c1b688cfa8c04de3086d48ab73e 100644 (file)
@@ -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
index 8759a2a623f060b82623a6e1eee794d8ed775fd3..4696886cf182bdafa00057dfc38ff1cf0a8e7266 100644 (file)
@@ -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);
index 2836429de3ff48b78d65bc7b24769f75b70bf67e..3a927b01bd4f953017f5551a935dcf571502dc22 100644 (file)
@@ -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,
index 9144a7570c64dd3293215e59e6b70afb3fdd326b..ce3798968dd78420e7f5b4ccff20df7838cb932f 100644 (file)
@@ -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);
index 6a3b2f3b2b76eabaf5dfab03f56be8480aba3832..b6e7a186647b02ac1406e810342c722950627123 100644 (file)
@@ -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));
 
index cab9b42a287311d522265b72050d9e75770ccbf0..0ecab243f4be806a5bdd4ce330d5acdcedcaccd4 100644 (file)
@@ -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()");
 
index a545738d02cc70c16c8c2e91a607ab952c6a7c33..29a2580803c764ac609b4777f017c8412a5db9bf 100644 (file)
@@ -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();
index 38e965bcf239e72574b7ceac3bbb2a1f3956f7d3..b232914574c4cfa890f4045ad246199f181161ff 100644 (file)
@@ -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()");
 
index 6ee3437621d662363dd872f83cc0fa3b1a0c477a..a80160a69005456f091ed21b75f1e8722fa89c97 100644 (file)
@@ -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);
index 465e0d10533a2042ce0dde255939460847d1147d..f4325ba1713d6e7acaf9c096670b6eb3b9c39eb7 100644 (file)
@@ -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);
index dd005c084b480978a669e68c423ae99d3efb95d8..dfc1052435cb6fd71d4db4ea1a26114131b677a4 100644 (file)
@@ -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);
index 3fdd270546d37bd5576907ed055e4952fe5f27ef..750bcccc5c23295953e12736fc0b68dfa3ec2102 100644 (file)
@@ -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.
index 9efcc70b1ecf0e8c72e8673edc457de864bba989..233fc5914d2b62b94bc27c01f28ff7fce91b8470 100644 (file)
@@ -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,
index cec9de7cb14ea0c6c13799f708f29efc52c28f8e..4a10624dea29b678765cc1f240761ce69dc78500 100644 (file)
@@ -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));
 
index fcb8f6932ad1e6004b24d70a9d3ab8f5fad99dd3..f18f9fdeb8e2cae6c9c5ae89d1ede05af3016e2e 100644 (file)
@@ -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("
                                                                   ")");
index c14e5c1065d758f81107810b6c121bd72b1ed92a..cf15fd3544bfe8b15aef6806016a570db754f26a 100644 (file)
@@ -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));
 
index 5c61f5919b8c15b1094fccd2072f7078de94090d..52f9c31ec825f166bf9feb17a9d7701ad2c611f3 100644 (file)
@@ -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));
 
index 1ce0e4322159158f3aae3aefdae20834583eff9d..65264b817ed73cb816d0b596c05121c2b855ed24 100644 (file)
@@ -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));
index 68bb04f8440713bbf6a929bf858f2141b80f80a6..70304a01d8fc5fc82e8cab83d2b282055c564410 100644 (file)
@@ -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);
 
index 6e1161a7465b0dbc7ad7dc581ec9c274126a8ef7..e7a61ad3ba4400dc660757ab4e9796d7b2242b58 100644 (file)
@@ -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);
index 91caa6c41c6d34d69a09bcab220882d82c3d91e8..3563b941984bed40187ac5cd11b5c5209449ba80 100644 (file)
@@ -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.
index 1464c9ac8b97e420c9b37c5be0cc95626fc15170..955805d0dfe738e1eba2200130971d3c374411cb 100644 (file)
@@ -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.
index 6a003e8d79ee7cb7cdb046eff6c72107db18d414..b78a35306a9dc1066fa2d43a96f36938e7c14561 100644 (file)
@@ -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);
index 9b5740b4bb5c9b7938cec3cf242ce5b41d4eab53..b1e70080e7e7435dac2d558ed551290c50a33a4b 100644 (file)
@@ -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));
        }
 
index 9797a4ce1b0ad783d672bd5d7fb5b39c47d2c3a7..ac8b3d86727b90f5fe0fe373f1a9cc4b0ae14aa9 100644 (file)
@@ -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.
index 22d4a6fd427d7c537fa10a2641f6c39588064bd6..36ddb38e6b46722f869c78740a06df88d20cfbb3 100644 (file)
@@ -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);
 
-       if (result == ISC_R_SUCCESS) {
-               result = sync_channellist(lcfg);
-       }
+       sync_channellist(lcfg);
 
-       if (result == ISC_R_SUCCESS) {
-               atomic_init(&lctx->logconfig, (uintptr_t)lcfg);
+       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);
-               }
+       *lctxp = lctx;
+       if (lcfgp != NULL) {
+               *lcfgp = lcfg;
        }
-
-       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);
+
+       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) {
-               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);
-       }
+       /*
+        * 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);
 
-       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);
-
-               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);
                        }
                }
 
index ba8fa7ac79a4b5d8853face70cdc2363ead04164..3d31df2f5499a1748e78707fdd445ec0de741ec4 100644 (file)
@@ -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));
        }
 
index 171aa26c234fd1380bacfadfa11b2641900ab271..44234152a5bb00fae0f2b63d8ff1bea75724a52f 100644 (file)
@@ -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);
index 24466f6121ccb9dd35709392b3b46a1eee5b7c52..f5ac432462bbf66ed8c2fedbdb5ee1cd05228c81 100644 (file)
@@ -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);
index 38cf4db69bd5e1d01a79976943a8d39a7e6c4710..7a70d536d6b21497c949a0ed919accfba3456e0f 100644 (file)
@@ -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));
        }