lib: prepare for plugin-based frr_format check

Signed-off-by: David Lamparter <equinox@diac24.net>
This commit is contained in:
David Lamparter 2019-08-02 17:42:06 +02:00
parent 47466c571f
commit 07ef3e34ae
8 changed files with 43 additions and 3 deletions

View file

@ -448,4 +448,8 @@ static inline const struct prefix *bgp_node_get_prefix(struct bgp_node *node)
return &node->p; return &node->p;
} }
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pRN" (struct bgp_node *)
#endif
#endif /* _QUAGGA_BGP_TABLE_H */ #endif /* _QUAGGA_BGP_TABLE_H */

View file

@ -161,6 +161,10 @@ agg_node_get_prefix(const struct agg_node *node)
return &node->p; return &node->p;
} }
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pRN" (struct agg_node *)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -305,7 +305,14 @@ extern "C" {
#include <inttypes.h> #include <inttypes.h>
#ifdef _FRR_ATTRIBUTE_PRINTFRR #ifdef _FRR_ATTRIBUTE_PRINTFRR
#define PRINTFRR(a, b) __attribute__((printfrr(a, b))) #define PRINTFRR(a, b) __attribute__((frr_format("frr_printf", a, b)))
#undef PRIu64
#undef PRId64
#undef PRIx64
#define PRIu64 "Lu"
#define PRId64 "Ld"
#define PRIx64 "Lx"
#else /* !_FRR_ATTRIBUTE_PRINTFRR */ #else /* !_FRR_ATTRIBUTE_PRINTFRR */
#define PRINTFRR(a, b) __attribute__((format(printf, a, b))) #define PRINTFRR(a, b) __attribute__((format(printf, a, b)))

View file

@ -201,6 +201,10 @@ extern struct nexthop *nexthop_dup(const struct nexthop *nexthop,
extern struct nexthop *nexthop_dup_no_recurse(const struct nexthop *nexthop, extern struct nexthop *nexthop_dup_no_recurse(const struct nexthop *nexthop,
struct nexthop *rparent); struct nexthop *rparent);
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pNH" (struct nexthop *)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -544,6 +544,22 @@ static inline int is_default_host_route(const struct prefix *p)
return 0; return 0;
} }
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pI4" (struct in_addr *)
#pragma FRR printfrr_ext "%pI4" (in_addr_t *)
#pragma FRR printfrr_ext "%pI6" (struct in6_addr *)
#pragma FRR printfrr_ext "%pFX" (struct prefix *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_ipv4 *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_ipv6 *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_eth *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_evpn *)
#pragma FRR printfrr_ext "%pFX" (struct prefix_fs *)
#pragma FRR printfrr_ext "%pSG4" (struct prefix_sg *)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -31,7 +31,7 @@ struct fbuf {
}; };
#define at(a, b) \ #define at(a, b) \
__attribute__((format(printf, a, b))) PRINTFRR(a, b)
#define atn(a, b) \ #define atn(a, b) \
at(a, b) __attribute__((nonnull(1) _RET_NONNULL)) at(a, b) __attribute__((nonnull(1) _RET_NONNULL))
#define atm(a, b) \ #define atm(a, b) \
@ -75,6 +75,7 @@ char *asnprintfrr(struct memtype *mt, char *out, size_t sz,
#undef at #undef at
#undef atm #undef atm
#undef atn
/* extension specs must start with a capital letter (this is a restriction /* extension specs must start with a capital letter (this is a restriction
* for both performance's and human understanding's sake.) * for both performance's and human understanding's sake.)

View file

@ -331,6 +331,10 @@ static inline int route_table_iter_started(route_table_iter_t *iter)
return iter->state != RT_ITER_STATE_INIT; return iter->state != RT_ITER_STATE_INIT;
} }
#ifdef _FRR_ATTRIBUTE_PRINTFRR
#pragma FRR printfrr_ext "%pRN" (struct route_node *)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -112,7 +112,7 @@ static const struct {
/* no entry/default: 150 */ /* no entry/default: 150 */
}; };
static void __attribute__((format(printf, 5, 6))) static void PRINTFRR(5, 6)
_rnode_zlog(const char *_func, vrf_id_t vrf_id, struct route_node *rn, _rnode_zlog(const char *_func, vrf_id_t vrf_id, struct route_node *rn,
int priority, const char *msgfmt, ...) int priority, const char *msgfmt, ...)
{ {