From 26b6ce9a569105df86911160ca9cb686b230c49a Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 17 May 2024 12:29:59 +1000 Subject: [PATCH 1/2] Clang-format header file changes --- lib/dns/include/dns/name.h | 42 +++++++++++++++++++-------------- lib/dns/include/dns/rdataset.h | 9 ++++--- lib/isc/include/isc/list.h | 7 +++--- lib/isc/net.c | 12 ++++------ lib/isc/netmgr/http.c | 23 +++++++----------- tests/dns/rdata_test.c | 43 ++++++++-------------------------- tests/dns/sigs_test.c | 5 +--- tests/include/tests/dns.h | 5 +--- tests/include/tests/ns.h | 5 +--- 9 files changed, 58 insertions(+), 93 deletions(-) diff --git a/lib/dns/include/dns/name.h b/lib/dns/include/dns/name.h index 199856aae7..e20aa2cc2c 100644 --- a/lib/dns/include/dns/name.h +++ b/lib/dns/include/dns/name.h @@ -168,25 +168,33 @@ extern const dns_name_t *dns_wildcardname; * unsigned char offsets[] = { 0, 6 }; * dns_name_t value = DNS_NAME_INITABSOLUTE(data, offsets); */ -#define DNS_NAME_INITNONABSOLUTE(A, B) \ - { \ - DNS_NAME_MAGIC, A, (sizeof(A) - 1), sizeof(B), \ - DNS_NAMEATTR_READONLY, B, NULL, \ - { (void *)-1, (void *)-1 }, { NULL, NULL }, NULL \ - } +#define DNS_NAME_INITNONABSOLUTE(A, B) \ + { DNS_NAME_MAGIC, \ + A, \ + (sizeof(A) - 1), \ + sizeof(B), \ + DNS_NAMEATTR_READONLY, \ + B, \ + NULL, \ + { (void *)-1, (void *)-1 }, \ + { NULL, NULL }, \ + NULL } -#define DNS_NAME_INITABSOLUTE(A, B) \ - { \ - DNS_NAME_MAGIC, A, sizeof(A), sizeof(B), \ - DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, B, \ - NULL, { (void *)-1, (void *)-1 }, { NULL, NULL }, NULL \ - } +#define DNS_NAME_INITABSOLUTE(A, B) \ + { DNS_NAME_MAGIC, \ + A, \ + sizeof(A), \ + sizeof(B), \ + DNS_NAMEATTR_READONLY | DNS_NAMEATTR_ABSOLUTE, \ + B, \ + NULL, \ + { (void *)-1, (void *)-1 }, \ + { NULL, NULL }, \ + NULL } -#define DNS_NAME_INITEMPTY \ - { \ - DNS_NAME_MAGIC, NULL, 0, 0, 0, NULL, NULL, \ - { (void *)-1, (void *)-1 }, { NULL, NULL }, NULL \ - } +#define DNS_NAME_INITEMPTY \ + { DNS_NAME_MAGIC, NULL, 0, 0, 0, NULL, NULL, { (void *)-1, (void *)-1 }, \ + { NULL, NULL }, NULL } /*% * Standard size of a wire format name diff --git a/lib/dns/include/dns/rdataset.h b/lib/dns/include/dns/rdataset.h index 566ea44cf9..f63591c5c7 100644 --- a/lib/dns/include/dns/rdataset.h +++ b/lib/dns/include/dns/rdataset.h @@ -148,11 +148,10 @@ struct dns_rdataset { #define DNS_RDATASET_COUNT_UNDEFINED UINT32_MAX -#define DNS_RDATASET_INIT \ - { \ - .magic = DNS_RDATASET_MAGIC, .link = ISC_LINK_INITIALIZER, \ - .count = DNS_RDATASET_COUNT_UNDEFINED \ - } +#define DNS_RDATASET_INIT \ + { .magic = DNS_RDATASET_MAGIC, \ + .link = ISC_LINK_INITIALIZER, \ + .count = DNS_RDATASET_COUNT_UNDEFINED } /*! * \def DNS_RDATASETATTR_RENDERED diff --git a/lib/isc/include/isc/list.h b/lib/isc/include/isc/list.h index 2cf4437542..81f561e79c 100644 --- a/lib/isc/include/isc/list.h +++ b/lib/isc/include/isc/list.h @@ -17,9 +17,10 @@ #define ISC_LINK_TOMBSTONE(type) ((type *)-1) -#define ISC_LIST_INITIALIZER \ - { \ - .head = NULL, .tail = NULL, \ +#define ISC_LIST_INITIALIZER \ + { \ + .head = NULL, \ + .tail = NULL, \ } #define ISC_LINK_INITIALIZER_TYPE(type) \ { \ diff --git a/lib/isc/net.c b/lib/isc/net.c index e32a543e2d..ca46f80397 100644 --- a/lib/isc/net.c +++ b/lib/isc/net.c @@ -80,14 +80,10 @@ #ifdef __OpenBSD__ #define USE_SYSCTL_PORTRANGE -#define SYSCTL_V4PORTRANGE_LOW \ - { \ - CTL_NET, PF_INET, IPPROTO_IP, IPCTL_IPPORT_HIFIRSTAUTO \ - } -#define SYSCTL_V4PORTRANGE_HIGH \ - { \ - CTL_NET, PF_INET, IPPROTO_IP, IPCTL_IPPORT_HILASTAUTO \ - } +#define SYSCTL_V4PORTRANGE_LOW \ + { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_IPPORT_HIFIRSTAUTO } +#define SYSCTL_V4PORTRANGE_HIGH \ + { CTL_NET, PF_INET, IPPROTO_IP, IPCTL_IPPORT_HILASTAUTO } /* Same for IPv6 */ #define SYSCTL_V6PORTRANGE_LOW SYSCTL_V4PORTRANGE_LOW #define SYSCTL_V6PORTRANGE_HIGH SYSCTL_V4PORTRANGE_HIGH diff --git a/lib/isc/netmgr/http.c b/lib/isc/netmgr/http.c index 2220edf364..eaa90c7094 100644 --- a/lib/isc/netmgr/http.c +++ b/lib/isc/netmgr/http.c @@ -847,18 +847,13 @@ send_client_connection_header(isc_nm_http_session_t *session) { return (true); } -#define MAKE_NV(NAME, VALUE, VALUELEN) \ - { \ - (uint8_t *)(uintptr_t)(NAME), (uint8_t *)(uintptr_t)(VALUE), \ - sizeof(NAME) - 1, VALUELEN, NGHTTP2_NV_FLAG_NONE \ - } +#define MAKE_NV(NAME, VALUE, VALUELEN) \ + { (uint8_t *)(uintptr_t)(NAME), (uint8_t *)(uintptr_t)(VALUE), \ + sizeof(NAME) - 1, VALUELEN, NGHTTP2_NV_FLAG_NONE } -#define MAKE_NV2(NAME, VALUE) \ - { \ - (uint8_t *)(uintptr_t)(NAME), (uint8_t *)(uintptr_t)(VALUE), \ - sizeof(NAME) - 1, sizeof(VALUE) - 1, \ - NGHTTP2_NV_FLAG_NONE \ - } +#define MAKE_NV2(NAME, VALUE) \ + { (uint8_t *)(uintptr_t)(NAME), (uint8_t *)(uintptr_t)(VALUE), \ + sizeof(NAME) - 1, sizeof(VALUE) - 1, NGHTTP2_NV_FLAG_NONE } static ssize_t client_read_callback(nghttp2_session *ngsession, int32_t stream_id, @@ -1951,10 +1946,8 @@ server_send_response(nghttp2_session *ngsession, int32_t stream_id, return (ISC_R_SUCCESS); } -#define MAKE_ERROR_REPLY(tag, code, desc) \ - { \ - tag, MAKE_NV2(":status", #code), desc \ - } +#define MAKE_ERROR_REPLY(tag, code, desc) \ + { tag, MAKE_NV2(":status", #code), desc } /* * Here we use roughly the same error codes that Unbound uses. diff --git a/tests/dns/rdata_test.c b/tests/dns/rdata_test.c index d79b072e14..0a9ec1c00a 100644 --- a/tests/dns/rdata_test.c +++ b/tests/dns/rdata_test.c @@ -79,42 +79,19 @@ typedef struct wire_ok { unsigned int loop; } wire_ok_t; -#define COMPARE(r1, r2, answer) \ - { \ - r1, r2, answer, __LINE__ \ - } -#define COMPARE_SENTINEL() \ - { \ - NULL, NULL, 0, __LINE__ \ - } +#define COMPARE(r1, r2, answer) { r1, r2, answer, __LINE__ } +#define COMPARE_SENTINEL() { NULL, NULL, 0, __LINE__ } -#define TEXT_VALID_CHANGED(data_in, data_out) \ - { \ - data_in, data_out, 0 \ - } -#define TEXT_VALID(data) \ - { \ - data, data, 0 \ - } -#define TEXT_VALID_LOOP(loop, data) \ - { \ - data, data, loop \ - } -#define TEXT_VALID_LOOPCHG(loop, data_in, data_out) \ - { \ - data_in, data_out, loop \ - } -#define TEXT_INVALID(data) \ - { \ - data, NULL, 0 \ - } -#define TEXT_SENTINEL() TEXT_INVALID(NULL) +#define TEXT_VALID_CHANGED(data_in, data_out) { data_in, data_out, 0 } +#define TEXT_VALID(data) { data, data, 0 } +#define TEXT_VALID_LOOP(loop, data) { data, data, loop } +#define TEXT_VALID_LOOPCHG(loop, data_in, data_out) { data_in, data_out, loop } +#define TEXT_INVALID(data) { data, NULL, 0 } +#define TEXT_SENTINEL() TEXT_INVALID(NULL) #define VARGC(...) (sizeof((unsigned char[]){ __VA_ARGS__ })) -#define WIRE_TEST(ok, loop, ...) \ - { \ - { __VA_ARGS__ }, VARGC(__VA_ARGS__), ok, loop \ - } +#define WIRE_TEST(ok, loop, ...) \ + { { __VA_ARGS__ }, VARGC(__VA_ARGS__), ok, loop } #define WIRE_VALID(...) WIRE_TEST(true, 0, __VA_ARGS__) #define WIRE_VALID_LOOP(loop, ...) WIRE_TEST(true, loop, __VA_ARGS__) /* diff --git a/tests/dns/sigs_test.c b/tests/dns/sigs_test.c index 881c900628..e053f5bbd6 100644 --- a/tests/dns/sigs_test.c +++ b/tests/dns/sigs_test.c @@ -59,10 +59,7 @@ typedef struct { const char *type; } zonediff_t; -#define ZONEDIFF_SENTINEL \ - { \ - 0, NULL, 0, NULL \ - } +#define ZONEDIFF_SENTINEL { 0, NULL, 0, NULL } /*% * Structure defining a dns__zone_updatesigs() test. diff --git a/tests/include/tests/dns.h b/tests/include/tests/dns.h index 64a265b660..40d6a7e938 100644 --- a/tests/include/tests/dns.h +++ b/tests/include/tests/dns.h @@ -44,10 +44,7 @@ typedef struct { const char *rdata; } zonechange_t; -#define ZONECHANGE_SENTINEL \ - { \ - 0, NULL, 0, NULL, NULL \ - } +#define ZONECHANGE_SENTINEL { 0, NULL, 0, NULL, NULL } isc_result_t dns_test_makeview(const char *name, bool with_cache, dns_view_t **viewp); diff --git a/tests/include/tests/ns.h b/tests/include/tests/ns.h index 175cb90975..58331cf551 100644 --- a/tests/include/tests/ns.h +++ b/tests/include/tests/ns.h @@ -41,10 +41,7 @@ typedef struct ns_test_id { int lineno; } ns_test_id_t; -#define NS_TEST_ID(desc) \ - { \ - .description = desc, .lineno = __LINE__ \ - } +#define NS_TEST_ID(desc) { .description = desc, .lineno = __LINE__ } #define CHECK(r) \ do { \ From a3cdf22b602d4ca8b084e0ba69ca0444ab22dfb7 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Fri, 17 May 2024 13:32:10 +1000 Subject: [PATCH 2/2] Ignore reformat sources with up-to-date clang-format-18 --- .git-blame-ignore-revs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-blame-ignore-revs b/.git-blame-ignore-revs index 1d950838e7..8abc610dc4 100644 --- a/.git-blame-ignore-revs +++ b/.git-blame-ignore-revs @@ -20,3 +20,5 @@ e577b1eca70856b816ffa36199f14078e4b76b58 b8b9b4ac2c0ae88de85f4d83982edb97694959d7 # Reformat sources with up-to-date clang-format-17 6a85e79c0b349003449f9c9a64eba74a97653826 +# Reformat sources with up-to-date clang-format-18 +26b6ce9a569105df86911160ca9cb686b230c49a