From 46f06c1d6e4b613f5be166b18b4653776e50024f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Thu, 30 Mar 2023 21:13:41 +0200 Subject: [PATCH] Apply the semantic patch to remove isc_stdtime_get() This is a simple replacement using the semantic patch from the previous commit and as added bonus, one removal of previously undetected unused variable in named/server.c. --- bin/dnssec/dnssec-cds.c | 3 +-- bin/dnssec/dnssec-importkey.c | 3 +-- bin/dnssec/dnssec-keyfromlabel.c | 4 +--- bin/dnssec/dnssec-keygen.c | 2 +- bin/dnssec/dnssec-revoke.c | 3 +-- bin/dnssec/dnssec-settime.c | 4 +--- bin/dnssec/dnssec-signzone.c | 2 +- bin/dnssec/dnssec-verify.c | 2 +- bin/dnssec/dnssectool.c | 6 ++--- bin/named/controlconf.c | 2 +- bin/named/server.c | 11 +++------ bin/named/statschannel.c | 3 +-- bin/named/tsigconf.c | 2 +- bin/rndc/rndc.c | 7 ++---- lib/dns/adb.c | 13 +++++------ lib/dns/dnssec.c | 8 +++---- lib/dns/master.c | 6 ++--- lib/dns/masterdump.c | 6 ++--- lib/dns/nta.c | 11 +++------ lib/dns/rbtdb.c | 18 ++++++--------- lib/dns/rdata/generic/keydata_65533.c | 4 +--- lib/dns/resolver.c | 9 ++++---- lib/dns/rootns.c | 8 ++----- lib/dns/rrl.c | 2 +- lib/dns/time.c | 4 ++-- lib/dns/tkey.c | 7 ++---- lib/dns/tsig.c | 18 ++++++--------- lib/dns/update.c | 9 ++++---- lib/dns/validator.c | 2 +- lib/dns/view.c | 3 +-- lib/dns/zone.c | 33 +++++++++------------------ lib/isc/netmgr/tcp.c | 5 ++-- lib/ns/client.c | 5 ++-- lib/ns/query.c | 12 ++++------ tests/dns/dnstap_test.c | 4 ++-- tests/dns/keytable_test.c | 6 ++--- tests/dns/sigs_test.c | 3 +-- tests/dns/tsig_test.c | 4 +--- tests/dns/update_test.c | 6 ++--- 39 files changed, 97 insertions(+), 163 deletions(-) diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index d6726e8ddb..21ecec919a 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -345,8 +345,7 @@ load_parent_set(const char *path) { } notbefore = isc_time_seconds(&modtime); if (startstr != NULL) { - isc_stdtime_t now; - isc_stdtime_get(&now); + isc_stdtime_t now = isc_stdtime_now(); notbefore = strtotime(startstr, now, notbefore, NULL); } verbose_time(1, "child records must not be signed before", notbefore); diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 8e8d481d5e..df01289e19 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -302,10 +302,9 @@ main(int argc, char **argv) { isc_log_t *log = NULL; dns_rdataset_t rdataset; dns_rdata_t rdata; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_rdata_init(&rdata); - isc_stdtime_get(&now); if (argc == 1) { usage(); diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index 54a93a5a93..9837b54523 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -135,7 +135,6 @@ main(int argc, char **argv) { dns_ttl_t ttl = 0; isc_stdtime_t publish = 0, activate = 0, revoke = 0; isc_stdtime_t inactive = 0, deltime = 0; - isc_stdtime_t now; int prepub = -1; bool setpub = false, setact = false; bool setrev = false, setinact = false; @@ -151,6 +150,7 @@ main(int argc, char **argv) { isc_stdtime_t syncadd = 0, syncdel = 0; bool unsetsyncadd = false, setsyncadd = false; bool unsetsyncdel = false, setsyncdel = false; + isc_stdtime_t now = isc_stdtime_now(); if (argc == 1) { usage(); @@ -160,8 +160,6 @@ main(int argc, char **argv) { isc_commandline_errprint = false; - isc_stdtime_get(&now); - #define CMDLINE_FLAGS "3A:a:Cc:D:E:Ff:GhI:i:kK:L:l:n:P:p:R:S:t:v:Vy" while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { switch (ch) { diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 55a28b7f7f..35246e5f05 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -839,6 +839,7 @@ main(int argc, char **argv) { .prepub = -1, .protocol = -1, .size = -1, + .now = isc_stdtime_now(), }; if (argc == 1) { @@ -876,7 +877,6 @@ main(int argc, char **argv) { isc_commandline_reset = true; isc_mem_create(&mctx); - isc_stdtime_get(&ctx.now); while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { switch (ch) { diff --git a/bin/dnssec/dnssec-revoke.c b/bin/dnssec/dnssec-revoke.c index b5797240a7..ada83fd96a 100644 --- a/bin/dnssec/dnssec-revoke.c +++ b/bin/dnssec/dnssec-revoke.c @@ -190,7 +190,7 @@ main(int argc, char **argv) { flags = dst_key_flags(key); if ((flags & DNS_KEYFLAG_REVOKE) == 0) { - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); if ((flags & DNS_KEYFLAG_KSK) == 0) { fprintf(stderr, @@ -200,7 +200,6 @@ main(int argc, char **argv) { program); } - isc_stdtime_get(&now); dst_key_settime(key, DST_TIME_REVOKE, now); dst_key_setflags(key, flags | DNS_KEYFLAG_REVOKE); diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c index 816e85178d..fcd8c0cb53 100644 --- a/bin/dnssec/dnssec-settime.c +++ b/bin/dnssec/dnssec-settime.c @@ -202,7 +202,6 @@ main(int argc, char **argv) { int prepub = -1; int options; dns_ttl_t ttl = 0; - isc_stdtime_t now; isc_stdtime_t dstime = 0, dnskeytime = 0; isc_stdtime_t krrsigtime = 0, zrrsigtime = 0; isc_stdtime_t pub = 0, act = 0, rev = 0, inact = 0, del = 0; @@ -238,6 +237,7 @@ main(int argc, char **argv) { bool unsetdsadd = false, setdsadd = false; bool unsetdsdel = false, setdsdel = false; bool printdsadd = false, printdsdel = false; + isc_stdtime_t now = isc_stdtime_now(); options = DST_TYPE_PUBLIC | DST_TYPE_PRIVATE | DST_TYPE_STATE; @@ -251,8 +251,6 @@ main(int argc, char **argv) { isc_commandline_errprint = false; - isc_stdtime_get(&now); - #define CMDLINE_FLAGS "A:D:d:E:fg:hI:i:K:k:L:P:p:R:r:S:suv:Vz:" while ((ch = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) { switch (ch) { diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 1a5b3b40fe..d0f9add4b7 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -3680,7 +3680,7 @@ main(int argc, char *argv[]) { } } - isc_stdtime_get(&now); + now = isc_stdtime_now(); if (startstr != NULL) { starttime = strtotime(startstr, now, now, NULL); diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 539b155275..e6b8972b02 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -281,7 +281,7 @@ main(int argc, char *argv[]) { isc_result_totext(result)); } - isc_stdtime_get(&now); + now = isc_stdtime_now(); rdclass = strtoclass(classname); diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index d43e7d9fde..502548444c 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -474,8 +474,7 @@ set_keyversion(dst_key_t *key) { * set the creation date */ if (major < 1 || (major == 1 && minor <= 2)) { - isc_stdtime_t now; - isc_stdtime_get(&now); + isc_stdtime_t now = isc_stdtime_now(); dst_key_settime(key, DST_TIME_CREATED, now); } } @@ -490,7 +489,7 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir, uint16_t id, oldid; uint32_t rid, roldid; dns_secalg_t alg; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); if (exact != NULL) { *exact = false; @@ -501,7 +500,6 @@ key_collision(dst_key_t *dstkey, dns_name_t *name, const char *dir, alg = dst_key_alg(dstkey); ISC_LIST_INIT(matchkeys); - isc_stdtime_get(&now); result = dns_dnssec_findmatchingkeys(name, dir, now, mctx, &matchkeys); if (result == ISC_R_NOTFOUND) { return (false); diff --git a/bin/named/controlconf.c b/bin/named/controlconf.c index 8e1ecd08d4..56084de881 100644 --- a/bin/named/controlconf.c +++ b/bin/named/controlconf.c @@ -447,7 +447,7 @@ control_recvmessage(isc_nmhandle_t *handle, isc_result_t result, void *arg) { goto cleanup; } - isc_stdtime_get(&conn->now); + conn->now = isc_stdtime_now(); /* * Limit exposure to replay attacks. diff --git a/bin/named/server.c b/bin/named/server.c index 6a2ae1aa8d..a041e53e26 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -7456,7 +7456,7 @@ generate_session_key(const char *filename, const char *keynamestr, char key_txtsecret[256]; char key_rawsecret[64]; isc_region_t key_rawregion; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_tsigkey_t *tsigkey = NULL; FILE *fp = NULL; @@ -7484,7 +7484,6 @@ generate_session_key(const char *filename, const char *keynamestr, CHECK(isc_base64_totext(&key_rawregion, -1, "", &key_txtbuffer)); /* Store the key in tsigkey. */ - isc_stdtime_get(&now); CHECK(dns_tsigkey_createfromkey(dst_key_name(key), algname, key, false, false, NULL, now, now, mctx, NULL, &tsigkey)); @@ -15140,11 +15139,9 @@ named_server_zonestatus(named_server_t *server, isc_lex_t *lex, result = dns_db_getsigningtime(db, &next, name); if (result == ISC_R_SUCCESS) { - isc_stdtime_t timenow; char namebuf[DNS_NAME_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE]; - isc_stdtime_get(&timenow); dns_name_format(name, namebuf, sizeof(namebuf)); dns_rdatatype_format(next.covers, typebuf, sizeof(typebuf)); @@ -15444,7 +15441,7 @@ named_server_nta(named_server_t *server, isc_lex_t *lex, bool readonly, CHECK(DNS_R_SYNTAX); } - isc_stdtime_get(&now); + now = isc_stdtime_now(); isc_loopmgr_pause(named_g_loopmgr); for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; @@ -15704,11 +15701,9 @@ mkey_dumpzone(dns_view_t *view, isc_buffer_t **text) { dns_db_t *db = NULL; dns_dbversion_t *ver = NULL; dns_rriterator_t rrit; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_name_t *prevname = NULL; - isc_stdtime_get(&now); - CHECK(dns_zone_getdb(view->managed_keys, &db)); dns_db_currentversion(db, &ver); dns_rriterator_init(&rrit, db, ver, 0); diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 180f75581c..7b8eaa4d25 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -3826,7 +3826,6 @@ named_statschannels_shutdown(named_server_t *server) { isc_result_t named_stats_dump(named_server_t *server, FILE *fp) { - isc_stdtime_t now; isc_result_t result; dns_view_t *view; dns_zone_t *zone, *next; @@ -3837,6 +3836,7 @@ named_stats_dump(named_server_t *server, FILE *fp) { uint64_t zonestat_values[dns_zonestatscounter_max]; uint64_t sockstat_values[isc_sockstatscounter_max]; uint64_t gluecachestats_values[dns_gluecachestatscounter_max]; + isc_stdtime_t now = isc_stdtime_now(); isc_once_do(&once, init_desc); @@ -3844,7 +3844,6 @@ named_stats_dump(named_server_t *server, FILE *fp) { dumparg.type = isc_statsformat_file; dumparg.arg = fp; - isc_stdtime_get(&now); fprintf(fp, "+++ Statistics Dump +++ (%lu)\n", (unsigned long)now); fprintf(fp, "++ Incoming Requests ++\n"); diff --git a/bin/named/tsigconf.c b/bin/named/tsigconf.c index d20ab72103..3333283bc7 100644 --- a/bin/named/tsigconf.c +++ b/bin/named/tsigconf.c @@ -104,7 +104,7 @@ add_initial_keys(const cfg_obj_t *list, dns_tsig_keyring_t *ring, } secretlen = isc_buffer_usedlength(&secretbuf); - isc_stdtime_get(&now); + now = isc_stdtime_now(); ret = dns_tsigkey_create(&keyname, alg, secret, secretlen, false, false, NULL, now, now, mctx, ring, &tsigkey); diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index c6bf8c9f62..088cfd1a17 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -397,7 +397,7 @@ rndc_recvnonce(isc_nmhandle_t *handle, isc_result_t result, void *arg) { isccc_region_t source; uint32_t nonce; isccc_sexpr_t *request = NULL; - isccc_time_t now; + isccc_time_t now = isc_stdtime_now(); isc_region_t r; isccc_sexpr_t *data = NULL; isc_buffer_t b; @@ -439,8 +439,6 @@ rndc_recvnonce(isc_nmhandle_t *handle, isc_result_t result, void *arg) { nonce = 0; } - isc_stdtime_get(&now); - DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, now, now + 60, &request)); data = isccc_alist_lookup(request, "_data"); @@ -496,7 +494,7 @@ rndc_connected(isc_nmhandle_t *handle, isc_result_t result, void *arg) { char socktext[ISC_SOCKADDR_FORMATSIZE]; isccc_sexpr_t *request = NULL; isccc_sexpr_t *data = NULL; - isccc_time_t now; + isccc_time_t now = isc_stdtime_now(); isc_region_t r; isc_buffer_t b; isc_nmhandle_t *connhandle = NULL; @@ -521,7 +519,6 @@ rndc_connected(isc_nmhandle_t *handle, isc_result_t result, void *arg) { isc_nmhandle_attach(handle, &connhandle); - isc_stdtime_get(&now); DO("create message", isccc_cc_createmessage(1, NULL, NULL, ++serial, now, now + 60, &request)); data = isccc_alist_lookup(request, "_data"); diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 568c96763c..071774f4cc 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -2087,7 +2087,7 @@ dns_adb_createfind(dns_adb_t *adb, isc_loop_t *loop, isc_job_cb cb, void *cbarg, } if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } /* @@ -2456,7 +2456,7 @@ dns_adb_cancelfind(dns_adbfind_t *find) { void dns_adb_dump(dns_adb_t *adb, FILE *f) { - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); REQUIRE(DNS_ADB_VALID(adb)); REQUIRE(f != NULL); @@ -2465,7 +2465,6 @@ dns_adb_dump(dns_adb_t *adb, FILE *f) { return; } - isc_stdtime_get(&now); cleanup_names(adb, now); cleanup_entries(adb, now); dump_adb(adb, f, false, now); @@ -2956,7 +2955,7 @@ fetch_callback(void *arg) { goto out; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); /* * If we got a negative cache response, remember it. @@ -3197,7 +3196,7 @@ dns_adb_adjustsrtt(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int rtt, LOCK(&entry->lock); if (entry->expires == 0 || factor == DNS_ADB_RTTADJAGE) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } adjustsrtt(addr, rtt, factor, now); @@ -3258,7 +3257,7 @@ dns_adb_changeflags(dns_adb_t *adb, dns_adbaddrinfo_t *addr, unsigned int bits, entry->flags = (entry->flags & ~mask) | (bits & mask); if (entry->expires == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); entry->expires = now + ADB_ENTRY_WINDOW; } @@ -3555,7 +3554,7 @@ dns_adb_freeaddrinfo(dns_adb_t *adb, dns_adbaddrinfo_t **addrp) { REQUIRE(DNS_ADBENTRY_VALID(entry)); if (entry->expires == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); entry->expires = now + ADB_ENTRY_WINDOW; } diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 57453fa6cf..034d697eec 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -408,7 +408,7 @@ dns_dnssec_verify(const dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, } if (!ignoretime) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); /* * Is SIG temporally valid? @@ -971,7 +971,7 @@ dns_dnssec_signmessage(dns_message_t *msg, dst_key_t *key) { if (msg->fuzzing) { now = msg->fuzztime; } else { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } sig.timesigned = now - DNS_TSIG_FUDGE; sig.timeexpire = now + DNS_TSIG_FUDGE; @@ -1119,7 +1119,7 @@ dns_dnssec_verifymessage(isc_buffer_t *source, dns_message_t *msg, if (msg->fuzzing) { now = msg->fuzztime; } else { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } if (isc_serial_lt((uint32_t)now, sig.timesigned)) { @@ -1907,7 +1907,7 @@ publish_key(dns_diff_t *diff, dns_dnsseckey_t *key, const dns_name_t *origin, "(%u).", keystr, ttl); - isc_stdtime_get(&now); + now = isc_stdtime_now(); dst_key_settime(key->key, DST_TIME_ACTIVATE, now + ttl); } diff --git a/lib/dns/master.c b/lib/dns/master.c index 0429ce36f4..1d6aa5078e 100644 --- a/lib/dns/master.c +++ b/lib/dns/master.c @@ -554,7 +554,7 @@ loadctx_create(dns_masterformat_t format, isc_mem_t *mctx, unsigned int options, isc_lex_setcomments(lctx->lex, ISC_LEXCOMMENT_DNSMASTERFILE); } - isc_stdtime_get(&lctx->now); + lctx->now = isc_stdtime_now(); lctx->top = dns_fixedname_initname(&lctx->fixed_top); dns_name_toregion(top, &r); @@ -1227,9 +1227,9 @@ load_text(dns_loadctx_t *lctx) { } else if (strcasecmp(DNS_AS_STR(token), "$DATE") == 0) { int64_t dump_time64; - isc_stdtime_t dump_time, current_time; + isc_stdtime_t dump_time; + isc_stdtime_t current_time = isc_stdtime_now(); GETTOKEN(lctx->lex, 0, &token, false); - isc_stdtime_get(¤t_time); result = dns_time64_fromtext(DNS_AS_STR(token), &dump_time64); if (MANYERRS(lctx, result)) { diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index 728b1d3dde..b80cd640eb 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -1545,7 +1545,7 @@ dumpctx_create(isc_mem_t *mctx, dns_db_t *db, dns_dbversion_t *version, goto cleanup; } - isc_stdtime_get(&dctx->now); + dctx->now = isc_stdtime_now(); dns_db_attach(db, &dctx->db); dctx->do_date = dns_db_iscache(dctx->db); @@ -1913,7 +1913,7 @@ dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db, isc_result_t result; isc_buffer_t buffer; char *bufmem; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_totext_ctx_t ctx; dns_rdatasetiter_t *rdsiter = NULL; unsigned int options = DNS_DB_STALEOK; @@ -1928,8 +1928,6 @@ dns_master_dumpnodetostream(isc_mem_t *mctx, dns_db_t *db, return (ISC_R_UNEXPECTED); } - isc_stdtime_get(&now); - bufmem = isc_mem_get(mctx, initial_buffer_length); isc_buffer_init(&buffer, bufmem, initial_buffer_length); diff --git a/lib/dns/nta.c b/lib/dns/nta.c index 0b44f64339..cee1ea1714 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -161,7 +161,7 @@ fetch_done(void *arg) { isc_result_t eresult = resp->result; dns_ntatable_t *ntatable = nta->ntatable; dns_view_t *view = ntatable->view; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); if (dns_rdataset_isassociated(&nta->rdataset)) { dns_rdataset_disassociate(&nta->rdataset); @@ -182,7 +182,6 @@ fetch_done(void *arg) { } isc_mem_putanddetach(&resp->mctx, resp, sizeof(*resp)); - isc_stdtime_get(&now); switch (eresult) { case ISC_R_SUCCESS: @@ -478,12 +477,10 @@ dns_ntatable_totext(dns_ntatable_t *ntatable, const char *view, dns_rbtnode_t *node; dns_rbtnodechain_t chain; bool first = true; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); REQUIRE(VALID_NTATABLE(ntatable)); - isc_stdtime_get(&now); - RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); dns_rbtnodechain_init(&chain); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); @@ -557,13 +554,11 @@ dns_ntatable_save(dns_ntatable_t *ntatable, FILE *fp) { isc_result_t result; dns_rbtnode_t *node; dns_rbtnodechain_t chain; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); bool written = false; REQUIRE(VALID_NTATABLE(ntatable)); - isc_stdtime_get(&now); - RWLOCK(&ntatable->rwlock, isc_rwlocktype_read); dns_rbtnodechain_init(&chain); result = dns_rbtnodechain_first(&chain, ntatable->table, NULL, NULL); diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 8ed1bff3a8..cec5536fec 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -5016,7 +5016,7 @@ cache_find(dns_db_t *db, const dns_name_t *name, dns_dbversion_t *version, REQUIRE(version == NULL); if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } search.rbtversion = NULL; @@ -5417,7 +5417,7 @@ cache_findzonecut(dns_db_t *db, const dns_name_t *name, unsigned int options, REQUIRE(VALID_RBTDB(search.rbtdb)); if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } search.rbtversion = NULL; @@ -5667,7 +5667,7 @@ expirenode(dns_db_t *db, dns_dbnode_t *node, isc_stdtime_t now) { */ if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } if (isc_mem_isovermem(rbtdb->common.mctx)) { @@ -5950,7 +5950,7 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, result = ISC_R_SUCCESS; if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } lock = &rbtdb->node_locks[rbtnode->locknum].lock; @@ -6058,7 +6058,7 @@ allrdatasets(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, } } else { if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } rbtversion = NULL; } @@ -6923,7 +6923,7 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, if (rbtversion == NULL) { if (now == 0) { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } } else { now = 0; @@ -7623,11 +7623,7 @@ beginload(dns_db_t *db, dns_rdatacallbacks_t *callbacks) { loadctx = isc_mem_get(rbtdb->common.mctx, sizeof(*loadctx)); loadctx->rbtdb = rbtdb; - if (IS_CACHE(rbtdb)) { - isc_stdtime_get(&loadctx->now); - } else { - loadctx->now = 0; - } + loadctx->now = IS_CACHE(rbtdb) ? isc_stdtime_now() : 0; RBTDB_LOCK(&rbtdb->lock, isc_rwlocktype_write); diff --git a/lib/dns/rdata/generic/keydata_65533.c b/lib/dns/rdata/generic/keydata_65533.c index 9e00a77ab7..b6b21e7c95 100644 --- a/lib/dns/rdata/generic/keydata_65533.c +++ b/lib/dns/rdata/generic/keydata_65533.c @@ -207,9 +207,7 @@ totext_keydata(ARGS_TOTEXT) { RETERR(str_totext(buf, target)); if ((tctx->flags & DNS_STYLEFLAG_MULTILINE) != 0) { - isc_stdtime_t now; - - isc_stdtime_get(&now); + isc_stdtime_t now = isc_stdtime_now(); RETERR(str_totext(tctx->linebreak, target)); RETERR(str_totext("; next refresh: ", target)); diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index e40c2b33c5..ce08b76c12 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -1093,7 +1093,7 @@ fctx_cancelquery(resquery_t **queryp, isc_time_t *finish, bool no_response, fetchctx_t *fctx = NULL; dns_adbfind_t *find = NULL; dns_adbaddrinfo_t *addrinfo; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); REQUIRE(queryp != NULL); @@ -1217,7 +1217,6 @@ fctx_cancelquery(resquery_t **queryp, isc_time_t *finish, bool no_response, /* * Age RTTs of servers not tried. */ - isc_stdtime_get(&now); if (finish != NULL || age_untried) { for (addrinfo = ISC_LIST_HEAD(fctx->forwaddrs); addrinfo != NULL; @@ -1374,7 +1373,7 @@ fcount_logspill(fetchctx_t *fctx, fctxcount_t *counter, bool final) { } /* Do not log the cumulative message if the previous log is recent. */ - isc_stdtime_get(&now); + now = isc_stdtime_now(); if (!final && counter->logged > now - 60) { return; } @@ -3556,7 +3555,7 @@ normal_nses: return (DNS_R_SERVFAIL); } - isc_stdtime_get(&now); + now = isc_stdtime_now(); INSIST(ISC_LIST_EMPTY(fctx->finds)); INSIST(ISC_LIST_EMPTY(fctx->altfinds)); @@ -5178,7 +5177,7 @@ validated(void *arg) { goto cleanup_fetchctx; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); /* * If chaining, we need to make sure that the right result code diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index d776a78c86..3e96694e56 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -154,13 +154,11 @@ check_hints(dns_db_t *db) { dns_rdataset_t rootns; dns_dbiterator_t *dbiter = NULL; dns_dbnode_t *node = NULL; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_fixedname_t fixname; dns_name_t *name; dns_rdatasetiter_t *rdsiter = NULL; - isc_stdtime_get(&now); - name = dns_fixedname_initname(&fixname); dns_rdataset_init(&rootns); @@ -460,7 +458,7 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db) { dns_rdata_ns_t ns; dns_rdataset_t hintns, rootns; const char *viewname = "", *sep = ""; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_name_t *name; dns_fixedname_t fixed; @@ -468,8 +466,6 @@ dns_root_checkhints(dns_view_t *view, dns_db_t *hints, dns_db_t *db) { REQUIRE(db != NULL); REQUIRE(view != NULL); - isc_stdtime_get(&now); - if (strcmp(view->name, "_bind") != 0 && strcmp(view->name, "_default") != 0) { diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index f0ed8f112b..f48258ef93 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -1342,7 +1342,7 @@ dns_rrl_init(dns_rrl_t **rrlp, dns_view_t *view, int min_entries) { rrl = isc_mem_getx(view->mctx, sizeof(*rrl), ISC_MEM_ZERO); isc_mem_attach(view->mctx, &rrl->mctx); isc_mutex_init(&rrl->lock); - isc_stdtime_get(&rrl->ts_bases[0]); + rrl->ts_bases[0] = isc_stdtime_now(); view->rrl = rrl; diff --git a/lib/dns/time.c b/lib/dns/time.c index 1bf4a452fc..cffcb05eb6 100644 --- a/lib/dns/time.c +++ b/lib/dns/time.c @@ -101,7 +101,7 @@ dns_time64_totext(int64_t t, isc_buffer_t *target) { int64_t dns_time64_from32(uint32_t value) { - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); int64_t start; int64_t t; @@ -111,7 +111,7 @@ dns_time64_from32(uint32_t value) { * is defined, but even the current code is good until the year * 2106. */ - isc_stdtime_get(&now); + start = (int64_t)now; if (isc_serial_gt(value, now)) { t = start + (value - now); diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 45ac21c003..c7262c1688 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -180,7 +180,7 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin, dns_tsigkey_t *tsigkey = NULL; dns_fixedname_t fixed; dns_name_t *principal; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); isc_region_t intoken; isc_buffer_t *outtoken = NULL; dns_gss_ctx_id_t gss_ctx = NULL; @@ -243,8 +243,6 @@ process_gsstkey(dns_message_t *msg, dns_name_t *name, dns_rdata_tkey_t *tkeyin, * XXXDCL Section 4.1.3: Limit GSS_S_CONTINUE_NEEDED to 10 times. */ - isc_stdtime_get(&now); - if (dns_name_countlabels(principal) == 0U) { if (tsigkey != NULL) { dns_tsigkey_detach(&tsigkey); @@ -685,7 +683,7 @@ dns_tkey_buildgssquery(dns_message_t *msg, const dns_name_t *name, isc_mem_t *mctx, char **err_message) { dns_rdata_tkey_t tkey; isc_result_t result; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); isc_buffer_t token; unsigned char array[TEMP_BUFFER_SZ]; @@ -716,7 +714,6 @@ dns_tkey_buildgssquery(dns_message_t *msg, const dns_name_t *name, dns_name_clone(DNS_TSIG_GSSAPI_NAME, &tkey.algorithm); } - isc_stdtime_get(&now); tkey.inception = now; tkey.expire = now + lifetime; tkey.mode = DNS_TKEYMODE_GSSAPI; diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index 8eef675b82..f4278de865 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -389,14 +389,13 @@ cleanup_ring(dns_tsig_keyring_t *ring) { dns_name_t foundname; dns_fixedname_t fixedorigin; dns_name_t *origin; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_rbtnode_t *node; dns_tsigkey_t *tkey; /* * Start up a new iterator each time. */ - isc_stdtime_get(&now); dns_name_init(&foundname, NULL); origin = dns_fixedname_initname(&fixedorigin); @@ -601,7 +600,7 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) { dns_name_t foundname; dns_fixedname_t fixedorigin; dns_name_t *origin; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_rbtnode_t *node; dns_tsigkey_t *tkey; dns_tsig_keyring_t *ring; @@ -615,7 +614,6 @@ dns_tsigkeyring_dumpanddetach(dns_tsig_keyring_t **ringp, FILE *fp) { return (DNS_R_CONTINUE); } - isc_stdtime_get(&now); dns_name_init(&foundname, NULL); origin = dns_fixedname_initname(&fixedorigin); dns_rbtnodechain_init(&chain); @@ -805,7 +803,7 @@ dns_tsig_sign(dns_message_t *msg) { if (msg->fuzzing) { now = msg->fuzztime; } else { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } tsig.timesigned = now + msg->timeadjust; @@ -1159,7 +1157,7 @@ dns_tsig_verify(isc_buffer_t *source, dns_message_t *msg, if (msg->fuzzing) { now = msg->fuzztime; } else { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } /* @@ -1659,7 +1657,7 @@ tsig_verify_tcp(isc_buffer_t *source, dns_message_t *msg) { if (msg->fuzzing) { now = msg->fuzztime; } else { - isc_stdtime_get(&now); + now = isc_stdtime_now(); } if (now + msg->timeadjust > tsig.timesigned + tsig.fudge) { @@ -1738,7 +1736,7 @@ isc_result_t dns_tsigkey_find(dns_tsigkey_t **tsigkey, const dns_name_t *name, const dns_name_t *algorithm, dns_tsig_keyring_t *ring) { dns_tsigkey_t *key; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); isc_result_t result; REQUIRE(tsigkey != NULL); @@ -1750,7 +1748,6 @@ dns_tsigkey_find(dns_tsigkey_t **tsigkey, const dns_name_t *name, cleanup_ring(ring); RWUNLOCK(&ring->lock, isc_rwlocktype_write); - isc_stdtime_get(&now); RWLOCK(&ring->lock, isc_rwlocktype_read); key = NULL; result = dns_rbt_findname(ring->keys, name, 0, NULL, (void *)&key); @@ -1880,10 +1877,9 @@ dns_tsigkeyring_detach(dns_tsig_keyring_t **ringp) { void dns_keyring_restore(dns_tsig_keyring_t *ring, FILE *fp) { - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); isc_result_t result; - isc_stdtime_get(&now); do { result = restore_key(ring, now, fp); if (result == ISC_R_NOMORE) { diff --git a/lib/dns/update.c b/lib/dns/update.c index d3899e8e51..c547c041a8 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -1059,12 +1059,11 @@ find_zone_keys(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, isc_mem_t *mctx, unsigned int maxkeys, dst_key_t **keys, unsigned int *nkeys) { isc_result_t result; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_dbnode_t *node = NULL; const char *directory = dns_zone_getkeydirectory(zone); CHECK(dns_db_findnode(db, dns_db_origin(db), false, &node)); - isc_stdtime_get(&now); dns_zone_lock_keyfiles(zone); result = dns_dnssec_findzonekeys(db, ver, node, dns_db_origin(db), @@ -1561,7 +1560,7 @@ dns_update_signaturesinc(dns_update_log_t *log, dns_zone_t *zone, dns_db_t *db, goto failure; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); state->inception = now - 3600; /* Allow for some clock skew. */ state->expire = now + dns__jitter_expire(zone, sigvalidityinterval); @@ -2221,10 +2220,10 @@ dns__update_soaserial(uint32_t serial, dns_updatemethod_t method) { case dns_updatemethod_none: return (serial); case dns_updatemethod_unixtime: - isc_stdtime_get(&now); + now = isc_stdtime_now(); return (now); case dns_updatemethod_date: - isc_stdtime_get(&now); + now = isc_stdtime_now(); return (epoch_to_yyyymmdd((time_t)now) * 100); case dns_updatemethod_increment: /* RFC1982 */ diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 08a5395ef2..4b180d1e97 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -3019,7 +3019,7 @@ dns_validator_create(dns_view_t *view, dns_name_t *name, dns_rdatatype_t type, dns_rdataset_init(&val->fsigrdataset); dns_fixedname_init(&val->wild); dns_fixedname_init(&val->closest); - isc_stdtime_get(&val->start); + val->start = isc_stdtime_now(); val->magic = VALIDATOR_MAGIC; if ((options & DNS_VALIDATOR_DEFER) == 0) { diff --git a/lib/dns/view.c b/lib/dns/view.c index 686075b309..fdfc295239 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -2017,7 +2017,7 @@ dns_view_loadnta(dns_view_t *view) { dns_ntatable_t *ntatable = NULL; isc_lex_t *lex = NULL; isc_token_t token; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); REQUIRE(DNS_VIEW_VALID(view)); @@ -2028,7 +2028,6 @@ dns_view_loadnta(dns_view_t *view) { isc_lex_create(view->mctx, 1025, &lex); CHECK(isc_lex_openfile(lex, view->nta_file)); CHECK(dns_view_getntatable(view, &ntatable)); - isc_stdtime_get(&now); for (;;) { int options = (ISC_LEXOPT_EOL | ISC_LEXOPT_EOF); diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 7444fb29e3..36446abd15 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -4003,12 +4003,11 @@ create_keydata(dns_zone_t *zone, dns_db_t *db, dns_dbversion_t *ver, dns_rdata_keydata_t kd; unsigned char rrdata[4096]; isc_buffer_t rrdatabuf; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); REQUIRE(keynode != NULL); ENTER; - isc_stdtime_get(&now); /* * If the keynode has no trust anchor set, we shouldn't be here. @@ -4169,11 +4168,9 @@ load_secroots(dns_zone_t *zone, dns_name_t *name, dns_rdataset_t *rdataset) { dns_rdata_keydata_t keydata; dns_rdata_dnskey_t dnskey; int trusted = 0, revoked = 0, pending = 0; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); dns_keytable_t *sr = NULL; - isc_stdtime_get(&now); - result = dns_view_getsecroots(zone->view, &sr); if (result == ISC_R_SUCCESS) { dns_keytable_delete(sr, name, sfd_del, zone->view); @@ -4513,13 +4510,11 @@ sync_keyzone(dns_zone_t *zone, dns_db_t *db) { dns_rdataset_t *rdataset = NULL; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_keydata_t keydata; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); bool load = true; dns_name_t *rrname = NULL; uint32_t ttl; - isc_stdtime_get(&now); - dns_rriterator_current(&rrit, &rrname, &ttl, &rdataset, NULL); if (!dns_rdataset_isassociated(rdataset)) { dns_rriterator_destroy(&rrit); @@ -5158,11 +5153,10 @@ zone_postload(dns_zone_t *zone, dns_db_t *db, isc_time_t loadtime, result = dns_db_getsigningtime(db, &next, name); if (result == ISC_R_SUCCESS) { - isc_stdtime_t timenow; + isc_stdtime_t timenow = isc_stdtime_now(); char namebuf[DNS_NAME_FORMATSIZE]; char typebuf[DNS_RDATATYPE_FORMATSIZE]; - isc_stdtime_get(&timenow); dns_name_format(name, namebuf, sizeof(namebuf)); dns_rdatatype_format(next.covers, typebuf, sizeof(typebuf)); @@ -6832,7 +6826,7 @@ zone_resigninc(dns_zone_t *zone) { goto failure; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); result = dns__zone_findkeys(zone, db, version, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); @@ -8048,7 +8042,7 @@ zone_nsec3chain(dns_zone_t *zone) { goto failure; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); result = dns__zone_findkeys(zone, db, version, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); @@ -9136,7 +9130,7 @@ zone_sign(dns_zone_t *zone) { goto cleanup; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); result = dns__zone_findkeys(zone, db, version, now, zone->mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); @@ -9792,9 +9786,7 @@ refresh_time(dns_keyfetch_t *kfetch, bool retry) { dns_rdataset_t *rdset; dns_rdata_t sigrr = DNS_RDATA_INIT; dns_rdata_sig_t sig; - isc_stdtime_t now; - - isc_stdtime_get(&now); + isc_stdtime_t now = isc_stdtime_now(); if (dns_rdataset_isassociated(&kfetch->dnskeysigset)) { rdset = &kfetch->dnskeysigset; @@ -9864,10 +9856,9 @@ minimal_update(dns_keyfetch_t *kfetch, dns_dbversion_t *ver, dns_diff_t *diff) { dns_rdata_keydata_t keydata; dns_name_t *name; dns_zone_t *zone = kfetch->zone; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); name = dns_fixedname_name(&kfetch->name); - isc_stdtime_get(&now); for (result = dns_rdataset_first(&kfetch->keydataset); result == ISC_R_SUCCESS; @@ -10041,7 +10032,7 @@ keyfetch_done(void *arg) { goto cleanup; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); dns_name_format(keyname, namebuf, sizeof(namebuf)); result = dns_view_getsecroots(zone->view, &secroots); @@ -10742,7 +10733,7 @@ zone_refreshkeys(dns_zone_t *zone) { dns_diff_t diff; dns_rdata_t rdata = DNS_RDATA_INIT; dns_rdata_keydata_t kd; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); bool commit = false; bool fetching = false; bool timerset = false; @@ -10750,8 +10741,6 @@ zone_refreshkeys(dns_zone_t *zone) { ENTER; REQUIRE(zone->db != NULL); - isc_stdtime_get(&now); - LOCK_ZONE(zone); if (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_EXITING)) { isc_time_settoepoch(&zone->refreshkeytime); diff --git a/lib/isc/netmgr/tcp.c b/lib/isc/netmgr/tcp.c index 7163595399..b5c0facdc2 100644 --- a/lib/isc/netmgr/tcp.c +++ b/lib/isc/netmgr/tcp.c @@ -42,9 +42,8 @@ static atomic_uint_fast32_t last_tcpquota_log = 0; static bool can_log_tcp_quota(void) { - isc_stdtime_t now, last; - - isc_stdtime_get(&now); + isc_stdtime_t last; + isc_stdtime_t now = isc_stdtime_now(); last = atomic_exchange_relaxed(&last_tcpquota_log, now); if (now != last) { return (true); diff --git a/lib/ns/client.c b/lib/ns/client.c index c016c8986c..5414fa49d0 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -997,11 +997,10 @@ ns_client_addopt(ns_client_t *client, dns_message_t *message, no_nsid: if ((client->attributes & NS_CLIENTATTR_WANTCOOKIE) != 0) { isc_buffer_t buf; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); uint32_t nonce; isc_buffer_init(&buf, cookie, sizeof(cookie)); - isc_stdtime_get(&now); isc_random_buf(&nonce, sizeof(nonce)); @@ -1292,7 +1291,7 @@ process_cookie(ns_client_t *client, isc_buffer_t *buf, size_t optlen) { * Allow for a 5 minute clock skew between servers sharing a secret. * Only accept COOKIE if we have talked to the client in the last hour. */ - isc_stdtime_get(&now); + now = isc_stdtime_now(); if (isc_serial_gt(when, (now + 300)) || /* In the future. */ isc_serial_lt(when, (now - 3600))) { /* In the past. */ diff --git a/lib/ns/query.c b/lib/ns/query.c index 4ce1c4d7ab..d82a96995b 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -2286,7 +2286,7 @@ mark_secure(ns_client_t *client, dns_db_t *db, dns_name_t *name, return; } - isc_stdtime_get(&now); + now = isc_stdtime_now(); dns_rdataset_trimttl(rdataset, sigrdataset, rrsig, now, client->view->acceptexpired); @@ -2583,7 +2583,7 @@ stale_refresh_aftermath(ns_client_t *client, isc_result_t result) { * database, starting the stale-refresh-time window for it. * This is a condensed form of query_lookup(). */ - isc_stdtime_get(&client->now); + client->now = isc_stdtime_now(); client->query.attributes &= ~NS_QUERYATTR_RECURSIONOK; qctx_init(client, NULL, 0, &qctx); @@ -6280,7 +6280,7 @@ fetch_callback(void *arg) { /* * Update client->now. */ - isc_stdtime_get(&client->now); + client->now = isc_stdtime_now(); } else { /* * This is a fetch completion event for a canceled fetch. @@ -6412,9 +6412,7 @@ recparam_update(ns_query_recparam_t *param, dns_rdatatype_t qtype, static void recursionquota_log(ns_client_t *client, atomic_uint_fast32_t *last_log_time, const char *format, isc_quota_t *quota) { - isc_stdtime_t now; - - isc_stdtime_get(&now); + isc_stdtime_t now = isc_stdtime_now(); if (now == atomic_load_relaxed(last_log_time)) { return; } @@ -6757,7 +6755,7 @@ query_hookresume(void *arg) { INSIST(rev->ctx == client->query.hookactx); client->query.hookactx = NULL; canceled = false; - isc_stdtime_get(&client->now); + client->now = isc_stdtime_now(); } else { canceled = true; } diff --git a/tests/dns/dnstap_test.c b/tests/dns/dnstap_test.c index 6aa054e069..ead4a83ef7 100644 --- a/tests/dns/dnstap_test.c +++ b/tests/dns/dnstap_test.c @@ -141,7 +141,8 @@ ISC_RUN_TEST_IMPL(dns_dt_send) { isc_sockaddr_t qaddr; isc_sockaddr_t raddr; struct in_addr in; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); + isc_time_t p, f; struct fstrm_iothr_options *fopt; @@ -182,7 +183,6 @@ ISC_RUN_TEST_IMPL(dns_dt_send) { in.s_addr = inet_addr("10.53.0.2"); isc_sockaddr_fromin(&raddr, &in, 2112); - isc_stdtime_get(&now); isc_time_set(&p, now - 3600, 0); /* past */ isc_time_set(&f, now + 3600, 0); /* future */ diff --git a/tests/dns/keytable_test.c b/tests/dns/keytable_test.c index 9a86b85065..ac8ae02868 100644 --- a/tests/dns/keytable_test.c +++ b/tests/dns/keytable_test.c @@ -170,7 +170,7 @@ create_tables(void) { dns_rdata_ds_t ds; dns_fixedname_t fn; dns_name_t *keyname = dns_fixedname_name(&fn); - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); assert_int_equal(dns_test_makeview("view", false, &view), ISC_R_SUCCESS); @@ -199,7 +199,6 @@ create_tables(void) { ISC_R_SUCCESS); /* Add a negative trust anchor, duration 1 hour */ - isc_stdtime_get(&now); assert_int_equal(dns_ntatable_add(ntatable, str2name("insecure.example"), false, now, 3600), @@ -604,7 +603,7 @@ ISC_LOOP_TEST_IMPL(nta) { unsigned char digest[ISC_MAX_MD_SIZE]; dns_rdata_ds_t ds; dns_view_t *myview = NULL; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); result = dns_test_makeview("view", false, &myview); assert_int_equal(result, ISC_R_SUCCESS); @@ -625,7 +624,6 @@ ISC_LOOP_TEST_IMPL(nta) { NULL), assert_int_equal(result, ISC_R_SUCCESS); - isc_stdtime_get(&now); result = dns_ntatable_add(ntatable, str2name("insecure.example"), false, now, 1); assert_int_equal(result, ISC_R_SUCCESS); diff --git a/tests/dns/sigs_test.c b/tests/dns/sigs_test.c index dbb14ac86e..1dfdd83e34 100644 --- a/tests/dns/sigs_test.c +++ b/tests/dns/sigs_test.c @@ -294,7 +294,7 @@ ISC_RUN_TEST_IMPL(updatesigs_next) { dns_db_t *db = NULL; isc_result_t result; unsigned int nkeys; - isc_stdtime_t now; + isc_stdtime_t now = isc_stdtime_now(); size_t i; UNUSED(state); @@ -313,7 +313,6 @@ ISC_RUN_TEST_IMPL(updatesigs_next) { result = dns_zone_setkeydirectory(zone, TESTS_DIR "/testkeys"); assert_int_equal(result, ISC_R_SUCCESS); - isc_stdtime_get(&now); result = dns__zone_findkeys(zone, db, NULL, now, mctx, DNS_MAXZONEKEYS, zone_keys, &nkeys); assert_int_equal(result, ISC_R_SUCCESS); diff --git a/tests/dns/tsig_test.c b/tests/dns/tsig_test.c index 02b5926f0c..e18fc69dd6 100644 --- a/tests/dns/tsig_test.c +++ b/tests/dns/tsig_test.c @@ -104,7 +104,6 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) { isc_buffer_t sigbuf; isc_region_t r; isc_result_t result = ISC_R_SUCCESS; - isc_stdtime_t now; unsigned char tsigbuf[1024]; unsigned int count; unsigned int sigsize = 0; @@ -119,8 +118,7 @@ add_tsig(dst_context_t *tsigctx, dns_tsigkey_t *key, isc_buffer_t *target) { dns_name_init(&tsig.algorithm, NULL); dns_name_clone(key->algorithm, &tsig.algorithm); - isc_stdtime_get(&now); - tsig.timesigned = now; + tsig.timesigned = isc_stdtime_now(); tsig.fudge = DNS_TSIG_FUDGE; tsig.originalid = 50; tsig.error = dns_rcode_noerror; diff --git a/tests/dns/update_test.c b/tests/dns/update_test.c index afeaa5ce83..5ec4002db5 100644 --- a/tests/dns/update_test.c +++ b/tests/dns/update_test.c @@ -67,9 +67,9 @@ set_mystdtime(int year, int month, int day) { mystdtime = timegm(&tm); } -void -isc_stdtime_get(isc_stdtime_t *now) { - *now = mystdtime; +isc_stdtime_t +isc_stdtime_now(void) { + return (mystdtime); } /* simple increment by 1 */