diff options
author | David Lamparter <equinox@opensourcerouting.org> | 2023-01-26 14:21:02 +0100 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2023-01-27 12:01:17 +0100 |
commit | 0f9de11a11644b77cc60d6ff6ac4519d2e5c29e1 (patch) | |
tree | c8e418c2049ef79101e62821f2b49506654eb4bd | |
parent | Merge pull request #12575 from anlancs/fix/build-vtysh-missing-dir (diff) | |
download | frr-0f9de11a11644b77cc60d6ff6ac4519d2e5c29e1.tar.xz frr-0f9de11a11644b77cc60d6ff6ac4519d2e5c29e1.zip |
*: apply proper format string attributes
So that we get warnings about broken format strings.
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
-rw-r--r-- | bfdd/bfd_packet.c | 1 | ||||
-rw-r--r-- | bfdd/ptm_adapter.c | 1 | ||||
-rw-r--r-- | bgpd/rfapi/rfapi_vty.c | 1 | ||||
-rw-r--r-- | lib/clippy.c | 1 | ||||
-rw-r--r-- | lib/ferr.c | 1 | ||||
-rw-r--r-- | lib/ferr.h | 9 | ||||
-rw-r--r-- | lib/northbound_cli.h | 5 | ||||
-rw-r--r-- | lib/termtable.c | 1 | ||||
-rw-r--r-- | lib/yang.h | 15 | ||||
-rw-r--r-- | lib/yang_wrappers.c | 2 | ||||
-rw-r--r-- | lib/yang_wrappers.h | 96 | ||||
-rw-r--r-- | pathd/path_pcep_lib.c | 3 | ||||
-rw-r--r-- | pceplib/pcep_utils_logging.c | 4 |
13 files changed, 87 insertions, 53 deletions
diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index 6397aa574..6980e5186 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -746,6 +746,7 @@ static void bfd_sd_reschedule(struct bfd_vrf_global *bvrf, int sd) } } +PRINTFRR(6, 7) static void cp_debug(bool mhop, struct sockaddr_any *peer, struct sockaddr_any *local, ifindex_t ifindex, vrf_id_t vrfid, const char *fmt, ...) diff --git a/bfdd/ptm_adapter.c b/bfdd/ptm_adapter.c index f6259b9c3..8a27fced5 100644 --- a/bfdd/ptm_adapter.c +++ b/bfdd/ptm_adapter.c @@ -81,6 +81,7 @@ static void bfdd_client_deregister(struct stream *msg); /* * Functions */ +PRINTFRR(2, 3) static void debug_printbpc(const struct bfd_peer_cfg *bpc, const char *fmt, ...) { char timers[3][128] = {}; diff --git a/bgpd/rfapi/rfapi_vty.c b/bgpd/rfapi/rfapi_vty.c index 719d898e3..d04d1ee75 100644 --- a/bgpd/rfapi/rfapi_vty.c +++ b/bgpd/rfapi/rfapi_vty.c @@ -322,6 +322,7 @@ int rfapiDebugPrintf(void *dummy, const char *format, ...) return 0; } +PRINTFRR(2, 3) static int rfapiStdioPrintf(void *stream, const char *format, ...) { FILE *file = NULL; diff --git a/lib/clippy.c b/lib/clippy.c index 7ca99c9a9..1c27f857b 100644 --- a/lib/clippy.c +++ b/lib/clippy.c @@ -108,6 +108,7 @@ int main(int argc, char **argv) #include "log.h" +PRINTFRR(3, 0) void vzlogx(const struct xref_logmsg *xref, int prio, const char *format, va_list args) { diff --git a/lib/ferr.c b/lib/ferr.c index bef7f3b20..4e4152621 100644 --- a/lib/ferr.c +++ b/lib/ferr.c @@ -219,6 +219,7 @@ ferr_r ferr_clear(void) return ferr_ok(); } +PRINTFRR(7, 0) static ferr_r ferr_set_va(const char *file, int line, const char *func, enum ferr_kind kind, const char *pathname, int errno_val, const char *text, va_list va) diff --git a/lib/ferr.h b/lib/ferr.h index c27601f66..9accde169 100644 --- a/lib/ferr.h +++ b/lib/ferr.h @@ -178,10 +178,12 @@ ferr_r ferr_clear(void); /* do NOT call these functions directly. only for macro use! */ ferr_r ferr_set_internal(const char *file, int line, const char *func, - enum ferr_kind kind, const char *text, ...); + enum ferr_kind kind, const char *text, ...) + PRINTFRR(5, 6); ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, enum ferr_kind kind, const char *pathname, - int errno_val, const char *text, ...); + int errno_val, const char *text, ...) + PRINTFRR(7, 8); #define ferr_ok() 0 @@ -221,7 +223,8 @@ ferr_r ferr_set_internal_ext(const char *file, int line, const char *func, #include "vty.h" /* print error message to vty; $ERR is replaced by the error's message */ -void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...); +void vty_print_error(struct vty *vty, ferr_r err, const char *msg, ...) + PRINTFRR(3, 4); #define CMD_FERR_DO(func, action, ...) \ do { \ diff --git a/lib/northbound_cli.h b/lib/northbound_cli.h index e47242544..d848507e0 100644 --- a/lib/northbound_cli.h +++ b/lib/northbound_cli.h @@ -71,7 +71,8 @@ extern void nb_cli_enqueue_change(struct vty *vty, const char *xpath, * CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise. */ extern int nb_cli_apply_changes_clear_pending(struct vty *vty, - const char *xpath_base_fmt, ...); + const char *xpath_base_fmt, ...) + PRINTFRR(2, 3); /* * Apply enqueued changes to the candidate configuration, this function @@ -89,7 +90,7 @@ extern int nb_cli_apply_changes_clear_pending(struct vty *vty, * CMD_SUCCESS on success, CMD_WARNING_CONFIG_FAILED otherwise. */ extern int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, - ...); + ...) PRINTFRR(2, 3); /* * Execute a YANG RPC or Action. diff --git a/lib/termtable.c b/lib/termtable.c index ddf882285..91ec75300 100644 --- a/lib/termtable.c +++ b/lib/termtable.c @@ -130,6 +130,7 @@ struct ttable *ttable_new(const struct ttable_style *style) * * @return pointer to the first cell of allocated row */ +PRINTFRR(3, 0) static struct ttable_cell *ttable_insert_row_va(struct ttable *tt, int i, const char *format, va_list ap) { diff --git a/lib/yang.h b/lib/yang.h index d625b24f6..8b49df5e9 100644 --- a/lib/yang.h +++ b/lib/yang.h @@ -331,7 +331,8 @@ extern void yang_dnode_get_path(const struct lyd_node *dnode, char *xpath, * Schema name of the libyang data node. */ extern const char *yang_dnode_get_schema_name(const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); /* * Find a libyang data node by its YANG data path. @@ -366,7 +367,8 @@ extern struct lyd_node *yang_dnode_get(const struct lyd_node *dnode, * The libyang data node if found, or NULL if not found. */ extern struct lyd_node *yang_dnode_getf(const struct lyd_node *dnode, - const char *path_fmt, ...); + const char *path_fmt, ...) + PRINTFRR(2, 3); /* * Check if a libyang data node exists. @@ -400,7 +402,7 @@ extern bool yang_dnode_exists(const struct lyd_node *dnode, const char *xpath); * true if a libyang data node was found, false otherwise. */ extern bool yang_dnode_existsf(const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); /* * Iterate over all libyang data nodes that satisfy an XPath query. @@ -422,7 +424,7 @@ extern bool yang_dnode_existsf(const struct lyd_node *dnode, */ void yang_dnode_iterate(yang_dnode_iter_cb cb, void *arg, const struct lyd_node *dnode, const char *xpath_fmt, - ...); + ...) PRINTFRR(4, 5); /* * Check if the libyang data node contains a default value. Non-presence @@ -459,7 +461,7 @@ extern bool yang_dnode_is_default(const struct lyd_node *dnode, * true if the data node contains the default value, false otherwise. */ extern bool yang_dnode_is_defaultf(const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); /* * Check if the libyang data node and all of its children contain default @@ -566,7 +568,8 @@ extern struct list *yang_data_list_new(void); * Pointer to yang_data if found, NULL otherwise. */ extern struct yang_data *yang_data_list_find(const struct list *list, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); /* * Create and set up a libyang context (for use by the translator) diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index ea21d1324..d22379dd2 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -58,6 +58,7 @@ } \ } while (0) +PRINTFRR(2, 0) static inline const char * yang_dnode_xpath_get_canon(const struct lyd_node *dnode, const char *xpath_fmt, va_list ap) @@ -75,6 +76,7 @@ yang_dnode_xpath_get_canon(const struct lyd_node *dnode, const char *xpath_fmt, return lyd_get_value(&__dleaf->node); } +PRINTFRR(2, 0) static inline const struct lyd_value * yang_dnode_xpath_get_value(const struct lyd_node *dnode, const char *xpath_fmt, va_list ap) diff --git a/lib/yang_wrappers.h b/lib/yang_wrappers.h index 56b314876..c27e1e537 100644 --- a/lib/yang_wrappers.h +++ b/lib/yang_wrappers.h @@ -30,105 +30,120 @@ extern "C" { extern bool yang_str2bool(const char *value); extern struct yang_data *yang_data_new_bool(const char *xpath, bool value); extern bool yang_dnode_get_bool(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern bool yang_get_default_bool(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern bool yang_get_default_bool(const char *xpath_fmt, ...) PRINTFRR(1, 2); /* dec64 */ extern double yang_str2dec64(const char *xpath, const char *value); extern struct yang_data *yang_data_new_dec64(const char *xpath, double value); extern double yang_dnode_get_dec64(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern double yang_get_default_dec64(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern double yang_get_default_dec64(const char *xpath_fmt, ...) PRINTFRR(1, 2); /* enum */ extern int yang_str2enum(const char *xpath, const char *value); extern struct yang_data *yang_data_new_enum(const char *xpath, int value); extern int yang_dnode_get_enum(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern int yang_get_default_enum(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern int yang_get_default_enum(const char *xpath_fmt, ...) PRINTFRR(1, 2); /* int8 */ extern int8_t yang_str2int8(const char *value); extern struct yang_data *yang_data_new_int8(const char *xpath, int8_t value); extern int8_t yang_dnode_get_int8(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern int8_t yang_get_default_int8(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern int8_t yang_get_default_int8(const char *xpath_fmt, ...) PRINTFRR(1, 2); /* int16 */ extern int16_t yang_str2int16(const char *value); extern struct yang_data *yang_data_new_int16(const char *xpath, int16_t value); extern int16_t yang_dnode_get_int16(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern int16_t yang_get_default_int16(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern int16_t yang_get_default_int16(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* int32 */ extern int32_t yang_str2int32(const char *value); extern struct yang_data *yang_data_new_int32(const char *xpath, int32_t value); extern int32_t yang_dnode_get_int32(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern int32_t yang_get_default_int32(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern int32_t yang_get_default_int32(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* int64 */ extern int64_t yang_str2int64(const char *value); extern struct yang_data *yang_data_new_int64(const char *xpath, int64_t value); extern int64_t yang_dnode_get_int64(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern int64_t yang_get_default_int64(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern int64_t yang_get_default_int64(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* uint8 */ extern uint8_t yang_str2uint8(const char *value); extern struct yang_data *yang_data_new_uint8(const char *xpath, uint8_t value); extern uint8_t yang_dnode_get_uint8(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern uint8_t yang_get_default_uint8(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); +extern uint8_t yang_get_default_uint8(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* uint16 */ extern uint16_t yang_str2uint16(const char *value); extern struct yang_data *yang_data_new_uint16(const char *xpath, uint16_t value); extern uint16_t yang_dnode_get_uint16(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern uint16_t yang_get_default_uint16(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); +extern uint16_t yang_get_default_uint16(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* uint32 */ extern uint32_t yang_str2uint32(const char *value); extern struct yang_data *yang_data_new_uint32(const char *xpath, uint32_t value); extern uint32_t yang_dnode_get_uint32(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern uint32_t yang_get_default_uint32(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); +extern uint32_t yang_get_default_uint32(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* uint64 */ extern uint64_t yang_str2uint64(const char *value); extern struct yang_data *yang_data_new_uint64(const char *xpath, uint64_t value); extern uint64_t yang_dnode_get_uint64(const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern uint64_t yang_get_default_uint64(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); +extern uint64_t yang_get_default_uint64(const char *xpath_fmt, ...) + PRINTFRR(1, 2); /* string */ extern struct yang_data *yang_data_new_string(const char *xpath, const char *value); extern const char *yang_dnode_get_string(const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(2, 3); extern void yang_dnode_get_string_buf(char *buf, size_t size, const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern const char *yang_get_default_string(const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(4, 5); +extern const char *yang_get_default_string(const char *xpath_fmt, ...) + PRINTFRR(1, 2); extern void yang_get_default_string_buf(char *buf, size_t size, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(3, 4); /* binary */ extern struct yang_data *yang_data_new_binary(const char *xpath, const char *value, size_t len); extern size_t yang_dnode_get_binary_buf(char *buf, size_t size, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) + PRINTFRR(4, 5); /* empty */ extern struct yang_data *yang_data_new_empty(const char *xpath); extern bool yang_dnode_get_empty(const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(2, 3); /* ip prefix */ extern void yang_str2prefix(const char *value, union prefixptr prefix); @@ -136,9 +151,9 @@ extern struct yang_data *yang_data_new_prefix(const char *xpath, union prefixconstptr prefix); extern void yang_dnode_get_prefix(struct prefix *prefix, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); extern void yang_get_default_prefix(union prefixptr var, const char *xpath_fmt, - ...); + ...) PRINTFRR(2, 3); /* ipv4 */ extern void yang_str2ipv4(const char *value, struct in_addr *addr); @@ -146,9 +161,9 @@ extern struct yang_data *yang_data_new_ipv4(const char *xpath, const struct in_addr *addr); extern void yang_dnode_get_ipv4(struct in_addr *addr, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); extern void yang_get_default_ipv4(struct in_addr *var, const char *xpath_fmt, - ...); + ...) PRINTFRR(2, 3); /* ipv4p */ extern void yang_str2ipv4p(const char *value, union prefixptr prefix); @@ -156,9 +171,9 @@ extern struct yang_data *yang_data_new_ipv4p(const char *xpath, union prefixconstptr prefix); extern void yang_dnode_get_ipv4p(union prefixptr prefix, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); extern void yang_get_default_ipv4p(union prefixptr var, const char *xpath_fmt, - ...); + ...) PRINTFRR(2, 3); /* ipv6 */ extern void yang_str2ipv6(const char *value, struct in6_addr *addr); @@ -166,9 +181,9 @@ extern struct yang_data *yang_data_new_ipv6(const char *xpath, const struct in6_addr *addr); extern void yang_dnode_get_ipv6(struct in6_addr *addr, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); extern void yang_get_default_ipv6(struct in6_addr *var, const char *xpath_fmt, - ...); + ...) PRINTFRR(2, 3); /* ipv6p */ extern void yang_str2ipv6p(const char *value, union prefixptr prefix); @@ -176,17 +191,18 @@ extern struct yang_data *yang_data_new_ipv6p(const char *xpath, union prefixconstptr prefix); extern void yang_dnode_get_ipv6p(union prefixptr prefix, const struct lyd_node *dnode, - const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); extern void yang_get_default_ipv6p(union prefixptr var, const char *xpath_fmt, - ...); + ...) PRINTFRR(2, 3); /* ip */ extern void yang_str2ip(const char *value, struct ipaddr *addr); extern struct yang_data *yang_data_new_ip(const char *xpath, const struct ipaddr *addr); extern void yang_dnode_get_ip(struct ipaddr *addr, const struct lyd_node *dnode, - const char *xpath_fmt, ...); -extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...); + const char *xpath_fmt, ...) PRINTFRR(3, 4); +extern void yang_get_default_ip(struct ipaddr *var, const char *xpath_fmt, ...) + PRINTFRR(2, 3); /* mac */ extern struct yang_data *yang_data_new_mac(const char *xpath, diff --git a/pathd/path_pcep_lib.c b/pathd/path_pcep_lib.c index 8e3565d72..6b247b705 100644 --- a/pathd/path_pcep_lib.c +++ b/pathd/path_pcep_lib.c @@ -38,7 +38,8 @@ DEFINE_MTYPE_STATIC(PATHD, PCEPLIB_MESSAGES, "PCEPlib PCEP Messages"); #define MAX_PATH_NAME_SIZE 255 /* pceplib logging callback */ -static int pceplib_logging_cb(int level, const char *fmt, va_list args); +static int pceplib_logging_cb(int level, const char *fmt, va_list args) + PRINTFRR(2, 0); /* Socket callbacks */ static int pcep_lib_pceplib_socket_read_cb(void *fpt, void **thread, int fd, diff --git a/pceplib/pcep_utils_logging.c b/pceplib/pcep_utils_logging.c index c9b2588b4..7afe55f12 100644 --- a/pceplib/pcep_utils_logging.c +++ b/pceplib/pcep_utils_logging.c @@ -27,10 +27,12 @@ #include <stdarg.h> #include <stdio.h> +#include "compiler.h" #include "pcep_utils_logging.h" /* Forward declaration */ -int pcep_stdout_logger(int priority, const char *format, va_list args); +int pcep_stdout_logger(int priority, const char *format, va_list args) + PRINTFRR(2, 0); static pcep_logger_func logger_func = pcep_stdout_logger; static int logging_level_ = LOG_INFO; |