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

Merge branch '46-enforce-clang-format-rules' into 'master'

Start enforcing the clang-format rules on changed files

Closes #46

See merge request !3063
parents d3b49b66 60d29f69
Pipeline #34087 passed with stages
in 45 minutes and 25 seconds
......@@ -15,7 +15,7 @@ BraceWrapping:
SplitEmptyFunction: true
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
AlwaysBreakAfterReturnType: TopLevelDefinitions
AlwaysBreakAfterReturnType: All
Cpp11BracedListStyle: false
ColumnLimit: 80
AlignAfterOpenBracket: Align
......
BasedOnStyle: LLVM
IndentWidth: 8
UseTab: Always
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
Cpp11BracedListStyle: false
ColumnLimit: 80
AlignAfterOpenBracket: Align
AlignConsecutiveDeclarations: true
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/'
Priority: 2
- Regex: '^<dns/'
Priority: 3
- Regex: '^<iscccc/'
Priority: 4
- Regex: '^<isccfg/'
Priority: 5
- Regex: '^<ns/'
Priority: 6
- Regex: '^<bind9/)'
Priority: 7
- Regex: '^(<[^/]*)/)'
Priority: 8
- Regex: '<[[:alnum:].]+>'
Priority: 1
- Regex: '".*"'
Priority: 9
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
PenaltyBreakAssignment: 30
PenaltyBreakComment: 10
PenaltyBreakFirstLessLess: 0
PenaltyBreakString: 10
PenaltyExcessCharacter: 100
Standard: Cpp11
ContinuationIndentWidth: 8
......@@ -17,9 +17,11 @@ variables:
MAKE: make
CONFIGURE: ./configure
CLANG: clang-9
SCAN_BUILD: scan-build-9
SYMBOLIZER: /usr/lib/llvm-9/bin/llvm-symbolizer
ASAN_SYMBOLIZER_PATH: "$SYMBOLIZER"
CLANG_FORMAT: clang-format-11
CFLAGS_COMMON: -fno-omit-frame-pointer -fno-optimize-sibling-calls -O1 -g -Wall -Wextra
......@@ -384,6 +386,12 @@ misc:sid:amd64:
expire_in: "1 day"
when: on_failure
💾:sid:amd64:
<<: *precheck_job
script:
- if [ -r .clang-format ]; then "${CLANG_FORMAT}" -i -style=file $(git ls-files '*.c' '*.h'); fi
- if test "$(git status --porcelain | grep -Ev '\?\?' | wc -l)" -gt "0"; then git status --short; exit 1; fi
🐞:sid:amd64:
<<: *precheck_job
<<: *debian_buster_amd64_image
......@@ -618,7 +626,7 @@ scan-build:buster:amd64:
<<: *debian_buster_amd64_image
stage: postcheck
variables:
CC: clang-9
CC: "${CLANG}"
CFLAGS: "${CFLAGS_COMMON}"
CONFIGURE: "${SCAN_BUILD} ./configure"
EXTRA_CONFIGURE: "--enable-dnstap --with-libidn2"
......@@ -878,7 +886,7 @@ tsan:buster:amd64:
<<: *debian_buster_amd64_image
<<: *build_job
variables:
CC: clang-9
CC: "${CLANG}"
CFLAGS: "${CFLAGS_COMMON} -fsanitize=thread -DISC_MEM_USE_INTERNAL_MALLOC=0"
LDFLAGS: "-fsanitize=thread"
EXTRA_CONFIGURE: "--with-libidn2 --enable-pthread-rwlock"
......
......@@ -47,12 +47,12 @@ void
DestroySockets(void);
#endif /* ifdef _WIN32 */
extern int debug;
extern const char * journal;
extern bool nomerge;
extern bool docheckmx;
extern bool docheckns;
extern bool dochecksrv;
extern int debug;
extern const char *journal;
extern bool nomerge;
extern bool docheckmx;
extern bool docheckns;
extern bool dochecksrv;
extern dns_zoneopt_t zone_options;
ISC_LANG_ENDDECLS
......
......@@ -56,7 +56,8 @@ 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) {
......
......@@ -62,7 +62,8 @@ static enum { progmode_check, progmode_compile } progmode;
} \
} while (0)
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) {
......
../../../.clang-format.headers
\ No newline at end of file
......@@ -127,11 +127,11 @@ static char anchortext[] = TRUST_ANCHORS;
/*
* Static function prototypes
*/
static isc_result_t get_reverse(char *reverse, size_t len, char *value,
bool strict);
static isc_result_t
get_reverse(char *reverse, size_t len, char *value, bool strict);
static isc_result_t parse_uint(uint32_t *uip, const char *value, uint32_t max,
const char *desc);
static isc_result_t
parse_uint(uint32_t *uip, const char *value, uint32_t max, const char *desc);
static void
usage(void) {
......@@ -205,7 +205,8 @@ usage(void) {
exit(1);
}
ISC_PLATFORM_NORETURN_PRE static void fatal(const char *format, ...)
ISC_PLATFORM_NORETURN_PRE static void
fatal(const char *format, ...)
ISC_FORMAT_PRINTF(1, 2) ISC_PLATFORM_NORETURN_POST;
static void
......@@ -221,7 +222,8 @@ fatal(const char *format, ...) {
exit(1);
}
static void warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
static void
warn(const char *format, ...) ISC_FORMAT_PRINTF(1, 2);
static void
warn(const char *format, ...) {
......@@ -241,7 +243,8 @@ static isc_logcategory_t categories[] = { { "delv", 0 }, { NULL, 0 } };
static isc_logmodule_t modules[] = { { "delv", 0 }, { NULL, 0 } };
static void delv_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
static void
delv_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3);
static void
delv_log(int level, const char *fmt, ...) {
......
......@@ -107,7 +107,8 @@ usage(void) {
fprintf(stderr, "Press <Help> for complete list of options\n");
}
#else /* if TARGET_OS_IPHONE */
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) {
......
......@@ -122,10 +122,12 @@ int lookup_counter = 0;
static char servercookie[256];
#ifdef HAVE_LIBIDN2
static void idn_locale_to_ace(const char *src, char *dst, size_t dstlen);
static void idn_ace_to_locale(const char *src, char **dst);
static isc_result_t idn_output_filter(isc_buffer_t *buffer,
unsigned int used_org);
static void
idn_locale_to_ace(const char *src, char *dst, size_t dstlen);
static void
idn_ace_to_locale(const char *src, char **dst);
static isc_result_t
idn_output_filter(isc_buffer_t *buffer, unsigned int used_org);
#endif /* HAVE_LIBIDN2 */
isc_socket_t *keep = NULL;
......@@ -227,19 +229,26 @@ void (*dighost_shutdown)(void);
/* forward declarations */
static void cancel_lookup(dig_lookup_t *lookup);
static void
cancel_lookup(dig_lookup_t *lookup);
static void recv_done(isc_task_t *task, isc_event_t *event);
static void
recv_done(isc_task_t *task, isc_event_t *event);
static void send_udp(dig_query_t *query);
static void
send_udp(dig_query_t *query);
static void connect_timeout(isc_task_t *task, isc_event_t *event);
static void
connect_timeout(isc_task_t *task, isc_event_t *event);
static void launch_next_query(dig_query_t *query, bool include_question);
static void
launch_next_query(dig_query_t *query, bool include_question);
static void check_next_lookup(dig_lookup_t *lookup);
static void
check_next_lookup(dig_lookup_t *lookup);
static bool next_origin(dig_lookup_t *oldlookup);
static bool
next_origin(dig_lookup_t *oldlookup);
static int
count_dots(char *string) {
......@@ -2718,7 +2727,8 @@ force_timeout(dig_query_t *query) {
}
}
static void connect_done(isc_task_t *task, isc_event_t *event);
static void
connect_done(isc_task_t *task, isc_event_t *event);
/*%
* Unlike send_udp, this can't be called multiple times with the same
......
../../../.clang-format.headers
\ No newline at end of file
......@@ -124,8 +124,10 @@ static const char *rtypetext[] = {
#define N_KNOWN_RRTYPES (sizeof(rtypetext) / sizeof(rtypetext[0]))
static void flush_lookup_list(void);
static void getinput(isc_task_t *task, isc_event_t *event);
static void
flush_lookup_list(void);
static void
getinput(isc_task_t *task, isc_event_t *event);
static char *
rcode_totext(dns_rcode_t rcode) {
......@@ -876,7 +878,8 @@ get_next_command(void) {
isc_mem_free(mctx, buf);
}
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) {
......
......@@ -121,8 +121,8 @@ typedef struct keyinfo {
} keyinfo_t;
/* A replaceable function that can generate a DS RRset from some input */
typedef isc_result_t ds_maker_func_t(dns_rdatalist_t *dslist, isc_buffer_t *buf,
dns_rdata_t *rdata);
typedef isc_result_t
ds_maker_func_t(dns_rdatalist_t *dslist, isc_buffer_t *buf, dns_rdata_t *rdata);
static dns_rdataset_t cdnskey_set, cdnskey_sig;
static dns_rdataset_t cds_set, cds_sig;
......@@ -1016,7 +1016,8 @@ nsdiff(uint32_t ttl, dns_rdataset_t *oldset, dns_rdataset_t *newset) {
}
}
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) {
......
......@@ -320,7 +320,8 @@ emits(bool showall, bool cds, dns_rdata_t *rdata) {
}
}
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) {
......
......@@ -264,7 +264,8 @@ emit(const char *dir, dns_rdata_t *rdata) {
dst_key_free(&key);
}
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) {
......
......@@ -46,7 +46,8 @@
const char *program = "dnssec-keyfromlabel";
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) {
......
......@@ -69,9 +69,11 @@ const char *program = "dnssec-keygen";
isc_log_t *lctx = NULL;
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 progress(int p);
static void
progress(int p);
struct keygen_ctx {
const char *predecessor;
......
......@@ -40,7 +40,8 @@ const char *program = "dnssec-revoke";
static isc_mem_t *mctx = NULL;
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) {
......
......@@ -43,7 +43,8 @@ const char *program = "dnssec-settime";
static isc_mem_t *mctx = NULL;
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) {
......
......@@ -186,7 +186,8 @@ static dns_ttl_t maxttl = 0;
UNLOCK(&statslock); \
}
static void sign(isc_task_t *task, isc_event_t *event);
static void
sign(isc_task_t *task, isc_event_t *event);
/*%
* Store a copy of 'name' in 'fzonecut' and return a pointer to that copy.
......@@ -3123,7 +3124,8 @@ print_version(FILE *fp) {
fprintf(fp, "; dnssec_signzone version " VERSION "\n");
}
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) {
......
......@@ -137,7 +137,8 @@ loadzone(char *file, char *origin, dns_rdataclass_t rdclass, dns_db_t **db) {
}
}
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) {
......
......@@ -25,7 +25,7 @@
/*! verbosity: set by -v and -q option in each program, defined in dnssectool.c
*/
extern int verbose;
extern int verbose;
extern bool quiet;
/*! program name, statically initialized in each program */
......
......@@ -32,12 +32,18 @@
typedef struct builtin builtin_t;
static isc_result_t do_version_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_hostname_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_authors_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_id_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_empty_lookup(dns_sdblookup_t *lookup);
static isc_result_t do_dns64_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_version_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_hostname_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_authors_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_id_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_empty_lookup(dns_sdblookup_t *lookup);
static isc_result_t
do_dns64_lookup(dns_sdblookup_t *lookup);
/*
* We can't use function pointers as the db_data directly
......
......@@ -107,8 +107,10 @@ struct named_controls {
isccc_symtab_t *symtab;
};
static void control_newconn(isc_task_t *task, isc_event_t *event);
static void control_recvmessage(isc_task_t *task, isc_event_t *event);
static void
control_newconn(isc_task_t *task, isc_event_t *event);
static void
control_recvmessage(isc_task_t *task, isc_event_t *event);
#define CLOCKSKEW 300
......
../../../.clang-format.headers
\ No newline at end of file
......@@ -302,9 +302,9 @@ library_fatal_error(const char *file, int line, const char *format,
exit(1);
}
static void library_unexpected_error(const char *file, int line,
const char *format, va_list args)
ISC_FORMAT_PRINTF(3, 0);
static void
library_unexpected_error(const char *file, int line, const char *format,
va_list args) ISC_FORMAT_PRINTF(3, 0);
static void
library_unexpected_error(const char *file, int line, const char *format,
......
......@@ -383,74 +383,86 @@ ISC_PLATFORM_NORETURN_PRE static void
fatal(named_server_t *server, const char *msg,
isc_result_t result) ISC_PLATFORM_NORETURN_POST;
static void named_server_reload(isc_task_t *task, isc_event_t *event);
static void
named_server_reload(isc_task_t *task, isc_event_t *event);
static isc_result_t ns_listenelt_fromconfig(const cfg_obj_t *listener,
const cfg_obj_t *config,
cfg_aclconfctx_t *actx,
isc_mem_t *mctx, uint16_t family,
ns_listenelt_t **target);
static isc_result_t ns_listenlist_fromconfig(const cfg_obj_t *listenlist,
const cfg_obj_t *config,
cfg_aclconfctx_t *actx,
isc_mem_t *mctx, uint16_t family,
ns_listenlist_t **target);
static isc_result_t
ns_listenelt_fromconfig(const cfg_obj_t *listener, const cfg_obj_t *config,
cfg_aclconfctx_t *actx, isc_mem_t *mctx,
uint16_t family, ns_listenelt_t **target);
static isc_result_t
ns_listenlist_fromconfig(const cfg_obj_t *listenlist, const cfg_obj_t *config,
cfg_aclconfctx_t *actx, isc_mem_t *mctx,
uint16_t family, ns_listenlist_t **target);
static isc_result_t configure_forward(const cfg_obj_t *config, dns_view_t *view,
const dns_name_t *origin,
const cfg_obj_t *forwarders,
const cfg_obj_t *forwardtype);
static isc_result_t
configure_forward(const cfg_obj_t *config, dns_view_t *view,
const dns_name_t *origin, const cfg_obj_t *forwarders,
const cfg_obj_t *forwardtype);
static isc_result_t configure_alternates(const cfg_obj_t *config,
dns_view_t *view,
const cfg_obj_t *alternates);
static isc_result_t
configure_alternates(const cfg_obj_t *config, dns_view_t *view,
const cfg_obj_t *alternates);
static isc_result_t configure_zone(const cfg_obj_t *config,
const cfg_obj_t *zconfig,
const cfg_obj_t *vconfig, isc_mem_t *mctx,
dns_view_t *view, dns_viewlist_t *viewlist,
dns_kasplist_t *kasplist,
cfg_aclconfctx_t *aclconf, bool added,
bool old_rpz_ok, bool modify);
static isc_result_t
configure_zone(const cfg_obj_t *config, const cfg_obj_t *zconfig,
const cfg_obj_t *vconfig, isc_mem_t *mctx, dns_view_t *view,
dns_viewlist_t *viewlist, dns_kasplist_t *kasplist,
cfg_aclconfctx_t *aclconf, bool added, bool old_rpz_ok,
bool modify);
static isc_result_t configure_newzones(dns_view_t *view, cfg_obj_t *config,
cfg_obj_t *vconfig, isc_mem_t *mctx,
cfg_aclconfctx_t *actx);
static isc_result_t
configure_newzones(dns_view_t *view, cfg_obj_t *config, cfg_obj_t *vconfig,
isc_mem_t *mctx, cfg_aclconfctx_t *actx);
static isc_result_t add_keydata_zone(dns_view_t *view, const char *directory,
isc_mem_t *mctx);
static isc_result_t
add_keydata_zone(dns_view_t *view, const char *directory, isc_mem_t *mctx);
static void end_reserved_dispatches(named_server_t *server, bool all);
static void
end_reserved_dispatches(named_server_t *server, bool all);
static void newzone_cfgctx_destroy(void **cfgp);
static void
newzone_cfgctx_destroy(void **cfgp);
static inline isc_result_t putstr(isc_buffer_t **b, const char *str);
static inline isc_result_t
putstr(isc_buffer_t **b, const char *str);
static isc_result_t putmem(isc_buffer_t **b, const char *str, size_t len);
static isc_result_t
putmem(isc_buffer_t **b, const char *str, size_t len);
static isc_result_t putuint8(isc_buffer_t **b, uint8_t val);
static isc_result_t
putuint8(isc_buffer_t **b, uint8_t val);
static inline isc_result_t putnull(isc_buffer_t **b);
static inline isc_result_t
putnull(isc_buffer_t **b);
static int count_zones(const cfg_obj_t *conf);
static int
count_zones(const cfg_obj_t *conf);
#ifdef HAVE_LMDB
static isc_result_t migrate_nzf(dns_view_t *view);
static isc_result_t
migrate_nzf(dns_view_t *view);
static isc_result_t nzd_writable(dns_view_t *view);
static isc_result_t
nzd_writable(dns_view_t *view);
static isc_result_t nzd_open(dns_view_t *view, unsigned int flags,