From c130b4e1aedfda8119b513ecaa82c7f7deda3228 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Wed, 29 May 2024 13:03:10 +0200 Subject: [PATCH 1/3] Lib: Use access() function attribute --- lib/birdlib.h | 10 ++++++++++ lib/ip.h | 2 +- lib/net.h | 4 ++-- lib/string.h | 6 +++--- nest/attrs.h | 8 ++++---- 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/lib/birdlib.h b/lib/birdlib.h index fac7e4ea..a520fdb3 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -78,6 +78,16 @@ static inline int u64_cmp(u64 i1, u64 i2) #define NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) +#if __GNUC_PREREQ(10, 0) +#define ACCESS_READ(...) __attribute__((access(read_only, __VA_ARGS__))) +#define ACCESS_WRITE(...) __attribute__((access(write_only, __VA_ARGS__))) +#define ACCESS_RW(...) __attribute__((access(read_write, __VA_ARGS__))) +#else +#define ACCESS_READ(...) +#define ACCESS_WRITE(...) +#define ACCESS_RW(...) +#endif + #define STATIC_ASSERT(EXP) _Static_assert(EXP, #EXP) #define STATIC_ASSERT_MSG(EXP,MSG) _Static_assert(EXP, MSG) diff --git a/lib/ip.h b/lib/ip.h index 0a25d5bc..f9aa7f66 100644 --- a/lib/ip.h +++ b/lib/ip.h @@ -398,7 +398,7 @@ typedef struct mpls_label_stack { u32 stack[MPLS_MAX_LABEL_STACK]; } mpls_label_stack; -static inline int +static inline int ACCESS_READ(1, 2) mpls_get(const char *buf, int buflen, u32 *stack) { for (int i=0; (i Date: Thu, 30 May 2024 02:11:06 +0200 Subject: [PATCH 2/3] Lib: Fix BSD build --- lib/birdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/birdlib.h b/lib/birdlib.h index a520fdb3..8852b609 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -78,7 +78,7 @@ static inline int u64_cmp(u64 i1, u64 i2) #define NONNULL(...) __attribute__((nonnull(__VA_ARGS__))) #define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) -#if __GNUC_PREREQ(10, 0) +#if __GNUC__ >= 10 #define ACCESS_READ(...) __attribute__((access(read_only, __VA_ARGS__))) #define ACCESS_WRITE(...) __attribute__((access(write_only, __VA_ARGS__))) #define ACCESS_RW(...) __attribute__((access(read_write, __VA_ARGS__))) From a5b4c21d8138bb533b02a60973b1ff4feedae456 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 30 May 2024 02:40:55 +0200 Subject: [PATCH 3/3] Filter: Silence some warnings in clang --- filter/decl.m4 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/filter/decl.m4 b/filter/decl.m4 index 57bf9454..ea0b0995 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -621,10 +621,19 @@ FID_WR_PUT(11) #pragma GCC diagnostic ignored "-Woverride-init" #endif +#if defined(__clang__) +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Winitializer-overrides" +#endif + static struct sym_scope f_type_method_scopes[] = { FID_WR_PUT(12) }; +#if defined(__clang__) +#pragma clang diagnostic pop +#endif + #if defined(__GNUC__) && __GNUC__ >= 6 #pragma GCC diagnostic pop #endif