Browse Source

pimd: fix format strings

 * pim_igmp.c,
 * pim_igmpv3.c,
 * pim_pim.c,
 * pim_tlv.c: use %zu / %zd for size_t/ssize_t
 * pim_iface.c,
 * pim_ifchannel.c,
 * pim_mroute.c,
 * pim_neighbor.c,
 * pim_oil.c,
 * pim_ssmpingd.c,
 * pim_upstream.c: %zu for size_t
 * pim_cmd.c: %zu + a few (long long) casts for int64_t
 * pim_hello.c: %td for ptrdiff_t
David Lamparter 7 years ago
parent
commit
5c69798346

+ 7 - 7
pimd/pim_cmd.c

@@ -1091,8 +1091,8 @@ static void show_rpf_refresh_stats(struct vty *vty, time_t now)
 	  "RPF Cache Refresh Last:     %s%s",
 	  qpim_rpf_cache_refresh_delay_msec, VTY_NEWLINE,
 	  pim_time_timer_remain_msec(qpim_rpf_cache_refresher), VTY_NEWLINE,
-	  qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
-	  qpim_rpf_cache_refresh_events, VTY_NEWLINE,
+	  (long long)qpim_rpf_cache_refresh_requests, VTY_NEWLINE,
+	  (long long)qpim_rpf_cache_refresh_events, VTY_NEWLINE,
 	  refresh_uptime, VTY_NEWLINE);
 }
 
@@ -2241,7 +2241,7 @@ static void show_ssmpingd(struct vty *vty)
 	    bind_addr_str,
 	    ntohs(bind_addr.sin_port),
 	    ss_uptime,
-	    ss->requests,
+	    (long long)ss->requests,
 	    VTY_NEWLINE);
   }
 }
@@ -3642,7 +3642,7 @@ DEFUN (test_pim_receive_dump,
 
       left = sizeof(buf) - ip_hlen - pim_msg_size;
       if (left < 1) {
-	vty_out(vty, "%% Overflow buf_size=%d buf_left=%d at hex array arg %d=%s octet %02x%s",
+	vty_out(vty, "%% Overflow buf_size=%zu buf_left=%d at hex array arg %d=%s octet %02x%s",
 		sizeof(buf), left, argi, str, octet, VTY_NEWLINE);
 	return CMD_WARNING;
       }
@@ -3653,7 +3653,7 @@ DEFUN (test_pim_receive_dump,
 
   ip_msg_len = ip_hlen + pim_msg_size;
 
-  vty_out(vty, "Receiving: buf_size=%d ip_msg_size=%d pim_msg_size=%d%s",
+  vty_out(vty, "Receiving: buf_size=%zu ip_msg_size=%d pim_msg_size=%d%s",
 	  sizeof(buf), ip_msg_len, pim_msg_size, VTY_NEWLINE);
 
   /* "receive" message */
@@ -3873,7 +3873,7 @@ DEFUN (test_pim_receive_assert,
 
   remain = buf_pastend - buf;
   if (remain < (int) sizeof(struct ip)) {
-    vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%d%s",
+    vty_out(vty, "No room for ip header: buf_size=%d < ip_header_size=%zu%s",
 	    remain, sizeof(struct ip), VTY_NEWLINE);
     return CMD_WARNING;
   }
@@ -4195,7 +4195,7 @@ DEFUN (test_pim_receive_upcall,
 
   result = pim_mroute_msg(-1, (char *) &msg, sizeof(msg));
   if (result) {
-    vty_out(vty, "pim_mroute_msg(len=%d) returned failure: %d%s",
+    vty_out(vty, "pim_mroute_msg(len=%zu) returned failure: %d%s",
 	    sizeof(msg), result, VTY_NEWLINE);
     return CMD_WARNING;
   }

+ 1 - 1
pimd/pim_hello.c

@@ -197,7 +197,7 @@ int pim_hello_recv(struct interface *ifp,
     if ((tlv_curr + option_len) > tlv_pastend) {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: long PIM hello TLV type=%d length=%d > left=%d from %s on interface %s",
+      zlog_warn("%s: long PIM hello TLV type=%d length=%d > left=%td from %s on interface %s",
 		__PRETTY_FUNCTION__,
 		option_type, option_len, tlv_pastend - tlv_curr,
 		src_str, ifp->name);

+ 2 - 2
pimd/pim_iface.c

@@ -80,7 +80,7 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
 
   pim_ifp = XMALLOC(MTYPE_PIM_INTERFACE, sizeof(*pim_ifp));
   if (!pim_ifp) {
-    zlog_err("PIM XMALLOC(%d) failure", sizeof(*pim_ifp));
+    zlog_err("PIM XMALLOC(%zu) failure", sizeof(*pim_ifp));
     return 0;
   }
 
@@ -911,7 +911,7 @@ static struct igmp_join *igmp_join_new(struct interface *ifp,
     char source_str[100];
     pim_inet4_dump("<grp?>", group_addr, group_str, sizeof(group_str));
     pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
-    zlog_err("%s: XMALLOC(%d) failure for IGMP group %s source %s on interface %s",
+    zlog_err("%s: XMALLOC(%zu) failure for IGMP group %s source %s on interface %s",
 	     __PRETTY_FUNCTION__,
 	     sizeof(*ij), group_str, source_str, ifp->name);
     close(join_fd);

+ 1 - 1
pimd/pim_ifchannel.c

@@ -204,7 +204,7 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp,
 
   ch = XMALLOC(MTYPE_PIM_IFCHANNEL, sizeof(*ch));
   if (!ch) {
-    zlog_err("%s: PIM XMALLOC(%d) failure",
+    zlog_err("%s: PIM XMALLOC(%zu) failure",
 	     __PRETTY_FUNCTION__, sizeof(*ch));
     return 0;
   }

+ 4 - 4
pimd/pim_igmp.c

@@ -679,7 +679,7 @@ int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len)
   char to_str[100];
     
   if (len < sizeof(*ip_hdr)) {
-    zlog_warn("IGMP packet size=%d shorter than minimum=%d",
+    zlog_warn("IGMP packet size=%zu shorter than minimum=%zu",
 	      len, sizeof(*ip_hdr));
     return -1;
   }
@@ -692,7 +692,7 @@ int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len)
   ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
 
   if (PIM_DEBUG_IGMP_PACKETS) {
-    zlog_debug("Recv IP packet from %s to %s on %s: size=%d ip_header_size=%d ip_proto=%d",
+    zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
 	       from_str, to_str, igmp->interface->name, len, ip_hlen, ip_hdr->ip_p);
   }
 
@@ -703,12 +703,12 @@ int pim_igmp_packet(struct igmp_sock *igmp, char *buf, size_t len)
   }
 
   if (ip_hlen < PIM_IP_HEADER_MIN_LEN) {
-    zlog_warn("IP packet header size=%d shorter than minimum=%d",
+    zlog_warn("IP packet header size=%zu shorter than minimum=%d",
 	      ip_hlen, PIM_IP_HEADER_MIN_LEN);
     return -1;
   }
   if (ip_hlen > PIM_IP_HEADER_MAX_LEN) {
-    zlog_warn("IP packet header size=%d greater than maximum=%d",
+    zlog_warn("IP packet header size=%zu greater than maximum=%d",
 	      ip_hlen, PIM_IP_HEADER_MAX_LEN);
     return -1;
   }

+ 6 - 6
pimd/pim_igmpv3.c

@@ -1151,7 +1151,7 @@ static int group_retransmit_sources(struct igmp_group *group,
       if (num_sources_tosend1 > query_buf1_max_sources) {
 	char group_str[100];
 	pim_inet4_dump("<group?>", group->group_addr, group_str, sizeof(group_str));
-	zlog_warn("%s: group %s on %s: s_flag=1 unable to fit %d sources into buf_size=%d (max_sources=%d)",
+	zlog_warn("%s: group %s on %s: s_flag=1 unable to fit %d sources into buf_size=%zu (max_sources=%d)",
 		  __PRETTY_FUNCTION__, group_str, igmp->interface->name,
 		  num_sources_tosend1, sizeof(query_buf1), query_buf1_max_sources);
       }
@@ -1193,7 +1193,7 @@ static int group_retransmit_sources(struct igmp_group *group,
     if (num_sources_tosend2 > query_buf2_max_sources) {
       char group_str[100];
       pim_inet4_dump("<group?>", group->group_addr, group_str, sizeof(group_str));
-      zlog_warn("%s: group %s on %s: s_flag=0 unable to fit %d sources into buf_size=%d (max_sources=%d)",
+      zlog_warn("%s: group %s on %s: s_flag=0 unable to fit %d sources into buf_size=%zu (max_sources=%d)",
 		__PRETTY_FUNCTION__, group_str, igmp->interface->name,
 		num_sources_tosend2, sizeof(query_buf2), query_buf2_max_sources);
     }
@@ -1622,7 +1622,7 @@ void pim_igmp_send_membership_query(struct igmp_group *group,
 
   msg_size = IGMP_V3_SOURCES_OFFSET + (num_sources << 2);
   if (msg_size > query_buf_size) {
-    zlog_err("%s %s: unable to send: msg_size=%d larger than query_buf_size=%d",
+    zlog_err("%s %s: unable to send: msg_size=%zd larger than query_buf_size=%d",
 	     __FILE__, __PRETTY_FUNCTION__,
 	     msg_size, query_buf_size);
     return;
@@ -1662,7 +1662,7 @@ void pim_igmp_send_membership_query(struct igmp_group *group,
     char group_str[100];
     pim_inet4_dump("<dst?>", dst_addr, dst_str, sizeof(dst_str));
     pim_inet4_dump("<group?>", group_addr, group_str, sizeof(group_str));
-    zlog_debug("%s: to %s on %s: group=%s sources=%d msg_size=%d s_flag=%x QRV=%u QQI=%u QQIC=%02x checksum=%x",
+    zlog_debug("%s: to %s on %s: group=%s sources=%d msg_size=%zd s_flag=%x QRV=%u QQI=%u QQIC=%02x checksum=%x",
 	       __PRETTY_FUNCTION__,
 	       dst_str, ifname, group_str, num_sources,
 	       msg_size, s_flag, querier_robustness_variable,
@@ -1687,13 +1687,13 @@ void pim_igmp_send_membership_query(struct igmp_group *group,
     pim_inet4_dump("<dst?>", dst_addr, dst_str, sizeof(dst_str));
     pim_inet4_dump("<group?>", group_addr, group_str, sizeof(group_str));
     if (sent < 0) {
-      zlog_warn("%s: sendto() failure to %s on %s: group=%s msg_size=%d: errno=%d: %s",
+      zlog_warn("%s: sendto() failure to %s on %s: group=%s msg_size=%zd: errno=%d: %s",
 		__PRETTY_FUNCTION__,
 		dst_str, ifname, group_str, msg_size,
 		e, safe_strerror(e));
     }
     else {
-      zlog_warn("%s: sendto() partial to %s on %s: group=%s msg_size=%d: sent=%d",
+      zlog_warn("%s: sendto() partial to %s on %s: group=%s msg_size=%zd: sent=%zd",
 		__PRETTY_FUNCTION__,
 		dst_str, ifname, group_str,
 		msg_size, sent);

+ 1 - 1
pimd/pim_mroute.c

@@ -201,7 +201,7 @@ static int mroute_read_msg(int fd)
   int rd;
 
   if (((int) sizeof(buf)) < msg_min_size) {
-    zlog_err("%s: fd=%d: buf size=%d lower than msg_min=%d",
+    zlog_err("%s: fd=%d: buf size=%zu lower than msg_min=%d",
 	     __PRETTY_FUNCTION__, fd, sizeof(buf), msg_min_size);
     return -1;
   }

+ 1 - 1
pimd/pim_neighbor.c

@@ -292,7 +292,7 @@ static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
 
   neigh = XMALLOC(MTYPE_PIM_NEIGHBOR, sizeof(*neigh));
   if (!neigh) {
-    zlog_err("%s: PIM XMALLOC(%d) failure",
+    zlog_err("%s: PIM XMALLOC(%zu) failure",
 	     __PRETTY_FUNCTION__, sizeof(*neigh));
     return 0;
   }

+ 2 - 2
pimd/pim_oil.c

@@ -69,7 +69,7 @@ static struct channel_oil *channel_oil_new(struct in_addr group_addr,
 
   c_oil = XCALLOC(MTYPE_PIM_CHANNEL_OIL, sizeof(*c_oil));
   if (!c_oil) {
-    zlog_err("PIM XCALLOC(%d) failure", sizeof(*c_oil));
+    zlog_err("PIM XCALLOC(%zu) failure", sizeof(*c_oil));
     return 0;
   }
 
@@ -91,7 +91,7 @@ static struct channel_oil *pim_add_channel_oil(struct in_addr group_addr,
 
   c_oil = channel_oil_new(group_addr, source_addr, input_vif_index);
   if (!c_oil) {
-    zlog_warn("PIM XCALLOC(%d) failure", sizeof(*c_oil));
+    zlog_warn("PIM XCALLOC(%zu) failure", sizeof(*c_oil));
     return 0;
   }
 

+ 5 - 5
pimd/pim_pim.c

@@ -132,7 +132,7 @@ int pim_pim_packet(struct interface *ifp, char *buf, size_t len)
   }
     
   if (len < sizeof(*ip_hdr)) {
-    zlog_warn("PIM packet size=%d shorter than minimum=%d",
+    zlog_warn("PIM packet size=%zu shorter than minimum=%zu",
 	      len, sizeof(*ip_hdr));
     return -1;
   }
@@ -145,7 +145,7 @@ int pim_pim_packet(struct interface *ifp, char *buf, size_t len)
   ip_hlen = ip_hdr->ip_hl << 2; /* ip_hl gives length in 4-byte words */
 
   if (PIM_DEBUG_PIM_PACKETS) {
-    zlog_debug("Recv IP packet from %s to %s on %s: size=%d ip_header_size=%d ip_proto=%d",
+    zlog_debug("Recv IP packet from %s to %s on %s: size=%zu ip_header_size=%zu ip_proto=%d",
 	       src_str, dst_str, ifp->name, len, ip_hlen, ip_hdr->ip_p);
   }
 
@@ -156,12 +156,12 @@ int pim_pim_packet(struct interface *ifp, char *buf, size_t len)
   }
 
   if (ip_hlen < PIM_IP_HEADER_MIN_LEN) {
-    zlog_warn("IP packet header size=%d shorter than minimum=%d",
+    zlog_warn("IP packet header size=%zu shorter than minimum=%d",
 	      ip_hlen, PIM_IP_HEADER_MIN_LEN);
     return -1;
   }
   if (ip_hlen > PIM_IP_HEADER_MAX_LEN) {
-    zlog_warn("IP packet header size=%d greater than maximum=%d",
+    zlog_warn("IP packet header size=%zu greater than maximum=%d",
 	      ip_hlen, PIM_IP_HEADER_MAX_LEN);
     return -1;
   }
@@ -480,7 +480,7 @@ int pim_msg_send(int fd,
 		e, safe_strerror(e));
     }
     else {
-      zlog_warn("%s: sendto() partial to %s on %s: fd=%d msg_size=%d: sent=%d",
+      zlog_warn("%s: sendto() partial to %s on %s: fd=%d msg_size=%d: sent=%zd",
 		__PRETTY_FUNCTION__,
 		dst_str, ifname, fd,
 		pim_msg_size, sent);

+ 2 - 2
pimd/pim_ssmpingd.c

@@ -99,7 +99,7 @@ static int ssmpingd_socket(struct in_addr addr, int port, int mttl)
   if (bind(fd, &sockaddr, sizeof(sockaddr))) {
     char addr_str[100];
     pim_inet4_dump("<addr?>", addr, addr_str, sizeof(addr_str));
-    zlog_warn("%s: bind(fd=%d,addr=%s,port=%d,len=%d) failure: errno=%d: %s",
+    zlog_warn("%s: bind(fd=%d,addr=%s,port=%d,len=%zu) failure: errno=%d: %s",
 	      __PRETTY_FUNCTION__,
 	      fd, addr_str, port, sizeof(sockaddr),
 	      errno, safe_strerror(errno));
@@ -373,7 +373,7 @@ static struct ssmpingd_sock *ssmpingd_new(struct in_addr source_addr)
   if (!ss) {
     char source_str[100];
     pim_inet4_dump("<src?>", source_addr, source_str, sizeof(source_str));
-    zlog_err("%s: XMALLOC(%d) failure for ssmpingd source %s",
+    zlog_err("%s: XMALLOC(%zu) failure for ssmpingd source %s",
 	     __PRETTY_FUNCTION__,
 	     sizeof(*ss), source_str);
     close(sock_fd);

+ 8 - 8
pimd/pim_tlv.c

@@ -39,7 +39,7 @@ char *pim_tlv_append_uint16(uint8_t *buf,
   uint16_t option_len = 2;
 
   if ((buf + PIM_TLV_OPTION_SIZE(option_len)) > buf_pastend) {
-    zlog_warn("%s: buffer overflow: left=%d needed=%d",
+    zlog_warn("%s: buffer overflow: left=%zd needed=%d",
 	      __PRETTY_FUNCTION__,
 	      buf_pastend - buf, PIM_TLV_OPTION_SIZE(option_len));
     return 0;
@@ -64,7 +64,7 @@ char *pim_tlv_append_2uint16(uint8_t *buf,
   uint16_t option_len = 4;
 
   if ((buf + PIM_TLV_OPTION_SIZE(option_len)) > buf_pastend) {
-    zlog_warn("%s: buffer overflow: left=%d needed=%d",
+    zlog_warn("%s: buffer overflow: left=%zd needed=%d",
 	      __PRETTY_FUNCTION__,
 	      buf_pastend - buf, PIM_TLV_OPTION_SIZE(option_len));
     return 0;
@@ -90,7 +90,7 @@ char *pim_tlv_append_uint32(uint8_t *buf,
   uint16_t option_len = 4;
 
   if ((buf + PIM_TLV_OPTION_SIZE(option_len)) > buf_pastend) {
-    zlog_warn("%s: buffer overflow: left=%d needed=%d",
+    zlog_warn("%s: buffer overflow: left=%zd needed=%d",
 	      __PRETTY_FUNCTION__,
 	      buf_pastend - buf, PIM_TLV_OPTION_SIZE(option_len));
     return 0;
@@ -137,7 +137,7 @@ char *pim_tlv_append_addrlist_ucast(uint8_t *buf,
       continue;
 
     if ((curr + ucast_ipv4_encoding_len) > buf_pastend) {
-      zlog_warn("%s: buffer overflow: left=%d needed=%d",
+      zlog_warn("%s: buffer overflow: left=%zd needed=%zu",
 		__PRETTY_FUNCTION__,
 		buf_pastend - curr, ucast_ipv4_encoding_len);
       return 0;
@@ -155,7 +155,7 @@ char *pim_tlv_append_addrlist_ucast(uint8_t *buf,
   }
 
   if (PIM_DEBUG_PIM_TRACE) {
-    zlog_warn("%s: number of encoded secondary unicast IPv4 addresses: %d",
+    zlog_warn("%s: number of encoded secondary unicast IPv4 addresses: %zu",
 	      __PRETTY_FUNCTION__,
 	      option_len / ucast_ipv4_encoding_len);
   }
@@ -398,7 +398,7 @@ int pim_parse_addr_ucast(const char *ifname, struct in_addr src_addr,
     if ((addr + sizeof(struct in_addr)) > pastend) {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: IPv4 unicast address overflow: left=%d needed=%d from %s on %s",
+      zlog_warn("%s: IPv4 unicast address overflow: left=%zd needed=%zu from %s on %s",
 		__PRETTY_FUNCTION__,
 		pastend - addr, sizeof(struct in_addr),
 		src_str, ifname);
@@ -471,7 +471,7 @@ int pim_parse_addr_group(const char *ifname, struct in_addr src_addr,
     if ((addr + sizeof(struct in_addr)) > pastend) {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: IPv4 group address overflow: left=%d needed=%d from %s on %s",
+      zlog_warn("%s: IPv4 group address overflow: left=%zd needed=%zu from %s on %s",
 		__PRETTY_FUNCTION__,
 		pastend - addr, sizeof(struct in_addr),
 		src_str, ifname);
@@ -549,7 +549,7 @@ int pim_parse_addr_source(const char *ifname,
     if ((addr + sizeof(struct in_addr)) > pastend) {
       char src_str[100];
       pim_inet4_dump("<src?>", src_addr, src_str, sizeof(src_str));
-      zlog_warn("%s: IPv4 source address overflow: left=%d needed=%d from %s on %s",
+      zlog_warn("%s: IPv4 source address overflow: left=%zd needed=%zu from %s on %s",
 		__PRETTY_FUNCTION__,
 		pastend - addr, sizeof(struct in_addr),
 		src_str, ifname);

+ 1 - 1
pimd/pim_upstream.c

@@ -355,7 +355,7 @@ static struct pim_upstream *pim_upstream_new(struct in_addr source_addr,
 
   up = XMALLOC(MTYPE_PIM_UPSTREAM, sizeof(*up));
   if (!up) {
-    zlog_err("%s: PIM XMALLOC(%d) failure",
+    zlog_err("%s: PIM XMALLOC(%zu) failure",
 	     __PRETTY_FUNCTION__, sizeof(*up));
     return 0;
   }