diff --git a/filter/decl.m4 b/filter/decl.m4 index dcb24f8c..45afe474 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -622,12 +622,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 diff --git a/lib/attrs.h b/lib/attrs.h index 894705ef..c622fc0a 100644 --- a/lib/attrs.h +++ b/lib/attrs.h @@ -73,7 +73,7 @@ struct adata *as_path_prepend2(struct linpool *pool, const struct adata *op, int struct adata *as_path_to_old(struct linpool *pool, const struct adata *path); struct adata *as_path_cut(struct linpool *pool, const struct adata *path, uint num); const struct adata *as_path_merge(struct linpool *pool, const struct adata *p1, const struct adata *p2); -void as_path_format(const struct adata *path, byte *buf, uint size); +void as_path_format(const struct adata *path, byte *buf, uint size) ACCESS_WRITE(2, 3); int as_path_getlen(const struct adata *path); int as_path_getlen_int(const struct adata *path, int bs); int as_path_get_first(const struct adata *path, u32 *orig_as); @@ -244,11 +244,11 @@ enum isf_way { ISF_ROUTER_ID, }; -int int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size); +int int_set_format(const struct adata *set, enum isf_way way, int from, byte *buf, uint size) ACCESS_WRITE(4, 5); int ec_format(byte *buf, u64 ec); -int ec_set_format(const struct adata *set, int from, byte *buf, uint size); +int ec_set_format(const struct adata *set, int from, byte *buf, uint size) ACCESS_WRITE(3, 4); int lc_format(byte *buf, lcomm lc); -int lc_set_format(const struct adata *set, int from, byte *buf, uint size); +int lc_set_format(const struct adata *set, int from, byte *buf, uint size) ACCESS_WRITE(3, 4); int int_set_contains(const struct adata *list, u32 val); int ec_set_contains(const struct adata *list, u64 val); int lc_set_contains(const struct adata *list, lcomm val); diff --git a/lib/birdlib.h b/lib/birdlib.h index 5f1d3c3c..57149cc9 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -118,6 +118,16 @@ static inline int u64_cmp(u64 i1, u64 i2) #define ALLOC_SIZE(...) __attribute__((alloc_size(__VA_ARGS__))) #define CLEANUP(fun) __attribute__((cleanup(fun))) +#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__))) +#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