2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

various style cleanups

This commit is contained in:
Evan Hunt
2020-02-06 10:28:53 -08:00
committed by Matthijs Mekking
parent 58aa084edc
commit 6504e7da95
4 changed files with 100 additions and 61 deletions

View File

@@ -2205,7 +2205,7 @@ check_zoneconf(const cfg_obj_t *zconfig, const cfg_obj_t *voptions,
for (element = cfg_list_first(kasps); element != NULL;
element = cfg_list_next(element))
{
const char* kn = cfg_obj_asstring(
const char *kn = cfg_obj_asstring(
cfg_tuple_get(cfg_listelt_value(element),
"name"));
if (strcmp(kaspname, kn) == 0) {

View File

@@ -24,8 +24,7 @@
#include <dns/keyvalues.h>
isc_result_t
dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp)
{
dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp) {
dns_kasp_t *kasp;
REQUIRE(name != NULL);
@@ -60,7 +59,7 @@ dns_kasp_create(isc_mem_t *mctx, const char *name, dns_kasp_t **kaspp)
kasp->parent_propagation_delay = DNS_KASP_PARENT_PROPDELAY;
kasp->parent_registration_delay = DNS_KASP_PARENT_REGDELAY;
// TODO: The rest of the KASP configuration
/* TODO: The rest of the KASP configuration */
kasp->magic = DNS_KASP_MAGIC;
*kaspp = kasp;
@@ -82,14 +81,14 @@ destroy(dns_kasp_t *kasp) {
dns_kasp_key_t *key;
dns_kasp_key_t *key_next;
ISC_INSIST(!ISC_LINK_LINKED(kasp, link));
REQUIRE(!ISC_LINK_LINKED(kasp, link));
for (key = ISC_LIST_HEAD(kasp->keys); key != NULL; key = key_next) {
key_next = ISC_LIST_NEXT(key, link);
ISC_LIST_UNLINK(kasp->keys, key, link);
dns_kasp_key_destroy(key);
}
ISC_INSIST(ISC_LIST_EMPTY(kasp->keys));
INSIST(ISC_LIST_EMPTY(kasp->keys));
isc_mem_free(kasp->mctx, kasp->name);
isc_mem_putanddetach(&kasp->mctx, kasp, sizeof(*kasp));
@@ -98,6 +97,7 @@ destroy(dns_kasp_t *kasp) {
void
dns_kasp_detach(dns_kasp_t **kaspp) {
REQUIRE(kaspp != NULL && DNS_KASP_VALID(*kaspp));
dns_kasp_t *kasp = *kaspp;
*kaspp = NULL;
@@ -106,9 +106,10 @@ dns_kasp_detach(dns_kasp_t **kaspp) {
}
}
const char*
const char *
dns_kasp_getname(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
return (kasp->name);
}
@@ -116,6 +117,7 @@ void
dns_kasp_freeze(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->frozen = true;
}
@@ -123,6 +125,7 @@ void
dns_kasp_thaw(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
kasp->frozen = false;
}
@@ -130,6 +133,7 @@ uint32_t
dns_kasp_signdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->signatures_validity - kasp->signatures_refresh);
}
@@ -137,6 +141,7 @@ uint32_t
dns_kasp_sigrefresh(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->signatures_refresh);
}
@@ -144,6 +149,7 @@ void
dns_kasp_setsigrefresh(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->signatures_refresh = value;
}
@@ -151,6 +157,7 @@ uint32_t
dns_kasp_sigvalidity(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->signatures_validity);
}
@@ -158,6 +165,7 @@ void
dns_kasp_setsigvalidity(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->signatures_validity = value;
}
@@ -165,6 +173,7 @@ uint32_t
dns_kasp_sigvalidity_dnskey(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->signatures_validity_dnskey);
}
@@ -172,6 +181,7 @@ void
dns_kasp_setsigvalidity_dnskey(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->signatures_validity = value;
}
@@ -179,6 +189,7 @@ dns_ttl_t
dns_kasp_dnskeyttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->dnskey_ttl);
}
@@ -186,6 +197,7 @@ void
dns_kasp_setdnskeyttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->dnskey_ttl = ttl;
}
@@ -193,6 +205,7 @@ uint32_t
dns_kasp_publishsafety(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->publish_safety);
}
@@ -200,6 +213,7 @@ void
dns_kasp_setpublishsafety(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->publish_safety = value;
}
@@ -207,6 +221,7 @@ uint32_t
dns_kasp_retiresafety(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->retire_safety);
}
@@ -214,6 +229,7 @@ void
dns_kasp_setretiresafety(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->retire_safety = value;
}
@@ -221,6 +237,7 @@ dns_ttl_t
dns_kasp_zonemaxttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->zone_max_ttl);
}
@@ -228,6 +245,7 @@ void
dns_kasp_setzonemaxttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->zone_max_ttl = ttl;
}
@@ -235,6 +253,7 @@ uint32_t
dns_kasp_zonepropagationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->zone_propagation_delay);
}
@@ -242,6 +261,7 @@ void
dns_kasp_setzonepropagationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->zone_propagation_delay = value;
}
@@ -249,6 +269,7 @@ dns_ttl_t
dns_kasp_dsttl(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->parent_ds_ttl);
}
@@ -256,6 +277,7 @@ void
dns_kasp_setdsttl(dns_kasp_t *kasp, dns_ttl_t ttl) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->parent_ds_ttl = ttl;
}
@@ -263,6 +285,7 @@ uint32_t
dns_kasp_parentpropagationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->parent_propagation_delay);
}
@@ -270,6 +293,7 @@ void
dns_kasp_setparentpropagationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->parent_propagation_delay = value;
}
@@ -277,6 +301,7 @@ uint32_t
dns_kasp_parentregistrationdelay(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->parent_registration_delay);
}
@@ -284,12 +309,12 @@ void
dns_kasp_setparentregistrationdelay(dns_kasp_t *kasp, uint32_t value) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
kasp->parent_registration_delay = value;
}
isc_result_t
dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp)
{
dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp) {
dns_kasp_t *kasp = NULL;
REQUIRE(kaspp != NULL && *kaspp == NULL);
@@ -297,7 +322,6 @@ dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp)
if (list == NULL) {
return (ISC_R_NOTFOUND);
}
INSIST(list != NULL);
for (kasp = ISC_LIST_HEAD(*list); kasp != NULL;
kasp = ISC_LIST_NEXT(kasp, link))
@@ -306,31 +330,32 @@ dns_kasplist_find(dns_kasplist_t *list, const char *name, dns_kasp_t **kaspp)
break;
}
}
if (kasp == NULL) {
return (ISC_R_NOTFOUND);
}
dns_kasp_attach(kasp, kaspp);
return (ISC_R_SUCCESS);
}
dns_kasp_keylist_t
dns_kasp_keys(dns_kasp_t *kasp)
{
dns_kasp_keys(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(kasp->frozen);
return (kasp->keys);
}
bool
dns_kasp_keylist_empty(dns_kasp_t *kasp)
{
dns_kasp_keylist_empty(dns_kasp_t *kasp) {
REQUIRE(DNS_KASP_VALID(kasp));
return (ISC_LIST_EMPTY(kasp->keys));
}
void
dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key)
{
dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key) {
REQUIRE(DNS_KASP_VALID(kasp));
REQUIRE(!kasp->frozen);
REQUIRE(key != NULL);
@@ -339,8 +364,7 @@ dns_kasp_addkey(dns_kasp_t *kasp, dns_kasp_key_t *key)
}
isc_result_t
dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp)
{
dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp) {
dns_kasp_key_t *key;
REQUIRE(DNS_KASP_VALID(kasp));
@@ -361,16 +385,16 @@ dns_kasp_key_create(dns_kasp_t *kasp, dns_kasp_key_t **keyp)
}
void
dns_kasp_key_destroy(dns_kasp_key_t* key)
{
dns_kasp_key_destroy(dns_kasp_key_t *key) {
REQUIRE(key != NULL);
isc_mem_putanddetach(&key->mctx, key, sizeof(*key));
}
uint32_t
dns_kasp_key_algorithm(dns_kasp_key_t *key) {
REQUIRE(key != NULL);
return (key->algorithm);
}
@@ -420,21 +444,21 @@ dns_kasp_key_size(dns_kasp_key_t *key) {
uint32_t
dns_kasp_key_lifetime(dns_kasp_key_t *key) {
REQUIRE(key != NULL);
return (key->lifetime);
}
bool
dns_kasp_key_ksk(dns_kasp_key_t *key) {
REQUIRE(key != NULL);
return (key->role & DNS_KASP_KEY_ROLE_KSK);
}
bool
dns_kasp_key_zsk(dns_kasp_key_t *key) {
REQUIRE(key != NULL);
return (key->role & DNS_KASP_KEY_ROLE_ZSK);
}

View File

@@ -216,21 +216,27 @@ cfg_kasp_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, isc_log_t *logctx,
maps[i] = NULL;
/* Configuration: Signatures */
dns_kasp_setsigrefresh(kasp, get_duration(maps, "signatures-refresh",
DNS_KASP_SIG_REFRESH));
dns_kasp_setsigvalidity(kasp, get_duration(maps, "signatures-validity",
DNS_KASP_SIG_VALIDITY));
dns_kasp_setsigvalidity_dnskey(kasp, get_duration(maps,
"signatures-validity-dnskey",
DNS_KASP_SIG_VALIDITY_DNSKEY));
dns_kasp_setsigrefresh(kasp,
get_duration(maps, "signatures-refresh",
DNS_KASP_SIG_REFRESH));
dns_kasp_setsigvalidity(kasp,
get_duration(maps, "signatures-validity",
DNS_KASP_SIG_VALIDITY));
dns_kasp_setsigvalidity_dnskey(kasp,
get_duration(maps,
"signatures-validity-dnskey",
DNS_KASP_SIG_VALIDITY_DNSKEY));
/* Configuration: Keys */
dns_kasp_setdnskeyttl(kasp, get_duration(maps, "dnskey-ttl",
DNS_KASP_KEY_TTL));
dns_kasp_setpublishsafety(kasp, get_duration(maps, "publish-safety",
DNS_KASP_PUBLISH_SAFETY));
dns_kasp_setretiresafety(kasp, get_duration(maps, "retire-safety",
DNS_KASP_RETIRE_SAFETY));
dns_kasp_setdnskeyttl(kasp,
get_duration(maps, "dnskey-ttl",
DNS_KASP_KEY_TTL));
dns_kasp_setpublishsafety(kasp,
get_duration(maps, "publish-safety",
DNS_KASP_PUBLISH_SAFETY));
dns_kasp_setretiresafety(kasp,
get_duration(maps, "retire-safety",
DNS_KASP_RETIRE_SAFETY));
(void)confget(maps, "keys", &keys);
if (keys == NULL) {
@@ -249,33 +255,34 @@ cfg_kasp_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, isc_log_t *logctx,
}
}
}
ISC_INSIST(!(dns_kasp_keylist_empty(kasp)));
INSIST(!(dns_kasp_keylist_empty(kasp)));
/* Configuration: Zone settings */
dns_kasp_setzonemaxttl(kasp, get_duration(maps, "max-zone-ttl",
DNS_KASP_ZONE_MAXTTL));
dns_kasp_setzonepropagationdelay(kasp, get_duration(maps,
"zone-propagation-delay",
DNS_KASP_ZONE_PROPDELAY));
"zone-propagation-delay",
DNS_KASP_ZONE_PROPDELAY));
/* Configuration: Parent settings */
dns_kasp_setdsttl(kasp, get_duration(maps, "parent-ds-ttl",
DNS_KASP_DS_TTL));
dns_kasp_setparentpropagationdelay(kasp, get_duration(maps,
"parent-propagation-delay",
DNS_KASP_PARENT_PROPDELAY));
"parent-propagation-delay",
DNS_KASP_PARENT_PROPDELAY));
dns_kasp_setparentregistrationdelay(kasp, get_duration(maps,
"parent-registration-delay",
DNS_KASP_PARENT_REGDELAY));
"parent-registration-delay",
DNS_KASP_PARENT_REGDELAY));
// TODO: Rest of the configuration
/* TODO: Rest of the configuration */
/* Append it to the list for future lookups. */
ISC_LIST_APPEND(*kasplist, kasp, link);
ISC_INSIST(!(ISC_LIST_EMPTY(*kasplist)));
INSIST(!(ISC_LIST_EMPTY(*kasplist)));
/* Success: Attach the kasp to the pointer and return. */
dns_kasp_attach(kasp, kaspp);
/* Don't detach as kasp is on '*kasplist' */
return (ISC_R_SUCCESS);

View File

@@ -989,7 +989,7 @@ numlen(uint32_t num) {
size_t count = 0;
if (period == 0) {
return 1;
return (1);
}
while (period > 0) {
count++;
@@ -1181,8 +1181,8 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Every duration starts with 'P' */
P = strchr(str, 'P');
if (!P) {
return (ISC_R_BADNUMBER);
if (P == NULL) {
return (ISC_R_BADNUMBER);
}
/* Record the time indicator. */
@@ -1190,57 +1190,63 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Record years. */
X = strchr(str, 'Y');
if (X) {
if (X != NULL) {
duration->parts[0] = atoi(str+1);
str = X;
not_weeks = true;
}
/* Record months. */
X = strchr(str, 'M');
/*
* M could be months or minutes. This is months if there is no time
* part, or this M indicator is before the time indicator.
*/
if (X && (!T || (size_t) (X-P) < (size_t) (T-P))) {
if (X != NULL && (T == NULL || (size_t) (X-P) < (size_t) (T-P))) {
duration->parts[1] = atoi(str+1);
str = X;
not_weeks = true;
}
/* Record days. */
X = strchr(str, 'D');
if (X) {
if (X != NULL) {
duration->parts[3] = atoi(str+1);
str = X;
not_weeks = true;
}
/* Time part? */
if (T) {
if (T != NULL) {
str = T;
not_weeks = true;
}
/* Record hours. */
X = strchr(str, 'H');
if (X && T) {
if (X != NULL && T != NULL) {
duration->parts[4] = atoi(str+1);
str = X;
not_weeks = true;
}
/* Record minutes. */
X = strrchr(str, 'M');
/*
* M could be months or minutes. This is minutes if there is a time
* part and the M indicator is behind the time indicator.
*/
if (X && T && (size_t) (X-P) > (size_t) (T-P)) {
if (X != NULL && T != NULL && (size_t) (X-P) > (size_t) (T-P)) {
duration->parts[5] = atoi(str+1);
str = X;
not_weeks = true;
}
/* Record seconds. */
X = strchr(str, 'S');
if (X && T) {
if (X != NULL && T != NULL) {
duration->parts[6] = atoi(str+1);
str = X;
not_weeks = true;
@@ -1248,7 +1254,7 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
/* Or is the duration configured in weeks? */
W = strchr(buf, 'W');
if (W) {
if (W != NULL) {
if (not_weeks) {
/* Mix of weeks and other indicators is not allowed */
return (ISC_R_BADNUMBER);
@@ -1267,8 +1273,7 @@ duration_fromtext(isc_textregion_t *source, cfg_duration_t *duration) {
}
static isc_result_t
cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret)
{
parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret) {
isc_result_t result;
cfg_obj_t *obj = NULL;
cfg_duration_t duration;
@@ -1293,6 +1298,7 @@ cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret)
duration.parts[6] = ttl;
duration.iso8601 = false;
}
if (result == ISC_R_RANGE) {
cfg_parser_error(pctx, CFG_LOG_NEAR,
"duration or TTL out of range");
@@ -1300,9 +1306,11 @@ cfg__parse_duration(cfg_parser_t *pctx, cfg_obj_t **ret)
} else if (result != ISC_R_SUCCESS) {
goto cleanup;
}
CHECK(cfg_create_obj(pctx, &cfg_type_duration, &obj));
obj->value.duration = duration;
*ret = obj;
return (ISC_R_SUCCESS);
cleanup:
@@ -1325,7 +1333,7 @@ cfg_parse_duration(cfg_parser_t *pctx, const cfg_type_t *type,
goto cleanup;
}
return cfg__parse_duration(pctx, ret);
return (parse_duration(pctx, ret));
cleanup:
cfg_parser_error(pctx, CFG_LOG_NEAR,
@@ -1362,7 +1370,7 @@ cfg_parse_duration_or_unlimited(cfg_parser_t *pctx, const cfg_type_t *type,
return (ISC_R_SUCCESS);
}
return cfg__parse_duration(pctx, ret);
return (parse_duration(pctx, ret));
cleanup:
cfg_parser_error(pctx, CFG_LOG_NEAR,