From 566bdaf68cb41de3884726efc15376a79b3325b5 Mon Sep 17 00:00:00 2001 From: David Lamparter Date: Fri, 27 Mar 2020 13:14:37 +0100 Subject: [PATCH] *: fix format string warnings Signed-off-by: David Lamparter --- bfdd/config.c | 6 +++--- bgpd/bgp_label.c | 2 +- bgpd/bgp_mplsvpn.c | 2 +- bgpd/bgp_vty.c | 8 +++++--- lib/plist.c | 2 +- lib/thread.c | 9 ++++----- lib/yang_wrappers.c | 5 +++-- pimd/pim_tlv.c | 8 ++++---- 8 files changed, 22 insertions(+), 20 deletions(-) diff --git a/bfdd/config.c b/bfdd/config.c index b4bd0daf15..4ae7bfdc08 100644 --- a/bfdd/config.c +++ b/bfdd/config.c @@ -243,17 +243,17 @@ static int parse_peer_config(struct json_object *jo, struct bfd_peer_cfg *bpc) } else if (strcmp(key, "receive-interval") == 0) { bpc->bpc_recvinterval = json_object_get_int64(jo_val); bpc->bpc_has_recvinterval = true; - log_debug(" receive-interval: %llu", + log_debug(" receive-interval: %" PRIu64, bpc->bpc_recvinterval); } else if (strcmp(key, "transmit-interval") == 0) { bpc->bpc_txinterval = json_object_get_int64(jo_val); bpc->bpc_has_txinterval = true; - log_debug(" transmit-interval: %llu", + log_debug(" transmit-interval: %" PRIu64, bpc->bpc_txinterval); } else if (strcmp(key, "echo-interval") == 0) { bpc->bpc_echointerval = json_object_get_int64(jo_val); bpc->bpc_has_echointerval = true; - log_debug(" echo-interval: %llu", + log_debug(" echo-interval: %" PRIu64, bpc->bpc_echointerval); } else if (strcmp(key, "create-only") == 0) { bpc->bpc_createonly = json_object_get_boolean(jo_val); diff --git a/bgpd/bgp_label.c b/bgpd/bgp_label.c index e6e1aaeb19..ec44037bf7 100644 --- a/bgpd/bgp_label.c +++ b/bgpd/bgp_label.c @@ -471,7 +471,7 @@ int bgp_nlri_parse_label(struct peer *peer, struct attr *attr, if (pnt != lim) { flog_err( EC_BGP_UPDATE_RCV, - "%s [Error] Update packet error / L-U (%zu data remaining after parsing)", + "%s [Error] Update packet error / L-U (%td data remaining after parsing)", peer->host, lim - pnt); return BGP_NLRI_PARSE_ERROR_PACKET_LENGTH; } diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 54d8cc877a..fbcfe39c3a 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -244,7 +244,7 @@ int bgp_nlri_parse_vpn(struct peer *peer, struct attr *attr, if (pnt != lim) { flog_err( EC_BGP_UPDATE_RCV, - "%s [Error] Update packet error / VPN (%zu data remaining after parsing)", + "%s [Error] Update packet error / VPN (%td data remaining after parsing)", peer->host, lim - pnt); return BGP_NLRI_PARSE_ERROR_PACKET_LENGTH; } diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index da2ef13dba..9fd73fba19 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9121,10 +9121,12 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, vty_out(vty, "%*s", max_neighbor_width - len, " "); - vty_out(vty, "4 %10u %9u %9u %8" PRIu64 " %4d %4zd %8s", + vty_out(vty, + "4 %10u %9u %9u %8" PRIu64 " %4d %4zu %8s", peer->as, PEER_TOTAL_RX(peer), - PEER_TOTAL_TX(peer), peer->version[afi][safi], - 0, peer->obuf->count, + PEER_TOTAL_TX(peer), + peer->version[afi][safi], 0, + peer->obuf->count, peer_uptime(peer->uptime, timebuf, BGP_UPTIME_LEN, 0, NULL)); diff --git a/lib/plist.c b/lib/plist.c index 40131aebed..b7a020c6f7 100644 --- a/lib/plist.c +++ b/lib/plist.c @@ -778,7 +778,7 @@ static void __attribute__((unused)) prefix_list_print(struct prefix_list *plist) p = &pentry->prefix; - printf(" seq %" PRId64 " %s %s/%d", pentry->seq, + printf(" seq %lld %s %s/%d", (long long)pentry->seq, prefix_list_type_str(pentry), inet_ntop(p->family, p->u.val, buf, BUFSIZ), p->prefixlen); diff --git a/lib/thread.c b/lib/thread.c index 2217a60f0a..dbf668a699 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -114,11 +114,10 @@ static void vty_out_cpu_thread_history(struct vty *vty, struct cpu_thread_history *a) { vty_out(vty, "%5zu %10zu.%03zu %9zu %8zu %9zu %8zu %9zu", - (size_t)a->total_active, - a->cpu.total / 1000, a->cpu.total % 1000, - (size_t)a->total_calls, - a->cpu.total / a->total_calls, a->cpu.max, - a->real.total / a->total_calls, a->real.max); + (size_t)a->total_active, a->cpu.total / 1000, + a->cpu.total % 1000, (size_t)a->total_calls, + (size_t)(a->cpu.total / a->total_calls), a->cpu.max, + (size_t)(a->real.total / a->total_calls), a->real.max); vty_out(vty, " %c%c%c%c%c %s\n", a->types & (1 << THREAD_READ) ? 'R' : ' ', a->types & (1 << THREAD_WRITE) ? 'W' : ' ', diff --git a/lib/yang_wrappers.c b/lib/yang_wrappers.c index a308b18b73..2b502d635b 100644 --- a/lib/yang_wrappers.c +++ b/lib/yang_wrappers.c @@ -22,6 +22,7 @@ #include "log.h" #include "lib_errors.h" #include "northbound.h" +#include "printfrr.h" static const char *yang_get_default_value(const char *xpath) { @@ -443,7 +444,7 @@ struct yang_data *yang_data_new_int64(const char *xpath, int64_t value) { char value_str[BUFSIZ]; - snprintf(value_str, sizeof(value_str), "%" PRId64, value); + snprintfrr(value_str, sizeof(value_str), "%" PRId64, value); return yang_data_new(xpath, value_str); } @@ -651,7 +652,7 @@ struct yang_data *yang_data_new_uint64(const char *xpath, uint64_t value) { char value_str[BUFSIZ]; - snprintf(value_str, sizeof(value_str), "%" PRIu64, value); + snprintfrr(value_str, sizeof(value_str), "%" PRIu64, value); return yang_data_new(xpath, value_str); } diff --git a/pimd/pim_tlv.c b/pimd/pim_tlv.c index 5a751ac929..881a3e332a 100644 --- a/pimd/pim_tlv.c +++ b/pimd/pim_tlv.c @@ -473,7 +473,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size) case PIM_MSG_ADDRESS_FAMILY_IPV4: if ((addr + sizeof(struct in_addr)) > pastend) { zlog_warn( - "%s: IPv4 unicast address overflow: left=%zd needed=%zu", + "%s: IPv4 unicast address overflow: left=%td needed=%zu", __func__, pastend - addr, sizeof(struct in_addr)); return -3; @@ -489,7 +489,7 @@ int pim_parse_addr_ucast(struct prefix *p, const uint8_t *buf, int buf_size) case PIM_MSG_ADDRESS_FAMILY_IPV6: if ((addr + sizeof(struct in6_addr)) > pastend) { zlog_warn( - "%s: IPv6 unicast address overflow: left=%zd needed %zu", + "%s: IPv6 unicast address overflow: left=%td needed %zu", __func__, pastend - addr, sizeof(struct in6_addr)); return -3; @@ -548,7 +548,7 @@ int pim_parse_addr_group(struct prefix_sg *sg, const uint8_t *buf, int buf_size) if ((addr + sizeof(struct in_addr)) > pastend) { zlog_warn( - "%s: IPv4 group address overflow: left=%zd needed=%zu from", + "%s: IPv4 group address overflow: left=%td needed=%zu from", __func__, pastend - addr, sizeof(struct in_addr)); return -3; @@ -607,7 +607,7 @@ int pim_parse_addr_source(struct prefix_sg *sg, uint8_t *flags, case PIM_MSG_ADDRESS_FAMILY_IPV4: if ((addr + sizeof(struct in_addr)) > pastend) { zlog_warn( - "%s: IPv4 source address overflow: left=%zd needed=%zu", + "%s: IPv4 source address overflow: left=%td needed=%zu", __func__, pastend - addr, sizeof(struct in_addr)); return -3;