From 712142d271f5ea444571e3148835a685c947d924 Mon Sep 17 00:00:00 2001 From: Peter Fry Date: Mon, 19 Oct 2020 10:17:41 -0400 Subject: [PATCH 1/2] Use fallthrough attribute instead of comment as the comment no longer works in Clang 10. --- vendor/newrelic/axiom/util_hash.c | 4 ++-- vendor/newrelic/axiom/util_object.c | 4 ++-- vendor/newrelic/axiom/util_regex.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/vendor/newrelic/axiom/util_hash.c b/vendor/newrelic/axiom/util_hash.c index d32a5916..0c51b84d 100644 --- a/vendor/newrelic/axiom/util_hash.c +++ b/vendor/newrelic/axiom/util_hash.c @@ -189,10 +189,10 @@ uint32_t nr_mkhash(const char* str, int* len) { switch (str_len & 3) { case 3: k1 ^= tail[2] << 16; - /* FALLTHROUGH */ + __attribute__((fallthrough)); case 2: k1 ^= tail[1] << 8; - /* FALLTHROUGH */ + __attribute__((fallthrough)); case 1: k1 ^= tail[0]; diff --git a/vendor/newrelic/axiom/util_object.c b/vendor/newrelic/axiom/util_object.c index 881088dc..74c49ee1 100644 --- a/vendor/newrelic/axiom/util_object.c +++ b/vendor/newrelic/axiom/util_object.c @@ -1349,12 +1349,12 @@ static const char* parse_string(nrintobj_t* item, const char* str) { case 3: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; - /*FALLTHROUGH*/ + __attribute__((fallthrough)); case 2: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; - /*FALLTHROUGH*/ + __attribute__((fallthrough)); case 1: *--ptr2 = (uc | firstByteMark[len]); diff --git a/vendor/newrelic/axiom/util_regex.c b/vendor/newrelic/axiom/util_regex.c index 35d356e5..ab51ee52 100644 --- a/vendor/newrelic/axiom/util_regex.c +++ b/vendor/newrelic/axiom/util_regex.c @@ -328,7 +328,7 @@ void nr_regex_add_quoted_to_buffer(nrbuf_t* buf, case ':': case '-': nr_buffer_add(buf, NR_PSTR("\\")); - /* FALLTHROUGH */ + __attribute__((fallthrough)); default: nr_buffer_add(buf, &str[i], 1); From 75852032b5565e7a0c6aa59715c9e52028ce0a93 Mon Sep 17 00:00:00 2001 From: Peter Fry Date: Mon, 19 Oct 2020 11:30:01 -0400 Subject: [PATCH 2/2] Implement a fallthrough macro that should work on a variety of versions of clang and gcc. --- vendor/newrelic/axiom/nr_axiom.h | 15 +++++++++++++++ vendor/newrelic/axiom/util_hash.c | 4 ++-- vendor/newrelic/axiom/util_object.c | 4 ++-- vendor/newrelic/axiom/util_regex.c | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/vendor/newrelic/axiom/nr_axiom.h b/vendor/newrelic/axiom/nr_axiom.h index 79aa7ba5..f4f0753f 100644 --- a/vendor/newrelic/axiom/nr_axiom.h +++ b/vendor/newrelic/axiom/nr_axiom.h @@ -80,6 +80,21 @@ NRINLINE void* nr_remove_const(const void* ptr) { #endif /* } */ + +#if defined(__clang__) +#if __has_attribute(fallthrough) +#define FALLTHROUGH __attribute__((fallthrough)); +#else +#define FALLTHROUGH +#endif +#else +#if defined(__GNUC__) && __GNUC__ >= 7 +#define FALLTHROUGH __attribute__((fallthrough)); +#else +#define FALLTHROUGH +#endif /* __GNUC__ >= 7 */ +#endif + /* * The macro nr_clang_assert is redefined to assert iff we are compiling using * the clang static analyzer scan-build. scan-build is sensitive to diff --git a/vendor/newrelic/axiom/util_hash.c b/vendor/newrelic/axiom/util_hash.c index 0c51b84d..9831e6cd 100644 --- a/vendor/newrelic/axiom/util_hash.c +++ b/vendor/newrelic/axiom/util_hash.c @@ -189,10 +189,10 @@ uint32_t nr_mkhash(const char* str, int* len) { switch (str_len & 3) { case 3: k1 ^= tail[2] << 16; - __attribute__((fallthrough)); + FALLTHROUGH /* FALLTHROUGH */ case 2: k1 ^= tail[1] << 8; - __attribute__((fallthrough)); + FALLTHROUGH /* FALLTHROUGH */ case 1: k1 ^= tail[0]; diff --git a/vendor/newrelic/axiom/util_object.c b/vendor/newrelic/axiom/util_object.c index 74c49ee1..ef5c1bb9 100644 --- a/vendor/newrelic/axiom/util_object.c +++ b/vendor/newrelic/axiom/util_object.c @@ -1349,12 +1349,12 @@ static const char* parse_string(nrintobj_t* item, const char* str) { case 3: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; - __attribute__((fallthrough)); + FALLTHROUGH /* FALLTHROUGH */ case 2: *--ptr2 = ((uc | 0x80) & 0xBF); uc >>= 6; - __attribute__((fallthrough)); + FALLTHROUGH /* FALLTHROUGH */ case 1: *--ptr2 = (uc | firstByteMark[len]); diff --git a/vendor/newrelic/axiom/util_regex.c b/vendor/newrelic/axiom/util_regex.c index ab51ee52..4064029e 100644 --- a/vendor/newrelic/axiom/util_regex.c +++ b/vendor/newrelic/axiom/util_regex.c @@ -328,7 +328,7 @@ void nr_regex_add_quoted_to_buffer(nrbuf_t* buf, case ':': case '-': nr_buffer_add(buf, NR_PSTR("\\")); - __attribute__((fallthrough)); + FALLTHROUGH /* FALLTHROUGH */ default: nr_buffer_add(buf, &str[i], 1);