Commit d3b49b66 authored by Ondřej Surý's avatar Ondřej Surý

Merge branch 'each-style-tweak' into 'master'

adjust clang-format options to get closer to ISC style

See merge request !3061
parents 67b68e06 e851ed0b
Pipeline #34032 failed with stages
in 44 minutes and 22 seconds
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
BreakBeforeBraces: Linux
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterEnum: false
AfterStruct: false
AfterUnion: false
AfterControlStatement: MultiLine
AfterFunction: false # should also be MultiLine, but not yet supported
AfterExternBlock: false
BeforeElse: false
IndentBraces: false
SplitEmptyFunction: true
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AlwaysBreakAfterReturnType: All
AlwaysBreakAfterReturnType: TopLevelDefinitions
Cpp11BracedListStyle: false
ColumnLimit: 80
AlignAfterOpenBracket: Align
AlignConsecutiveDeclarations: true
AlignConsecutiveDeclarations: false
AlignConsecutiveMacros: true
AlignTrailingComments: true
AllowAllArgumentsOnNextLine: true
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
AlignEscapedNewlines: Left
DerivePointerAlignment: false
PointerAlignment: Right
PointerBindsToType: false
IncludeBlocks: Regroup
IncludeCategories:
- Regex: '^<isc/'
......@@ -36,15 +51,11 @@ IncludeCategories:
- Regex: '".*"'
Priority: 9
KeepEmptyLinesAtTheStartOfBlocks: false
# Taken from git's rules
PenaltyBreakAssignment: 10
# PenaltyBreakBeforeFirstCallParameter: 30
MaxEmptyLinesToKeep: 1
PenaltyBreakAssignment: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
Standard: Cpp11
ContinuationIndentWidth: 8
......@@ -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