From d97cebf4a71c3a83ef7545fc5927fe9625207daa Mon Sep 17 00:00:00 2001 From: Victor Seva Date: Wed, 17 May 2023 16:36:05 +0200 Subject: [PATCH] dnssec: clang-format for coherent indentation and coding style --- src/modules/dnssec/dnssec_func.c | 127 ++++++++++++++++--------------- src/modules/dnssec/dnssec_func.h | 26 +++---- src/modules/dnssec/dnssec_mod.c | 42 +++++----- 3 files changed, 96 insertions(+), 99 deletions(-) diff --git a/src/modules/dnssec/dnssec_func.c b/src/modules/dnssec/dnssec_func.c index 5918add4371..1f8d88a458f 100644 --- a/src/modules/dnssec/dnssec_func.c +++ b/src/modules/dnssec/dnssec_func.c @@ -37,16 +37,16 @@ #include "../../core/dprint.h" #include "dnssec_func.h" -static struct libval_context *libval_ctx = NULL; +static struct libval_context *libval_ctx = NULL; static unsigned int context_flags = 0; -unsigned int -set_context_flags(unsigned int flags) { -#define CHECK_AND_SET(flag) \ - if ((flag & flags) != 0) {\ - context_flags |= VAL_##flag;\ - LOG(L_INFO, "setting param %s\n", #flag);\ +unsigned int set_context_flags(unsigned int flags) +{ +#define CHECK_AND_SET(flag) \ + if((flag & flags) != 0) { \ + context_flags |= VAL_##flag; \ + LOG(L_INFO, "setting param %s\n", #flag); \ } unsigned int old_flags = context_flags; context_flags = 0; @@ -57,70 +57,70 @@ set_context_flags(unsigned int flags) { CHECK_AND_SET(QUERY_NO_DLV); CHECK_AND_SET(QUERY_NO_EDNS0_FALLBACK); CHECK_AND_SET(QUERY_RECURSE); - CHECK_AND_SET(QUERY_SKIP_RESOLVER); - CHECK_AND_SET(QUERY_SKIP_CACHE); + CHECK_AND_SET(QUERY_SKIP_RESOLVER); + CHECK_AND_SET(QUERY_SKIP_CACHE); return old_flags; } -static inline int -dnssec_init_context(void) { - if (libval_ctx == NULL) { - if (val_create_context(NULL, &libval_ctx) != VAL_NO_ERROR) - return -1; - if (context_flags != 0) { - val_context_setqflags(libval_ctx, VAL_CTX_FLAG_SET, context_flags); +static inline int dnssec_init_context(void) +{ + if(libval_ctx == NULL) { + if(val_create_context(NULL, &libval_ctx) != VAL_NO_ERROR) + return -1; + if(context_flags != 0) { + val_context_setqflags(libval_ctx, VAL_CTX_FLAG_SET, context_flags); } - } - return 0; + } + return 0; } -struct hostent * -dnssec_gethostbyname(const char *name) { - val_status_t val_status; - struct hostent * res; +struct hostent *dnssec_gethostbyname(const char *name) +{ + val_status_t val_status; + struct hostent *res; - if (dnssec_init_context()) - return NULL; + if(dnssec_init_context()) + return NULL; - LOG(L_INFO, " gethostbyname(%s) called: wrapper\n", name); + LOG(L_INFO, " gethostbyname(%s) called: wrapper\n", name); - res = val_gethostbyname(libval_ctx, name, &val_status); + res = val_gethostbyname(libval_ctx, name, &val_status); - if (val_istrusted(val_status) && !val_does_not_exist(val_status)) { - return res; - } - return NULL; + if(val_istrusted(val_status) && !val_does_not_exist(val_status)) { + return res; + } + return NULL; } -struct hostent * -dnssec_gethostbyname2(const char *name, int family) { - val_status_t val_status; - struct hostent * res; +struct hostent *dnssec_gethostbyname2(const char *name, int family) +{ + val_status_t val_status; + struct hostent *res; - if (dnssec_init_context()) - return NULL; + if(dnssec_init_context()) + return NULL; - LOG(L_INFO, " gethostbyname2(%s) called: wrapper\n", name); + LOG(L_INFO, " gethostbyname2(%s) called: wrapper\n", name); - res = val_gethostbyname2(libval_ctx, name, family, &val_status); + res = val_gethostbyname2(libval_ctx, name, family, &val_status); - if (val_istrusted(val_status) && !val_does_not_exist(val_status)) { - return res; - } - return NULL; + if(val_istrusted(val_status) && !val_does_not_exist(val_status)) { + return res; + } + return NULL; } -int -dnssec_res_init(void) { - LOG(L_INFO, "res_init called: wrapper\n"); +int dnssec_res_init(void) +{ + LOG(L_INFO, "res_init called: wrapper\n"); - return dnssec_init_context(); + return dnssec_init_context(); } -int -dnssec_res_destroy(void) { +int dnssec_res_destroy(void) +{ LOG(L_INFO, "destroying dnssec context\n"); val_free_context(libval_ctx); libval_ctx = NULL; @@ -128,28 +128,29 @@ dnssec_res_destroy(void) { } -int -dnssec_res_search(const char *dname, int class_h, int type_h, - unsigned char *answer, int anslen) { - val_status_t val_status; - int ret; +int dnssec_res_search(const char *dname, int class_h, int type_h, + unsigned char *answer, int anslen) +{ + val_status_t val_status; + int ret; - if (dnssec_init_context()) - return -1; + if(dnssec_init_context()) + return -1; - LOG(L_INFO, "res_query(%s,%d,%d) called: wrapper\n", - dname, class_h, type_h); + LOG(L_INFO, "res_query(%s,%d,%d) called: wrapper\n", dname, class_h, + type_h); - ret = val_res_search(libval_ctx, dname, class_h, type_h, answer, anslen, - &val_status); + ret = val_res_search( + libval_ctx, dname, class_h, type_h, answer, anslen, &val_status); - if (val_istrusted(val_status) && !val_does_not_exist(val_status)) { + if(val_istrusted(val_status) && !val_does_not_exist(val_status)) { return ret; - } else { - LOG(L_INFO, "invalid domain %s reason %s\n", dname, p_val_status(val_status)); + } else { + LOG(L_INFO, "invalid domain %s reason %s\n", dname, + p_val_status(val_status)); } - return -1; + return -1; } /*! @} */ diff --git a/src/modules/dnssec/dnssec_func.h b/src/modules/dnssec/dnssec_func.h index 2859280c515..224c7302288 100644 --- a/src/modules/dnssec/dnssec_func.h +++ b/src/modules/dnssec/dnssec_func.h @@ -31,24 +31,24 @@ struct hostent; -typedef enum { - QUERY_DONT_VALIDATE = 1<<0, - QUERY_IGNORE_SKEW = 1<<1, - QUERY_AC_DETAIL = 1<<2, - QUERY_NO_DLV = 1<<3, - QUERY_NO_EDNS0_FALLBACK = 1<<4, - QUERY_RECURSE = 1<<5, - QUERY_SKIP_RESOLVER = 1<<6, - QUERY_SKIP_CACHE = 1<<7 +typedef enum +{ + QUERY_DONT_VALIDATE = 1 << 0, + QUERY_IGNORE_SKEW = 1 << 1, + QUERY_AC_DETAIL = 1 << 2, + QUERY_NO_DLV = 1 << 3, + QUERY_NO_EDNS0_FALLBACK = 1 << 4, + QUERY_RECURSE = 1 << 5, + QUERY_SKIP_RESOLVER = 1 << 6, + QUERY_SKIP_CACHE = 1 << 7 } query_flags_t; int dnssec_res_init(void); int dnssec_res_destroy(void); unsigned int set_context_flags(unsigned int flags); -struct hostent* dnssec_gethostbyname(const char *); -struct hostent* dnssec_gethostbyname2(const char *, int); -int dnssec_res_search(const char*, int, int, unsigned char*, int); +struct hostent *dnssec_gethostbyname(const char *); +struct hostent *dnssec_gethostbyname2(const char *, int); +int dnssec_res_search(const char *, int, int, unsigned char *, int); #endif // DNSSEC_FUNC_H - diff --git a/src/modules/dnssec/dnssec_mod.c b/src/modules/dnssec/dnssec_mod.c index 830b409e3a4..1f70dd90665 100644 --- a/src/modules/dnssec/dnssec_mod.c +++ b/src/modules/dnssec/dnssec_mod.c @@ -49,37 +49,35 @@ static int dnssec_exit(void); /* parameters */ -static unsigned int flags=0; +static unsigned int flags = 0; /* global variables */ -gen_lock_t* timer_lock=0; -struct list_link* timer = 0; +gen_lock_t *timer_lock = 0; +struct list_link *timer = 0; -static param_export_t params[]={ - {"general_query_flags", INT_PARAM, &flags}, - {0,0,0} -}; +static param_export_t params[] = { + {"general_query_flags", INT_PARAM, &flags}, {0, 0, 0}}; -struct module_exports exports= { - "dnssec", /* module name */ - DEFAULT_DLFLAGS, /* dlopen flags */ - 0, /* exported functions */ - params, /* exported parameters */ - 0, /* RPC method exports */ - 0, /* exported pseudo-variables */ - 0, /* response handling function */ - dnssec_init, /* module initialization function */ - 0, /* per-child init function */ - dnssec_exit /* module destroy function */ +struct module_exports exports = { + "dnssec", /* module name */ + DEFAULT_DLFLAGS, /* dlopen flags */ + 0, /* exported functions */ + params, /* exported parameters */ + 0, /* RPC method exports */ + 0, /* exported pseudo-variables */ + 0, /* response handling function */ + dnssec_init, /* module initialization function */ + 0, /* per-child init function */ + dnssec_exit /* module destroy function */ }; static int load_dns(void) { struct dns_func_t *f = pkg_malloc(sizeof(struct dns_func_t)); - if( NULL == f ) { + if(NULL == f) { return -1; } memset(f, 0, sizeof(struct dns_func_t)); @@ -97,7 +95,8 @@ static int dnssec_init(void) LOG(L_INFO, "DNSSEC - initializing\n"); //set parameters - if(flags) set_context_flags(flags); + if(flags) + set_context_flags(flags); if(load_dns() != 0) { LM_ERR("loaded dnssec wrappers failed\n"); @@ -107,11 +106,8 @@ static int dnssec_init(void) } - static int dnssec_exit(void) { (void)dnssec_res_destroy(); return 0; } - -