*: apply proper format string attributes

So that we get warnings about broken format strings.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
David Lamparter 2023-01-26 14:21:02 +01:00
parent e784f789fb
commit 0f9de11a11
13 changed files with 87 additions and 53 deletions

View File

@ -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, ...)

View File

@ -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] = {};

View File

@ -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;

View File

@ -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)
{

View File

@ -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)

View File

@ -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 { \

View File

@ -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.

View File

@ -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)
{

View File

@ -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)

View File

@ -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)

View File

@ -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,

View File

@ -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,

View File

@ -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;