Commit e851ed0b authored by Evan Hunt's avatar Evan Hunt
Browse files

apply the modified style

parent 0255a974
Pipeline #33994 passed with stages
in 34 minutes and 50 seconds
......@@ -67,20 +67,20 @@
goto cleanup; \
} while (0)
#define ERR_IS_CNAME 1
#define ERR_NO_ADDRESSES 2
#define ERR_IS_CNAME 1
#define ERR_NO_ADDRESSES 2
#define ERR_LOOKUP_FAILURE 3
#define ERR_EXTRA_A 4
#define ERR_EXTRA_AAAA 5
#define ERR_MISSING_GLUE 5
#define ERR_IS_MXCNAME 6
#define ERR_IS_SRVCNAME 7
#define ERR_EXTRA_A 4
#define ERR_EXTRA_AAAA 5
#define ERR_MISSING_GLUE 5
#define ERR_IS_MXCNAME 6
#define ERR_IS_SRVCNAME 7
static const char *dbtype[] = { "rbt" };
int debug = 0;
int debug = 0;
const char *journal = NULL;
bool nomerge = true;
bool nomerge = true;
#if CHECK_LOCAL
bool docheckmx = true;
bool dochecksrv = true;
......@@ -107,20 +107,18 @@ static isc_logcategory_t categories[] = { { "", 0 },
{ NULL, 0 } };
static isc_symtab_t *symtab = NULL;
static isc_mem_t * sym_mctx;
static isc_mem_t *sym_mctx;
static void
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg)
{
freekey(char *key, unsigned int type, isc_symvalue_t value, void *userarg) {
UNUSED(type);
UNUSED(value);
isc_mem_free(userarg, key);
}
static void
add(char *key, int value)
{
isc_result_t result;
add(char *key, int value) {
isc_result_t result;
isc_symvalue_t symvalue;
if (sym_mctx == NULL) {
......@@ -146,8 +144,7 @@ add(char *key, int value)
}
static bool
logged(char *key, int value)
{
logged(char *key, int value) {
isc_result_t result;
if (symtab == NULL) {
......@@ -163,19 +160,18 @@ logged(char *key, int value)
static bool
checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
dns_rdataset_t *a, dns_rdataset_t *aaaa)
{
dns_rdataset_t *a, dns_rdataset_t *aaaa) {
dns_rdataset_t *rdataset;
dns_rdata_t rdata = DNS_RDATA_INIT;
dns_rdata_t rdata = DNS_RDATA_INIT;
struct addrinfo hints, *ai, *cur;
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
char addrbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:123.123.123.123")];
bool answer = true;
bool match;
const char *type;
void * ptr = NULL;
int result;
void *ptr = NULL;
int result;
REQUIRE(a == NULL || !dns_rdataset_isassociated(a) ||
a->type == dns_rdatatype_a);
......@@ -216,7 +212,8 @@ checkns(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner,
}
if (cur != NULL && cur->ai_canonname != NULL &&
strcasecmp(cur->ai_canonname, namebuf) != 0 &&
!logged(namebuf, ERR_IS_CNAME)) {
!logged(namebuf, ERR_IS_CNAME))
{
dns_zone_log(zone, ISC_LOG_ERROR,
"%s/NS '%s' (out of zone) "
"is a CNAME '%s' (illegal)",
......@@ -350,8 +347,8 @@ checkmissing:
}
while (result == ISC_R_SUCCESS && !match) {
dns_rdataset_current(rdataset, &rdata);
if (memcmp(ptr, rdata.data, rdata.length) ==
0) {
if (memcmp(ptr, rdata.data, rdata.length) == 0)
{
match = true;
}
dns_rdata_reset(&rdata);
......@@ -379,14 +376,13 @@ checkmissing:
}
static bool
checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
{
checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
struct addrinfo hints, *ai, *cur;
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
bool answer = true;
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
bool answer = true;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
......@@ -417,7 +413,8 @@ checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
cur = cur->ai_next;
}
if (cur != NULL && cur->ai_canonname != NULL &&
strcasecmp(cur->ai_canonname, namebuf) != 0) {
strcasecmp(cur->ai_canonname, namebuf) != 0)
{
if ((zone_options & DNS_ZONEOPT_WARNMXCNAME) != 0) {
level = ISC_LOG_WARNING;
}
......@@ -465,14 +462,13 @@ checkmx(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
}
static bool
checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
{
checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) {
struct addrinfo hints, *ai, *cur;
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
bool answer = true;
char namebuf[DNS_NAME_FORMATSIZE + 1];
char ownerbuf[DNS_NAME_FORMATSIZE];
int result;
int level = ISC_LOG_ERROR;
bool answer = true;
memset(&hints, 0, sizeof(hints));
hints.ai_flags = AI_CANONNAME;
......@@ -503,7 +499,8 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
cur = cur->ai_next;
}
if (cur != NULL && cur->ai_canonname != NULL &&
strcasecmp(cur->ai_canonname, namebuf) != 0) {
strcasecmp(cur->ai_canonname, namebuf) != 0)
{
if ((zone_options & DNS_ZONEOPT_WARNSRVCNAME) != 0) {
level = ISC_LOG_WARNING;
}
......@@ -551,11 +548,10 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner)
}
isc_result_t
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp)
{
setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp) {
isc_logdestination_t destination;
isc_logconfig_t * logconfig = NULL;
isc_log_t * log = NULL;
isc_logconfig_t *logconfig = NULL;
isc_log_t *log = NULL;
RUNTIME_CHECK(isc_log_create(mctx, &log, &logconfig) == ISC_R_SUCCESS);
isc_log_registercategories(log, categories);
......@@ -581,17 +577,16 @@ setup_logging(isc_mem_t *mctx, FILE *errout, isc_log_t **logp)
/*% scan the zone for oversize TTLs */
static isc_result_t
check_ttls(dns_zone_t *zone, dns_ttl_t maxttl)
{
isc_result_t result;
dns_db_t * db = NULL;
dns_dbversion_t * version = NULL;
dns_dbnode_t * node = NULL;
dns_dbiterator_t * dbiter = NULL;
check_ttls(dns_zone_t *zone, dns_ttl_t maxttl) {
isc_result_t result;
dns_db_t *db = NULL;
dns_dbversion_t *version = NULL;
dns_dbnode_t *node = NULL;
dns_dbiterator_t *dbiter = NULL;
dns_rdatasetiter_t *rdsiter = NULL;
dns_rdataset_t rdataset;
dns_fixedname_t fname;
dns_name_t * name;
dns_rdataset_t rdataset;
dns_fixedname_t fname;
dns_name_t *name;
name = dns_fixedname_initname(&fname);
dns_rdataset_init(&rdataset);
......@@ -602,7 +597,8 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl)
CHECK(dns_db_createiterator(db, 0, &dbiter));
for (result = dns_dbiterator_first(dbiter); result == ISC_R_SUCCESS;
result = dns_dbiterator_next(dbiter)) {
result = dns_dbiterator_next(dbiter))
{
result = dns_dbiterator_current(dbiter, &node, name);
if (result == DNS_R_NEWORIGIN) {
result = ISC_R_SUCCESS;
......@@ -612,11 +608,12 @@ check_ttls(dns_zone_t *zone, dns_ttl_t maxttl)
CHECK(dns_db_allrdatasets(db, node, version, 0, &rdsiter));
for (result = dns_rdatasetiter_first(rdsiter);
result == ISC_R_SUCCESS;
result = dns_rdatasetiter_next(rdsiter)) {
result = dns_rdatasetiter_next(rdsiter))
{
dns_rdatasetiter_current(rdsiter, &rdataset);
if (rdataset.ttl > maxttl) {
char nbuf[DNS_NAME_FORMATSIZE];
char tbuf[255];
char nbuf[DNS_NAME_FORMATSIZE];
char tbuf[255];
isc_buffer_t b;
isc_region_t r;
......@@ -672,15 +669,14 @@ cleanup:
isc_result_t
load_zone(isc_mem_t *mctx, const char *zonename, const char *filename,
dns_masterformat_t fileformat, const char *classname,
dns_ttl_t maxttl, dns_zone_t **zonep)
{
isc_result_t result;
dns_ttl_t maxttl, dns_zone_t **zonep) {
isc_result_t result;
dns_rdataclass_t rdclass;
isc_textregion_t region;
isc_buffer_t buffer;
dns_fixedname_t fixorigin;
dns_name_t * origin;
dns_zone_t * zone = NULL;
isc_buffer_t buffer;
dns_fixedname_t fixorigin;
dns_name_t *origin;
dns_zone_t *zone = NULL;
REQUIRE(zonep == NULL || *zonep == NULL);
......@@ -751,11 +747,10 @@ cleanup:
isc_result_t
dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
dns_masterformat_t fileformat, const dns_master_style_t *style,
const uint32_t rawversion)
{
const uint32_t rawversion) {
isc_result_t result;
FILE * output = stdout;
const char * flags;
FILE *output = stdout;
const char *flags;
flags = (fileformat == dns_masterformat_text) ? "w" : "wb";
......@@ -791,11 +786,10 @@ dump_zone(const char *zonename, dns_zone_t *zone, const char *filename,
#ifdef _WIN32
void
InitSockets(void)
{
WORD wVersionRequested;
InitSockets(void) {
WORD wVersionRequested;
WSADATA wsaData;
int err;
int err;
wVersionRequested = MAKEWORD(2, 0);
......@@ -807,8 +801,7 @@ InitSockets(void)
}
void
DestroySockets(void)
{
DestroySockets(void) {
WSACleanup();
}
#endif /* ifdef _WIN32 */
......@@ -56,12 +56,10 @@ isc_log_t *logc = NULL;
} while (0)
/*% usage */
ISC_PLATFORM_NORETURN_PRE static void
usage(void) ISC_PLATFORM_NORETURN_POST;
ISC_PLATFORM_NORETURN_PRE static void usage(void) ISC_PLATFORM_NORETURN_POST;
static void
usage(void)
{
usage(void) {
fprintf(stderr,
"usage: %s [-chijlvz] [-p [-x]] [-t directory] "
"[named.conf]\n",
......@@ -71,10 +69,9 @@ usage(void)
/*% directory callback */
static isc_result_t
directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg)
{
directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg) {
isc_result_t result;
const char * directory;
const char *directory;
REQUIRE(strcasecmp("directory", clausename) == 0);
......@@ -97,8 +94,7 @@ directory_callback(const char *clausename, const cfg_obj_t *obj, void *arg)
}
static bool
get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj)
{
get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj) {
int i;
for (i = 0;; i++) {
if (maps[i] == NULL) {
......@@ -111,14 +107,13 @@ get_maps(const cfg_obj_t **maps, const char *name, const cfg_obj_t **obj)
}
static bool
get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj)
{
get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj) {
const cfg_listelt_t *element;
const cfg_obj_t * checknames;
const cfg_obj_t * type;
const cfg_obj_t * value;
isc_result_t result;
int i;
const cfg_obj_t *checknames;
const cfg_obj_t *type;
const cfg_obj_t *value;
isc_result_t result;
int i;
for (i = 0;; i++) {
if (maps[i] == NULL) {
......@@ -134,13 +129,14 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj)
return (true);
}
for (element = cfg_list_first(checknames); element != NULL;
element = cfg_list_next(element)) {
element = cfg_list_next(element))
{
value = cfg_listelt_value(element);
type = cfg_tuple_get(value, "type");
if ((strcasecmp(cfg_obj_asstring(type), "primary") !=
0) &&
(strcasecmp(cfg_obj_asstring(type), "master") !=
0)) {
(strcasecmp(cfg_obj_asstring(type), "master") != 0))
{
continue;
}
*obj = cfg_tuple_get(value, "mode");
......@@ -150,10 +146,9 @@ get_checknames(const cfg_obj_t **maps, const cfg_obj_t **obj)
}
static isc_result_t
configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx)
{
isc_result_t result;
dns_db_t * db = NULL;
configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx) {
isc_result_t result;
dns_db_t *db = NULL;
dns_rdataclass_t rdclass;
isc_textregion_t r;
......@@ -181,26 +176,25 @@ configure_hint(const char *zfile, const char *zclass, isc_mem_t *mctx)
static isc_result_t
configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
const cfg_obj_t *vconfig, const cfg_obj_t *config,
isc_mem_t *mctx, bool list)
{
int i = 0;
isc_result_t result;
const char * zclass;
const char * zname;
const char * zfile = NULL;
const cfg_obj_t * maps[4];
const cfg_obj_t * mastersobj = NULL;
const cfg_obj_t * inviewobj = NULL;
const cfg_obj_t * zoptions = NULL;
const cfg_obj_t * classobj = NULL;
const cfg_obj_t * typeobj = NULL;
const cfg_obj_t * fileobj = NULL;
const cfg_obj_t * dlzobj = NULL;
const cfg_obj_t * dbobj = NULL;
const cfg_obj_t * obj = NULL;
const cfg_obj_t * fmtobj = NULL;
isc_mem_t *mctx, bool list) {
int i = 0;
isc_result_t result;
const char *zclass;
const char *zname;
const char *zfile = NULL;
const cfg_obj_t *maps[4];
const cfg_obj_t *mastersobj = NULL;
const cfg_obj_t *inviewobj = NULL;
const cfg_obj_t *zoptions = NULL;
const cfg_obj_t *classobj = NULL;
const cfg_obj_t *typeobj = NULL;
const cfg_obj_t *fileobj = NULL;
const cfg_obj_t *dlzobj = NULL;
const cfg_obj_t *dbobj = NULL;
const cfg_obj_t *obj = NULL;
const cfg_obj_t *fmtobj = NULL;
dns_masterformat_t masterformat;
dns_ttl_t maxttl = 0;
dns_ttl_t maxttl = 0;
zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_MANYERRORS;
......@@ -250,7 +244,8 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
*/
cfg_map_get(zoptions, "database", &dbobj);
if (dbobj != NULL && strcmp("rbt", cfg_obj_asstring(dbobj)) != 0 &&
strcmp("rbt64", cfg_obj_asstring(dbobj)) != 0) {
strcmp("rbt64", cfg_obj_asstring(dbobj)) != 0)
{
return (ISC_R_SUCCESS);
}
......@@ -273,7 +268,8 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
return (configure_hint(zfile, zclass, mctx));
} else if ((strcasecmp(cfg_obj_asstring(typeobj), "primary") != 0) &&
(strcasecmp(cfg_obj_asstring(typeobj), "master") != 0) &&
(strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0)) {
(strcasecmp(cfg_obj_asstring(typeobj), "redirect") != 0))
{
return (ISC_R_SUCCESS);
}
......@@ -459,13 +455,12 @@ configure_zone(const char *vclass, const char *view, const cfg_obj_t *zconfig,
/*% configure a view */
static isc_result_t
configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
const cfg_obj_t *vconfig, isc_mem_t *mctx, bool list)
{
const cfg_obj_t *vconfig, isc_mem_t *mctx, bool list) {
const cfg_listelt_t *element;
const cfg_obj_t * voptions;
const cfg_obj_t * zonelist;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
const cfg_obj_t *voptions;
const cfg_obj_t *zonelist;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
voptions = NULL;
if (vconfig != NULL) {
......@@ -480,7 +475,8 @@ configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
}
for (element = cfg_list_first(zonelist); element != NULL;
element = cfg_list_next(element)) {
element = cfg_list_next(element))
{
const cfg_obj_t *zconfig = cfg_listelt_value(element);
tresult = configure_zone(vclass, view, zconfig, vconfig, config,
mctx, list);
......@@ -493,8 +489,7 @@ configure_view(const char *vclass, const char *view, const cfg_obj_t *config,
static isc_result_t
config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
dns_rdataclass_t *classp)
{
dns_rdataclass_t *classp) {
isc_textregion_t r;
if (!cfg_obj_isstring(classobj)) {
......@@ -508,23 +503,24 @@ config_getclass(const cfg_obj_t *classobj, dns_rdataclass_t defclass,
/*% load zones from the configuration */
static isc_result_t
load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx, bool list_zones)
{
load_zones_fromconfig(const cfg_obj_t *config, isc_mem_t *mctx,
bool list_zones) {
const cfg_listelt_t *element;
const cfg_obj_t * views;
const cfg_obj_t * vconfig;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
const cfg_obj_t *views;
const cfg_obj_t *vconfig;
isc_result_t result = ISC_R_SUCCESS;
isc_result_t tresult;
views = NULL;
(void)cfg_map_get(config, "view", &views);
for (element = cfg_list_first(views); element != NULL;
element = cfg_list_next(element)) {
element = cfg_list_next(element))
{
const cfg_obj_t *classobj;
dns_rdataclass_t viewclass;
const char * vname;
char buf[sizeof("CLASS65535")];
const char *vname;
char buf[sizeof("CLASS65535")];
vconfig = cfg_listelt_value(element);
if (vconfig == NULL) {
......@@ -559,8 +555,7 @@ cleanup:
}
static void
output(void *closure, const char *text, int textlen)
{
output(void *closure, const char *text, int textlen) {
UNUSED(closure);
if (fwrite(text, 1, textlen, stdout) != (size_t)textlen) {
perror("fwrite");
......@@ -570,20 +565,19 @@ output(void *closure, const char *text, int textlen)
/*% The main processing routine */
int
main(int argc, char **argv)
{
int c;
main(int argc, char **argv) {
int c;
cfg_parser_t *parser = NULL;
cfg_obj_t * config = NULL;
const char * conffile = NULL;
isc_mem_t * mctx = NULL;
isc_result_t result;
int exit_status = 0;
bool load_zones = false;
bool list_zones = false;
bool print = false;
bool nodeprecate = false;
unsigned int flags = 0;
cfg_obj_t *config = NULL;
const char *conffile = NULL;
isc_mem_t *mctx = NULL;
isc_result_t result;
int exit_status = 0;
bool load_zones = false;
bool list_zones = false;
bool print = false;
bool nodeprecate = false;
unsigned int flags = 0;
isc_commandline_errprint = false;
......@@ -594,16 +588,16 @@ main(int argc, char **argv)
while ((c = isc_commandline_parse(argc, argv, CMDLINE_FLAGS)) != -1) {
switch (c) {
case 'm':
if (strcasecmp(isc_commandline_argument, "record") ==
0) {
if (strcasecmp(isc_commandline_argument, "record") == 0)
{
isc_mem_debugging |= ISC_MEM_DEBUGRECORD;
}
if (strcasecmp(isc_commandline_argument, "trace") ==
0) {
if (strcasecmp(isc_commandline_argument, "trace") == 0)
{
isc_mem_debugging |= ISC_MEM_DEBUGTRACE;
}
if (strcasecmp(isc_commandline_argument, "usage") ==
0) {
if (strcasecmp(isc_commandline_argument, "usage") == 0)
{
isc_mem_debugging |= ISC_MEM_DEBUGUSAGE;
}
if (strcasecmp(isc_commandline_argument, "size") == 0) {
......@@ -725,7 +719,8 @@ main(int argc, char **argv)
cfg_parser_setcallback(parser, directory_callback, NULL);
if (cfg_parse_file(parser, conffile, &cfg_type_namedconf, &config) !=
ISC_R_SUCCESS) {
ISC_R_SUCCESS)
{
exit(1);
}
......
......@@ -42,13 +42,13 @@
#include "check-tool.h"
static int quiet = 0;
static isc_mem_t * mctx = NULL;
dns_zone_t * zone = NULL;
dns_zonetype_t zonetype = dns_zone_master;
static int dumpzone = 0;
static const char * output_filename;
static const char * prog_name = NULL;
static int quiet = 0;
static isc_mem_t *mctx = NULL;
dns_zone_t *zone = NULL;
dns_zonetype_t zonetype = dns_zone_master;
static int dumpzone = 0;
static const char *output_filename;
static const char *prog_name = NULL;
static const dns_master_style_t *outputstyle = NULL;